EIP-7702 is an Ethereum change, activated in the Pectra upgrade in May 2025, that lets an ordinary externally owned account (EOA) point its address at a smart contract's code. The owner signs an authorisation naming a delegate contract, and a new type 4 (0x04) transaction writes a 23-byte delegation designator (0xef0100 followed by the delegate's address) into the EOA's code. From then on, any call to the EOA runs the delegate's code in the EOA's own context, with its own balance and storage, so the same address gains batching, gas sponsorship and custom permissions. The private key is never replaced: it can always sign a new delegation or clear the old one.
Why EOAs needed this
An EOA on Ethereum can do exactly one thing per transaction, must hold ETH for gas, and accepts only one rule: a valid secp256k1 signature. ERC-4337 account abstraction fixed that by making the account a contract, but a 4337 account lives at a new address. Users with years of history, approvals and assets on their EOA would have to migrate everything.
EIP-7702 takes the opposite route. The address stays the same; it simply gets code attached. A user who connects the same wallet tomorrow can approve and swap in one transaction, have an app pay their gas, or grant a game a limited session key, without moving a single token.
How a delegation is set
The authorisation is a signed tuple, separate from the transaction signature:
authorization = [chain_id, address, nonce, y_parity, r, s]
signed message = keccak256(0x05 || rlp([chain_id, address, nonce]))
addressis the delegate contract whose code the EOA will run.chain_idbinds it to one chain. Achain_idof0makes it valid on every EVM chain that supports 7702, which is convenient and dangerous in equal measure.noncemust equal the EOA's current nonce, so each authorisation can be used once.
Authorisations travel inside a type 4 transaction's authorization_list. Anyone can submit that transaction: the EOA itself, or a relayer paying the gas. For each tuple, the client recovers the signer, checks the chain ID and nonce, writes 0xef0100 || address as the signer's code, and increments the signer's nonce. Invalid tuples are skipped rather than failing the whole transaction. The list cannot be empty and the transaction must have a to address, so 7702 transactions can't deploy contracts.
Two details catch people out:
- Self-sponsored nonces. If the EOA sends the transaction itself, its transaction nonce is consumed first, so the authorisation must carry
current nonce + 1. Libraries handle this when told the EOA is the executor. - Persistence. The delegation survives after the transaction. It stays until the EOA signs another authorisation. Signing one for the zero address clears the code back to empty.
Each tuple costs 25,000 gas in intrinsic cost, with 12,500 refunded when the authority account already exists, so delegating a normal, funded EOA costs about 12,500 gas per authorisation on top of the transaction.
What changes once the EOA has code
When CALL, STATICCALL, DELEGATECALL or a transaction targets a delegated EOA, the client loads the delegate's code and executes it with address(this) equal to the EOA. Storage writes go to the EOA's storage. The delegate contract's own storage is never touched.
| Operation on a delegated EOA | Result |
|---|---|
| Call or transaction to it | Runs the delegate's code in the EOA's context |
EXTCODESIZE | 23 (the designator), not 0 |
EXTCODEHASH / EXTCODECOPY | Hash or bytes of the 23-byte designator |
| Delegation to another delegated account | Not followed; only one hop is resolved |
| Delegation to a precompile | Treated as empty code |
| Sending transactions | Still allowed (EIP-3607 was relaxed for designators) |
You can see a delegation directly:
cast code 0xYourEOA --rpc-url "$RPC_URL"
# 0x -> plain EOA
# 0xef0100<20-byte delegate address> -> delegated via EIP-7702
A minimal delegate and how to use it
A delegate contract is written like any other contract, except that address(this) will be the user's EOA. This one lets the EOA batch calls when it sends a transaction to itself:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
contract BatchExecutor {
struct Call {
address to;
uint256 value;
bytes data;
}
error Unauthorized();
error CallFailed(uint256 index, bytes reason);
function execute(Call[] calldata calls) external payable {
// Under 7702, address(this) is the EOA. Only the EOA itself may call.
if (msg.sender != address(this)) revert Unauthorized();
for (uint256 i = 0; i < calls.length; i++) {
(bool ok, bytes memory ret) = calls[i].to.call{value: calls[i].value}(calls[i].data);
if (!ok) revert CallFailed(i, ret);
}
}
receive() external payable {}
}
With viem, the EOA signs the authorisation and sends a type 4 transaction to its own address, in one step:
import { createWalletClient, http, encodeFunctionData, parseEther } from "viem";
import { privateKeyToAccount } from "viem/accounts";
import { sepolia } from "viem/chains";
import { batchExecutorAbi } from "./abi";
const eoa = privateKeyToAccount(process.env.PRIVATE_KEY as `0x${string}`);
const walletClient = createWalletClient({ account: eoa, chain: sepolia, transport: http() });
const authorization = await walletClient.signAuthorization({
contractAddress: "0xBatchExecutorAddress",
executor: "self", // the EOA sends the tx, so the auth uses nonce + 1
});
const hash = await walletClient.sendTransaction({
authorizationList: [authorization],
to: eoa.address,
data: encodeFunctionData({
abi: batchExecutorAbi,
functionName: "execute",
args: [[
{ to: "0xRecipientA", value: parseEther("0.01"), data: "0x" },
{ to: "0xRecipientB", value: parseEther("0.01"), data: "0x" },
]],
}),
});
For a sponsored flow, a relayer submits the transaction instead, and the delegate must check a signature from the EOA's key over the calls, the chain ID, address(this) and a replay nonce. That is exactly what audited smart account implementations already do, and several are built to run behind 7702 while speaking ERC-4337, so bundlers and paymasters work with a delegated EOA. In Foundry you can test all of this locally with the vm.signAndAttachDelegation(implementation, privateKey) cheatcode, which attaches the delegation for the next call.
In practice, you rarely ask users to delegate to your own contract. Wallets upgrade users to their own audited implementation, and dApps request batches through EIP-5792 (wallet_sendCalls) and let the wallet decide how to execute them.
What it means for contract developers
Even if you never write a delegate, 7702 changes assumptions your existing contracts may rely on.
tx.origin == msg.sender no longer means "no code". An EOA can now run code during its own transaction, so checks that use this to block contracts, or to guard against reentrancy, are unsound. Use proper reentrancy protection in Solidity instead.
EXTCODESIZE > 0 doesn't mean "contract". A delegated EOA has 23 bytes of code. Logic that treats code size as "not a user" will misclassify it. Equally, the account still has a working private key, so signatures from it can be verified with ecrecover as well as ERC-1271.
Token callbacks now fire. safeTransferFrom for ERC-721 and ERC-1155 calls onERC721Received or onERC1155Received on any address with code. If the delegate doesn't implement them, NFT transfers to that user revert. Similarly, a delegate with no receive or payable fallback makes plain ETH transfers to the EOA fail.
Batching shrinks approval windows. A user can approve exactly the amount needed and spend it in the same transaction, which reduces the risks described in how ERC-20 allowances and permits can be abused.
If you write delegates, three rules from the EIP's own security section matter most:
- No initcode runs. Storage can't be set during delegation, so an
initializecall sent separately can be front-run. Require initialisation data to be signed by the EOA key and check it withecrecover. - Storage persists across delegates. Switching from delegate A to delegate B leaves A's storage in place, and B may read it as something else. Use namespaced storage (ERC-7201), the same discipline as in upgradeable proxy contracts.
- Sponsors can be griefed. An EOA can invalidate its authorisation by bumping its nonce before the relayer's transaction lands, or sweep its funds mid-flow. Relayers need simulation, bonds or reputation, as with ERC-4337 bundlers.
Security for users
A delegation grants a contract full control of everything at the address, indefinitely, until it is revoked. That made it an immediate phishing target: soon after Pectra, analysts reported that a large share of mainnet delegations pointed to copy-pasted "sweeper" contracts that drain any ETH sent to an address whose key had already leaked. Well-designed wallets defend against this by refusing to sign authorisations for arbitrary contracts, by showing the delegate clearly, and by warning on or rejecting chain_id = 0.
The key also remains the master credential. 7702 adds features, but it cannot rotate the key away or add a second signer that overrides it, so a leaked seed phrase still loses everything. For treasury-sized balances, a multisig or MPC setup for team funds or a smart account at a fresh address is still the right tool.
Checklist
- A 7702 delegation is a signed
[chain_id, address, nonce]tuple carried in a type 4 transaction; it writes0xef0100 || delegateas the EOA's code. - It persists until replaced. Delegating to the zero address clears it; storage is never cleared.
- Self-sent delegations need
nonce + 1; useexecutor: "self"in viem. - Remove
tx.origin == msg.senderandEXTCODESIZEchecks that assume EOAs have no code. - Delegates must implement
receiveand token receiver hooks, use ERC-7201 storage, and verify signed initialisation. - Use audited delegate implementations and EIP-5792 batching; never ask users to delegate to unknown code.
- Treat any request to sign a delegation, especially with
chain_id = 0, as high risk.
The full specification is at eips.ethereum.org/EIPS/eip-7702.
Get the weekly commit
New blockchain deep dives every week.