The real question is not where the key is stored
Most discussions about AI agents and crypto wallets start with storage: MPC or HSM, enclave or hardware signer. Storage matters, but it is the second question. The first is simpler. What is the worst thing this agent can sign if someone else is steering it?
Assume that someone else will steer it at some point. Agents act on text they read, and some of that text will be written by attackers. Prompt injection has no reliable general fix today. So a secure design does not depend on the agent behaving well. It makes sure that when the agent misbehaves, the damage stays small, and someone notices quickly.
Start by asking whether the agent needs a wallet at all
Before designing key management, check whether blockchain belongs in this workflow.
If your agent pays for things inside your own platform, such as credits, internal transfers or usage billing, a conventional database ledger is cheaper, faster, reversible, and easier to audit. An on-chain wallet adds irreversibility and custody risk without adding anything you need.
If the agent's job is to prepare a transaction that a person approves anyway, it does not need signing authority. It can draft, explain, and queue. Execution stays with the human or with a deterministic system.
If the action follows fixed rules, such as a scheduled payout or a rebalance at a set threshold, plain automation with no model involved is more predictable and much easier to audit.
An agent wallet makes sense when the agent must act on-chain, without waiting for a person, at a frequency where human approval would defeat the purpose. If your use case does not meet that test, the most secure key is the one the agent never gets.
Split the job into three parts
When an agent does need to act onchain, separate three responsibilities and keep each behind its own boundary.
The agent proposes. It describes what it wants to do: transfer this amount, call this function, interact with this contract. It holds no signing material.
A policy layer decides. Deterministic code the agent cannot modify checks the proposal against rules, ideally after simulating the transaction to see what it would actually do.
A signer executes. Only approved proposals are signed by a component the agent cannot reach directly.
This is ordinary least privilege, applied to a component that takes its instructions from untrusted text. The one rule worth repeating is that the agent must never be able to edit its own policy. Limits the agent can raise are not limits.
The options, honestly compared
Managed agent wallet services combine MPC or enclave key storage with an offchain policy engine. They are fast to adopt and move heavy operational work to a specialist. The cost is dependence: you trust the provider to enforce your policies correctly, you inherit their uptime and roadmap, and leaving later can be painful. For many teams, especially early ones, this is still the right call.
Smart contract accounts with session keys give the agent a scoped, expiring credential, and the chain enforces the limits. You avoid trusting a server and keep the root key yourself. In exchange, the account and its permission modules are contracts that need independent audits, chain support varies, and the engineering effort is higher.
Self-hosted signing with HSMs or enclaves gives full control and works across chains and off-chain systems. It also makes you responsible for running critical security infrastructure around the clock, which suits organisations that already have that capability.
Hardware signers with human approval are the strongest control for large actions and the weakest for autonomy. Used only above a threshold, they pair well with any of the above.
Mature setups usually layer these: session keys for small routine actions, policy checks for medium ones, and multisig or hardware approval for anything material.
Policies that bound the worst case
Good policies are boring and specific:
Caps per transaction and per day, sized to a loss you could absorb.
Allowlists of destinations and contracts, with new entries needing human sign-off.
Permissions at the level of individual functions, never blanket approval to interact with a contract. Unlimited token approvals should not be routine.
Simulation before signing, rejecting anything whose effect differs from the stated intent.
Expiry on every delegated permission, so access lapses unless someone renews it.
A small working balance, topped up from a treasury the agent cannot touch.
Also separate reading from signing. An agent that browses the web, reads email, or processes token metadata should not be the same agent that holds a transfer tool. Never let keys or seed phrases appear in prompts, memory, logs or traces, and never let an unsolicited on-chain asset or message trigger an action.
Compliance does not move into the model
For regulated assets, the agent is the wrong place for compliance logic. A permissioned token standard such as ERC3643 enforces transfer rules against verified identity claims inside the token itself. That is where those rules belong. If an agent operates a wallet that holds regulated tokens, that wallet still needs to be tied to a verified owner through your KYC/AML process, and accountability for its transactions sits with that owner, not with the model.
Keep the agent inside the rules rather than making it responsible for them.
Plan for the bad day
Write the incident plan before you deploy:
A pause mechanism you have actually triggered in a drill.
One-step revocation of session keys and delegated permissions.
Key rotation on a schedule and after any suspected exposure.
Alerts on every signed transaction, routed to someone who can act.
A clear owner for each decision during an incident.
Ownership and verification
Two checks separate a system you own from one you rent. First, the client should hold the root keys, upgrade keys, and authority to change policy, and the developer should hold none of them after handover. Verify this on-chain, not just in a contract document. Second, independently audit the smart contracts, policy logic, and signing service, including adversarial tests that try to talk the agent past its limits.
When you scope this work with any vendor, ask for these answers before the build starts, not after launch.
This article is general guidance, not a security audit. Have qualified security professionals review your specific architecture.
RWaltz is a blockchain and enterprise software development company. It builds smart contracts, dApps, and tokenization platforms on a build-to-own model, where clients keep their code, IP, and keys, and independent security audits are part of delivery.
📖 Read the full blog: https://www.rwaltz.com/blogs/securing-ai-agents-that-hold-private-keys-a-practical-architecture-guide
Connect with RWaltz:
LinkedIn: https://www.linkedin.com/company/rwaltzsoftware
X (Twitter): https://twitter.com/rwaltzsoftware
Facebook: https://www.facebook.com/RWaltz-Software-PvtLtd-255590135349493
Telegram: https://t.me/RWaltzCrypto
GitHub: https://github.com/rwaltzsoftware
Clutch: https://clutch.co/profile/rwaltz-software
Website: https://www.rwaltz.com

