Generate or import wallet details using either a mnemonic seed phrase or private key. Use when the user asks for wallet creation, recovery, onboarding, or key-based wallet setup.
viemRPC_URL (only needed when validating on-chain state)SEED_PHRASE only for mnemonic importPRIVATE_KEY only for private key importAccept one of:
0x prefixed or raw hex)viem (section below).0x and non-0x formats0x[0-9a-fA-F]When the agent has no wallet configured, create one first, then continue with normal wallet/transaction flows.
import { generateMnemonic, mnemonicToAccount } from 'viem/accounts'
const mnemonic = generateMnemonic()
const account = mnemonicToAccount(mnemonic)
// Store mnemonic in secure secret storage only.
// Persist account.address as the agent wallet address.
import { generatePrivateKey, privateKeyToAccount } from 'viem/accounts'
const privateKey = generatePrivateKey()
const account = privateKeyToAccount(privateKey)
// Store privateKey in secure secret storage only.
// Persist account.address as the agent wallet address.
seedPhrase, derive with mnemonicToAccount.privateKey, derive with privateKeyToAccount.seed phrase or private keygenerated, imported, or derived<derived-address><network> / <derivation-path-if-used>validated and hiddensuccess | failed | needs_confirmation<backup|fund wallet|run balance check>action: generate | importchain: chain id/name used, or none if offline generation onlyaddress: derived wallet addresstxHash: nullstatus: success | failed | needs_confirmationnext_step: one clear follow-up action