This repository demonstrates EIP-7702: EOA Code Setting, a significant Ethereum upgrade introduced in Pectra upgrade.
EIP-7702 allows Externally Owned Accounts (EOAs) to have code through a delegation mechanism. This brings smart contract capabilities to EOAs without requiring users to migrate to new accounts.
- Set delegation code on EOAs
- Execute contract code in EOA context
- Maintain EOA transaction signing ability
- Support for cross-chain authorizations
- Transaction batching
- Gas sponsorship
- Granular permissions
- Account abstraction features
Our repository includes a complete example of gas sponsorship using EIP-7702:
// Alice authorizes Sponsor contract
bytes memory code = abi.encodePacked(hex"ef0100", address(sponsor));
vm.etch(alice, code); // Sets delegation code
// Execute sponsored transfer where:
// 1. Relayer pays gas
// 2. Value comes from Alice
// 3. Bob receives the transfer
vm.prank(alice);
address(alice).call{value: 1 ether}(
abi.encodeWithSelector(Sponsor.sponsoredTransfer.selector, bob)
);| Party | Pays |
|---|---|
| Alice | Transfer value (e.g., 1 ETH) |
| Relayer | Gas fees |
| Bob | Nothing (recipient) |
bytes memory delegationCode = abi.encodePacked(
hex"ef0100", // EIP-7702 magic bytes
address(contract) // Target contract address
);// Create a sponsor contract
Sponsor sponsor = new Sponsor();
// Set delegation on EOA (only works in Prague+)
bytes memory code = abi.encodePacked(hex"ef0100", address(sponsor));
vm.etch(eoa, code); // Sets delegation code
// Any call to EOA is delegated to sponsor contract
// but executes in EOA's contextThe repository includes tests that verify EIP-7702 functionality across different EVM versions:
# Should pass - Prague supports EIP-7702
FOUNDRY_PROFILE=prague forge test
# Alternatively
pnpm test
# Should fail - Shanghai doesn't support EIP-7702
FOUNDRY_PROFILE=shanghai forge test
# Alternatively
pnpm test:shanghaisrc/Sponsor.sol: Example contract for gas sponsorshipsrc/EIP7702Demonstrator.sol: Helper contract for demonstrationstest/SponsoredTransferTest.t.sol: Test suite showing sponsored transferstest/EIP7702Support.t.sol: Test suite for EVM version compatibility
- Foundry
v1.0(learn more here)
pnpm i
forge install# Build
forge build
# Test with specific EVM version
FOUNDRY_PROFILE=prague forge test -vvvFirst, start a local Anvil node:
anvilThen in a new terminal, deploy using one of the following commands:
Deploy with default (Prague) settings:
forge script script/Deploy.s.sol --broadcast --fork-url http://localhost:8545Deploy with Prague profile explicitly:
FOUNDRY_PROFILE=prague forge script script/Deploy.s.sol --broadcast --fork-url http://localhost:8545Deploy with Shanghai profile:
FOUNDRY_PROFILE=shanghai forge script script/Deploy.s.sol --broadcast --fork-url http://localhost:8545For these scripts to work, you need to have a MNEMONIC environment variable set to a valid
BIP39 mnemonic.
For instructions on how to deploy to a testnet or mainnet, check out the Solidity Scripting tutorial.
| Feature | Prague | Shanghai |
|---|---|---|
| Set EOA Code | ✅ | ❌ |
| Code Size | 23 bytes | 0 bytes |
| Delegation | Supported | Not Supported |
| Gas Sponsorship | ✅ | ❌ |
=== EIP-7702 Sponsored Transfer Details ===
Delegation code size: 23
Gas used: 68690
Value transferred: 1000000000000000000
Sender (Alice) balance change: 1000000000000000000
Recipient (Bob) balance change: 1000000000000000000
This repository includes scanning tools to detect which networks support EIP-7702.
Automated tool that scans all EVM-compatible networks from chainid.network to detect EIP-7702 support:
# Make script executable and run the complete scan
chmod +x eip7702_scanner.sh
./eip7702_scanner.shThe scanner tests each network's RPC endpoints using EIP-7702 state override syntax with eth_estimateGas calls. It
generates three files:
eip7702-networks.md- Detailed markdown report with all supported networkseip7702-chain-ids.txt- Simple text file listing supported chain IDseip7702-networks.ts- TypeScript export for integration
Tool to check the operational status of individual chains:
# Make script executable
chmod +x check_chain_status.sh
# Check status of a specific chain
./check_chain_status.sh <chain_id>
# Examples
./check_chain_status.sh 1 # Ethereum Mainnet
./check_chain_status.sh 10 # Optimism
./check_chain_status.sh 8453 # BaseThis tool provides:
- Chain metadata (name, native currency, TVL)
- RPC endpoint testing
- Block production verification
- Transaction activity analysis
The scanner creates the following output files:
eip7702-networks.md- Human-readable report with network details and verification instructionseip7702-networks.txt- Plain text list of supported chain IDs (one per line)eip7702-networks.ts- TypeScript array export for programmatic use
Feel free to reach out to Julien through:
- Element: @julienbrg:matrix.org
- Farcaster: julien-
- Telegram: @julienbrg
- Twitter: @julienbrg
- Discord: julienbrg
- LinkedIn: julienberanger