- EIP-7702 (live since the Pectra upgrade, May 7, 2025) lets an externally owned account (EOA) temporarily run a smart contract’s code through a new transaction type,
0x04. - You sign an authorization naming a contract; the network writes a 23-byte delegation designator —
0xef0100followed by the contract address — into the EOA’s code.eth_getCodethen returns that designator instead of0x. - The delegate runs in the EOA’s own storage and balance context, which unlocks batching, gas sponsorship, and session keys without moving funds to a new address.
- All examples below use viem and are verified against Chainstack on Sepolia (chain ID
11155111), where Pectra has been live since March 5, 2025.
What is EIP-7702
EIP-7702, “Set code for EOAs,” is the account-abstraction feature shipped in Ethereum’s Pectra upgrade. It introduces a new EIP-2718 transaction type,0x04 (the set-code transaction), that carries an authorization_list. Each authorization lets an EOA delegate its code to a smart contract — so the EOA can do things only contracts could before (batch multiple calls atomically, let someone else pay gas, enforce custom signing rules) while keeping the same address, balance, and history.
Unlike ERC-4337, which runs through a separate mempool and bundlers, EIP-7702 is a native transaction type — you send it to any standard JSON-RPC endpoint.
Get your own node endpoint today
Start for free and get your app to production levels immediately. No credit card required.You can sign up with your GitHub, X, Google, or Microsoft account.How EIP-7702 works
A set-code transaction carries an authorization list. Each authorization is a signed tuple:| Field | Meaning | ||
|---|---|---|---|
chain_id | The chain the authorization is valid on, or 0 to make it valid on every EVM chain that supports EIP-7702. | ||
address | The contract to delegate to. Set it to the zero address to revoke. | ||
nonce | Must match the authorizing account’s nonce at validation time. | ||
y_parity, r, s | A secp256k1 signature over `keccak256(0x05 | rlp([chain_id, address, nonce]))`. |
0xef prefix is a banned opcode (EIP-3541), so clients treat the designator as a pointer rather than executable code. Two consequences matter in practice:
- The delegate executes in the EOA’s storage and balance context — inside the contract,
address(this)is the EOA’s address. - The delegation persists across transactions until you change it. It is not undone at the end of the block.
The authorization signature uses the magic byte
0x05, which is different from the transaction type byte 0x04. viem and other libraries handle this for you.Self-sponsor vs relayer
There are two ways to submit a set-code transaction:- Self-sponsor — the EOA both signs the authorization and sends the transaction. Because the transaction consumes the EOA’s nonce, the authorization’s nonce must be
transaction.nonce + 1. viem handles this off-by-one automatically when you passexecutor: 'self'. - Relayer (sponsored) — a separate account pays gas and submits the transaction; the EOA only signs the authorization. The authorization’s nonce equals the EOA’s current nonce.
Prerequisites
You need an Ethereum node endpoint on a network where Pectra is live. For development, use Sepolia. Then install viem (version 2.x has stable EIP-7702 support):Delegate an EOA to a contract
This self-sponsored flow signs an authorization and sends the type-0x04 transaction from the same EOA. Point the transport at your Chainstack Sepolia endpoint.
index.js
type is eip7702, and the EOA now carries the delegation designator.
Read and revoke a delegation
Read the EOA’s code with eth_getCode — a delegated account returns the 23-byte designator instead of0x:
index.js
index.js
Revoking removes the code pointer, but it does not clear the EOA’s storage. State written by a previous delegate remains in the account’s storage slots.
Batch transactions from an EOA
The headline EIP-7702 use case is executing several calls atomically — for exampleapprove and transfer in a single transaction. Delegate to a minimal batch executor:
BatchCallDelegation.sol
writeContract, which also accepts an authorizationList:
index.js
Sponsor gas with a relayer
In the relayer pattern, a separate account pays gas and submits the transaction while the EOA only signs the authorization. Omitexecutor: 'self' and put the relayer on the wallet client:
index.js
Security considerations
EIP-7702 hands a contract control over your account’s storage and balance. By mid-2025 there were already real losses — a $1.54M batch-transaction phishing attack and a $146K drainer variant — so treat delegation with care.- Storage collisions — changing delegation does not clear storage. If a new delegate uses a storage slot differently than the previous one, it reads corrupted data. Use ERC-7201 namespaced storage in any contract meant to be a delegate.
- Broken
tx.originchecks — a delegated EOA can run contract logic while still beingtx.origin, sorequire(tx.origin == msg.sender)no longer proves “called by an EOA.” Replace such guards with an explicit reentrancy guard. - Constructors do not run — delegation never calls the contract’s constructor. Initialize through an explicit
initialize()guarded against re-initialization. - Bundle initialization — if you split delegation and initialization into two transactions, an attacker can front-run the init. Encode the init call in the same set-code transaction’s
data. chain_id = 0— an authorization signed with chain ID0is valid on every EIP-7702 chain. Only use it deliberately.
Networks
EIP-7702 is available wherever Pectra has activated.| Network | Chain ID | Pectra activation |
|---|---|---|
| Ethereum mainnet | 1 | May 7, 2025 |
| Sepolia | 11155111 | Mar 5, 2025 |
| Hoodi | 560048 | Mar 2025 |
Frequently asked questions
What is the EIP-7702 delegation designator?
It is the 23-byte value0xef0100 followed by the 20-byte delegate contract address, written to the EOA’s code when a valid authorization is processed. eth_getCode returns it for a delegated account; a plain EOA returns 0x.
How do I revoke an EIP-7702 delegation?
Send another set-code transaction with an authorization whoseaddress is the zero address (0x0000000000000000000000000000000000000000). The EOA’s code resets to empty. Note that storage written by the previous delegate is not cleared.
What is the difference between self-sponsor and relayer mode?
In self-sponsor mode the EOA signs the authorization and sends its own transaction, soauthorization.nonce must be tx.nonce + 1 (viem’s executor: 'self' handles this). In relayer mode a different account pays gas and submits the transaction, and authorization.nonce equals the EOA’s current nonce.
Can I use ethers.js or viem for EIP-7702?
viem 2.x has first-class, stable support (signAuthorization, authorizationList on sendTransaction/writeContract), which is what this guide uses. ethers added support more recently; viem is the most mature today.
Is EIP-7702 live on mainnet?
Yes — it shipped with Pectra on Ethereum mainnet on May 7, 2025, and on Sepolia on March 5, 2025. Use Sepolia for development.Does a delegation expire?
No. The delegation designator persists across transactions and blocks until you change it or revoke it with a new set-code transaction. A single signed authorization delegates indefinitely.Related resources
- Ethereum API reference — endpoints, methods, and networks
- Ethereum tooling — ethers.js, viem, and framework setup
- eth_getCode — read an account’s code (and its delegation designator)
- eth_sendRawTransaction — broadcast signed transactions
- Ethereum Dencun: rundown with examples — the previous upgrade’s features
- EIP-7702 specification — the canonical spec
- viem EIP-7702 documentation — full API reference