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. When using Transaction APIs:
- Transaction APIs detect whether a user must first delegate via EIP-7702
- If delegation is required, Transaction APIs prepare the correct authorization payload
- Your application prompts the user to sign when required
- We combine the delegation and transaction into a single onchain submission
Once delegated, the user’s account behaves as a Smart Wallet while keeping the same address and assets.
Prerequisites
- API key from your dashboard
Implementation
JavaScript
API
Use the eip7702Auth capability on the smart wallet client sendCalls action. sendCalls will automatically
sign any required authorization requests to delegate the EOA to Modular Account v2.
If the signing EOA is delegated to a different smart contract, sendCalls
will request to re-delegate to Modular Account v2, overriding any previous
delegation.
See the sendCalls SDK
reference
for full descriptions of the parameters used in the following example.
Advanced
How Wallet APIs handle delegation and signing
When interacting with Wallet APIs, delegation is handled automatically as part of transaction preparation.
If a user has not yet delegated on the target chain, the API response will include multiple signature requests:
- An EIP-7702 authorization signature (for delegation)
- An ERC-4337 user operation signature (for the transaction itself)
Your application is responsible for:
- Prompting the user to sign each request
- Returning the signatures to Alchemy
We combine these signatures into a single UserOperation and submits it to the bundler. After delegation is completed, future requests only require a user operation signature.
EIP-7702 authorization signing
When delegation is required, Wallet APIs return a Prepared EIP-7702 Authorization object.
This includes:
- The delegation contract address
- A nonce
- The chain ID
- A
signatureRequestdescribing how the authorization must be signed
For quick testing purposes, you can simply use eth_sign to sign the signatureRequest.rawPayload.
For production usage, we recommend:
- Verifying the delegation address is trusted
- Using a dedicated EIP-7702 signing utility to compute the hash to sign
Example of signing utility:
Delegation-only (smart account upgrade) flows
You do not need to send a dummy or no-op transaction to perform delegation.
If a user needs to upgrade to a Smart Wallet:
- Call
wallet_prepareCallswith your intended calls (or an empty call set) - Wallet APIs detect that delegation is required
- The response includes the required authorization and user operation signature requests
We handle combining delegation with the user operation automatically.
Wallet compatibility considerations
Some wallets restrict or block signing EIP-7702 authorizations for security reasons.
In particular:
- MetaMask only allows delegation to its own contract via its UI
- MetaMask does not support signing arbitrary EIP-7702 authorization payloads
For MetaMask users, you may need to rely on wallet-native features such as ERC-5792 batching instead of direct EIP-7702 delegation flows.
Ensure your users’ wallets support EIP-7702 authorization signing before enabling this flow.
EIP-7702 delegations
The eip7702Auth capability supports the interface defined in ERC-7902.
Currently, Wallet APIs only support delegation to the following contract:
0x69007702764179f14F51cdce752f4f775d74E139 (Modular Account v2)
All other delegation addresses will be rejected.
To simplify usage, it is recommended to use eip7702Auth: true.
Once delegated, an account remains delegated until the delegation is replaced or removed.
To reset an account back to a pure EOA, delegate to
0x0000000000000000000000000000000000000000
as defined in EIP-7702.
Third party signers
If you have an existing custom signer or another third-party embedded wallet provider, you can upgrade your embedded EOAs to smart wallets by connecting your existing signer. This will allow you to use EIP-7702 to get features like gas sponsorship, batching, and more.
Requirement: Your signer or embedded wallet provider must support signing EIP-7702 authorizations in order to delegate to a smart account.
To bring your own signer, you create a SmartAccountSigner that implements signAuthorization. See the details for the interface requirements here.
For example, you can upgrade an existing Privy embedded EOA by extending a Wallet Client to use the sign7702Authorization action exposed by Privy.
See full example code here.
The bulk of the logic happens in use-embedded-smart-wallet.ts.
In this react hook, a Privy embedded wallet is wrapped in a WalletClientSigner that supports signAuthorization.
This signer is then passed to createSmartWalletClient to construct a client for sending transactions.
When using the SmartWalletClient you must set the eip7702Auth capability to true, as shown in smart-wallet-demo.tsx
Next steps
Build more: