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

Implementation

Required SDK version: ^v4.61.0

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.

sendCalls.tsx
1import { useSendCalls, useSmartAccountClient } from "@account-kit/react";
2
3export default function SendCalls() {
4 const { client } = useSmartAccountClient({
5 accountParams: {
6 mode: "7702",
7 },
8 });
9 const { sendCallsAsync } = useSendCalls({ client });
10
11 const handleSend = async () => {
12 if (!client) {
13 throw new Error("Smart account client not connected");
14 }
15
16 try {
17 const { ids } = await sendCallsAsync({
18 calls: [
19 {
20 to: "0x0000000000000000000000000000000000000000",
21 value: "0x00",
22 data: "0x",
23 },
24 ],
25 });
26
27 console.log("Transaction sent with ID:", ids[0]);
28 } catch (error) {
29 console.error(error);
30 }
31 };
32
33 return <button onClick={handleSend}>Click to Send</button>;
34}

Advanced

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.

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:

  1. An authorization signature request
  2. 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.

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: