EIP-7702 Wallet API Quickstart (SDK)

Learn how to send user ops using EIP-7702 with the Wallet Client SDK

1. Install Prerequisites

You’ll need @account-kit/wallet-client and @account-kit/infra. We’ll also be using LocalAccountSigner from @aa-sdk/core as the signer for demonstration purposes.

$npm install @account-kit/wallet-client @account-kit/infra @aa-sdk/core

2. Create A Smart Wallet Client

Create a client for a given signer (e.g. a LocalAccountSigner imported from @aa-sdk/core or an Alchemy Signer).

1import { createSmartWalletClient } from "@account-kit/wallet-client";
2import { alchemy, arbitrumSepolia } from "@account-kit/infra";
3import { LocalAccountSigner } from "@aa-sdk/core";
4
5const signer = LocalAccountSigner.privateKeyToAccountSigner(PRIVATE_KEY); // we use a private key signer as an example here
6
7const transport = alchemy({
8 apiKey: ALCHEMY_API_KEY, // use your Alchemy app api key here
9});
10
11const client = createSmartWalletClient({
12 transport,
13 chain: arbitrumSepolia, // use any chain imported from @account-kit/infra here
14 signer,
15});

3. Send A Sponsored User Op

All you need to do is follow a few simple steps to start sending user ops with Wallet APIs!

1// Prepare the calls using the 7702 capability.
2const preparedCalls = await client.prepareCalls({
3 calls: [
4 // Calls here can include `to`, `data`, and `value` params.
5 { to: "0x0000000000000000000000000000000000000000", data: "0x" },
6 ],
7 from: "0xFROM_ADDRESS", // put the account address here
8 capabilities: {
9 eip7702Auth: true,
10 paymasterService: {
11 policyId: "your-gas-manager-policy-id", // put your gas manager policy ID here
12 },
13 },
14});
15
16// Sign the calls.
17const signedCalls = await client.signPreparedCalls(preparedCalls);
18
19// Send the userOp.
20const { preparedCallIds } = await client.sendPreparedCalls(signedCalls);
21
22// Check the status of the call.
23const status = await client.getCallsStatus(preparedCallIds[0]);