EIP-7702 with account abstraction¶
Turn a plain EOA into a smart account and act through it — in a single relayed, gas-sponsored transaction. The user signs an EIP-7702 authorization delegating their account to a smart-account implementation; Photon relays a type-0x04 transaction that applies the delegation and executes a call through the newly smart account, paying all gas.
The user's address never changes, and they never need native tokens.
Prerequisites¶
- An API key.
- A chain with the
eip7702flag — see Supported networks. - A delegate contract (your smart-account implementation) deployed on that chain.
- Read EIP-7702 authorizations first — especially the nonce rule.
1. The user signs the authorization¶
The tuple commits to (chainId, delegateAddress, nonce) where nonce is the
authority's current account nonce (Photon's relayer sends the transaction,
so no +1):
import { createWalletClient, http } from "viem";
const authorization = await walletClient.signAuthorization({
contractAddress: "0xYourDelegate…",
chainId: 84532,
nonce: await client.getTransactionCount({ address: user.address }),
});
2. Relay the delegation + first action together¶
Submit a transaction to the user's own address carrying the authorization.
Because the delegation applies before execution, the calldata already runs the
delegate's code — here, a batched execute on the smart-account
implementation:
curl -X POST https://photon.example.com/api/submit-tx \
-H "api-key: $EDITH_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"to": "0xUserAddress…",
"callData": "'"$EXECUTE_BATCH_CALLDATA"'",
"value": "0",
"chainId": 84532,
"authorizationList": [{
"chainId": 84532,
"address": "0xYourDelegate…",
"nonce": 7,
"r": "0x…", "s": "0x…", "yParity": 1
}]
}'
3. Verify the account is smart¶
Once the record reaches EXECUTED, the user's account code is the delegation
designator 0xef0100 ‖ delegateAddress:
const code = await client.getCode({ address: user.address });
// "0xef0100" + delegate address (lowercase, no 0x)
From here on, calls to the user's address run the delegate — every subsequent interaction can go through Submit a transaction as a plain sponsored call, no further authorizations needed.
Why this beats deploy-a-smart-wallet¶
- No new address — assets, history, and identity stay on the EOA.
- One signature to onboard — delegation and the first action share a transaction.
- Still gasless — the relayer funds both the delegation and the calls.
To route the batched call itself, most teams pair this with a multicall-style delegate; if you want Photon to aggregate independent transactions instead, see Batch transactions.