Why Smart Accounts?
Traditional EOA wallets require the user to approve every transaction. This breaks the agent experience — you cannot ask the agent to execute a multi-step DeFi strategy if each step requires manual wallet confirmation. Smart accounts solve this with delegated execution:No Signing Popups
The agent uses a session key to sign transactions without prompting you for each one.
Granular Permissions
Session keys are scoped to specific contracts, function selectors, and spending limits.
Batched Transactions
Multiple DeFi operations (swap + stake + LP) execute atomically in a single UserOperation.
Architecture
The smart account system uses three layers:ZeroDev Kernel
TheAgentSmartAccount class wraps ZeroDev Kernel, an ERC-4337 smart account implementation. Kernel provides:
- ECDSA validator: your EOA is the sudo owner
- Permission plugins: session keys are installed as regular (non-sudo) validators
- Batched execution:
executeBatch()combines multiple calls into one UserOperation - Gas sponsorship: transactions can be sponsored via the Pimlico paymaster
EntryPoint
All UserOperations are submitted to the ERC-4337 EntryPoint contract:| Contract | Address |
|---|---|
| EntryPoint v0.7 | 0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789 |
| Pimlico Bundler | 0x4337001fff419768e088ce247456c1b892888084 |
The Pimlico bundler processes UserOperations and submits them to the EntryPoint. It also provides paymaster functionality for gas sponsorship — users do not need ETH for gas if sponsorship is enabled.
Session Keys
Session keys are the core mechanism for safe agent delegation. Each session key is an ephemeral private key with constrained permissions enforced on-chain by the Kernel permission plugin.Creating a Session Key
Session Key Parameters
| Parameter | Type | Description |
|---|---|---|
validUntil | number | Unix timestamp when the session key expires |
spendingLimitUsdc | bigint | Maximum USDC the session key can spend (6 decimals) |
allowedTargets | Address[] | Contract addresses the key may call |
allowedSelectors | Hex[] | Optional: restrict to specific function selectors |
On-Chain Enforcement
When@zerodev/sdk is installed, session keys are enforced on-chain through Kernel’s permission plugin:
- The agent creates an ECDSA signer from the session private key
- A CallPolicy is constructed with the allowed targets and selectors
- A PermissionValidator is registered that wraps the signer and policies
- A session-scoped Kernel account is created with the permission validator as the regular validator
- UserOperations signed by the session key are validated on-chain against the policy
CallPolicy
TheCallPolicy is the heart of session key security. It defines exactly what the session key can do:
| Constraint | Description |
|---|---|
target | The contract address the key may call |
valueLimit | Maximum ETH value per call (0 = no ETH transfers) |
sig | Function selector restriction (optional) |
Batched Execution
One of the most powerful features of smart accounts is atomic batched execution. Instead of sending 3 separate transactions (approve + swap + supply), the agent can bundle them into a single UserOperation:Fallback Behavior
ThebatchExecute method has a graceful degradation chain:
- Session key client — if a session key is provided and a session-scoped Kernel client exists, uses it
- Owner Kernel client — if ZeroDev SDK and Pimlico are configured, submits as a batched UserOperation
- Deployed smart account — if the Kernel account is deployed on-chain, sends batch calldata directly
- EOA sequential — if no smart account exists, executes calls one at a time from the owner EOA
Gas Sponsorship
With a Pimlico API key configured, the smart account can sponsor gas for users. The Pimlico paymaster covers the gas cost of UserOperations, so users do not need ETH in their wallet to interact with DeFi protocols.Gas sponsorship requires a Pimlico API key. The paymaster is configured during
AgentSmartAccount.init() if the key is provided.Web Frontend Integration
The web UI integrates smart accounts with the Dynamic Labs wallet SDK:- User connects their wallet via Dynamic Labs (supports MetaMask, WalletConnect, Coinbase Wallet, etc.)
- The frontend derives a ZeroDev Kernel address from the connected wallet
- User approves a session key with their desired permissions
- The session key is stored in
sessionStoragefor the browser session - All subsequent agent actions use the session key — no more wallet popups
Session Recovery
If the browser tab is refreshed, theuseChat hook recovers the active session from sessionStorage and reconnects to the agent thread. The session key remains valid until its validUntil timestamp expires.
Revoking Session Keys
Session keys can be revoked immediately:SDK Reference
The smart account is in the@arb-agent/smart-account package as AgentSmartAccount.
Constructor
Methods
| Method | Description |
|---|---|
init() | Initialize the Kernel account and optional Pimlico client |
createSessionKey(params) | Create a scoped session key with on-chain permissions |
batchExecute(calls, sessionKey?) | Execute multiple calls atomically |
sponsoredExecute(call) | Execute a single call with gas sponsorship |
revokeSessionKey(address) | Revoke a session key locally |
Properties
| Property | Type | Description |
|---|---|---|
address | Address | The smart account address (call init() first) |