Using EIP-7702
Upgrade your user’s accounts to Smart Wallets using EIP-7702. This gives users access to all of the capabilities of Smart Wallets including gas sponsorship, batching, and more.
How it works
EIP-7702 enables EOAs (Externally Owned Accounts) to delegate control to smart wallets that can execute code directly from their addresses. Users simply sign an authorization payload to delegate, then their account can function as a smart wallet with access to all of the user’s assets. Wallet APIs will prompt the user to sign this authorization when the delegation is missing on the chain they’re interacting with.
Prerequisites
- API key from your dashboard
Implementation
React
JavaScript
API
To use Smart Wallets in EIP-7702 mode, you must specify the mode when constructing the smart account client with useSmartAccountClient
.
This will allow the authorized EOA to act as a smart wallet with the same address as the EOA. The useSendCalls
hook will sign the required
delegation payload the first time that a user interacts with a new chain. This payload is then relayed on chain with the user’s first transaction.
Prerequisites:
See the useSendCalls
SDK reference for parameter descriptions.
Advanced
When to use EIP-7702
EIP-7702 is particularly useful when you have existing wallets that are being used as EOAs, but want access to smart wallet capabilities while allowing users to keep their existing address and avoid transferring their assets. With EIP-7702, you can upgrade your users’ EOAs directly to a Smart Wallet at their current address.
See a full list of recommendations here.
Usage with prepare calls
The EIP-7702 capability works with the prepare calls function in a similar way to its usage in send calls. However, you are required to handle the authorization signature request in your code’s logic.
When a delegation is required the response to prepare calls will return an array of signature requests:
- An authorization signature request
- A user operation signature request
Both of these requests need to be signed and included in the sendPreparedCalls
request. sendPreparedCalls
takes
an array of signed calls for this purpose. These signatures are combined into a single transaction that is relayed onchain.
Signing an authorization signature request requires logic specific to the wallet being used. Examples:
Most external wallet implementations, including browser wallets, will block requests to sign authorizations. This is done for security reasons. To use EIP-7702 ensure that your user’s wallets support signing authorizations.
React
JavaScript
API
See the usePrepareCalls
react
hook
EIP-7702 delegations
The eip7702Auth
capability supports the interface defined in ERC-7902.
However, it currently only supports a single delegation address: 0x69007702764179f14F51cdce752f4f775d74E139
. All other addresses will be rejected.
It’s recommended to use eip7702Auth: true
to avoid the extra complexity.
Once your account is delegated, it will remain delegated until the delegation is replaced or removed. We currently only support relaying delegations for Modular Account v2. If you wish to replace or remove this delegation, you’ll need to relay the delegation yourself or use a third party service. Viem has a guide for this here.
To reset an account back to a pure EOA with no delegation, delegate the account to 0x0000000000000000000000000000000000000000
as defined in EIP-7702.
Next steps
Build more: