Complete guide and implementation for revoking EIP-7702 delegations on EVM addresses. Includes code examples, scripts, and comprehensive documentation.
- Overview
- What is EIP-7702?
- How Revocation Works
- Prerequisites
- Installation
- Configuration
- Usage
- Technical Details
- Security Considerations
- Resources
This repository provides a complete implementation guide for revoking EIP-7702 delegations on any EVM address. EIP-7702 allows Externally Owned Accounts (EOAs) to temporarily behave like smart contracts by delegating their code execution to a contract. This guide shows you how to safely revoke such delegations.
EIP-7702 ("Set EOA account code for one transaction") is an Ethereum Improvement Proposal that enables EOAs to temporarily delegate their code execution to a smart contract. This provides:
- β Smart account capabilities for regular wallets
- β Batch transaction execution
- β Gasless transactions (via paymasters)
- β Enhanced security features
- β Reversible delegation (can be revoked at any time)
- Temporary Delegation: Only active during the transaction
- Authorization-based: Requires explicit signature from the EOA
- Revocable: Can be cleared by delegating to zero address
- Backward Compatible: Works with existing Ethereum infrastructure
To revoke an EIP-7702 delegation, you simply delegate to the zero address (0x0000000000000000000000000000000000000000). This clears the delegation and returns your EOA to its normal state.
- Sign Authorization: Create an authorization object with the zero address as the target
- Send Transaction: Include the authorization in an EIP-7702 transaction
- Confirmation: Once mined, the delegation is cleared
// The key to revocation: delegate to zero address
const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';
const authorization = await client.signAuthorization({
contractAddress: ZERO_ADDRESS, // This revokes the delegation
});Before using this repository, ensure you have:
- Node.js (v18 or higher)
- npm or yarn package manager
- Private key of the EOA you want to revoke delegation from
- RPC endpoint (e.g., Alchemy, Infura, or public RPC)
- Basic understanding of Ethereum and smart contracts
- Clone the repository:
git clone https://github.com/Babs0022/eip-7702-revoke-delegation.git
cd eip-7702-revoke-delegation- Install dependencies:
npm install
# or
yarn install- Set up environment variables:
cp .env.example .envCreate a .env file in the root directory with the following variables:
# Your EOA private key (DO NOT COMMIT THIS FILE)
PRIVATE_KEY=your_private_key_here
# RPC endpoint URL
RPC_URL=https://eth.llamarpc.com
# (Optional) For delegation script - contract address to delegate to
DELEGATION_CONTRACT=0x....env file or expose your private key!
To revoke an existing EIP-7702 delegation:
npm run revokeThis script will:
- Load your account from the private key
- Sign an authorization to delegate to zero address
- Send the transaction to revoke the delegation
- Display the transaction hash and confirmation
To set up a new delegation (opposite of revocation):
npm run delegateNote: Make sure to set DELEGATION_CONTRACT in your .env file first.
npm run check-delegationAn EIP-7702 authorization tuple contains:
interface Authorization {
chainId: bigint; // Network chain ID
address: Address; // Contract address to delegate to (0x0 for revocation)
nonce: bigint; // Current nonce of the EOA
yParity: number; // Signature recovery bit
r: Hex; // Signature r value
s: Hex; // Signature s value
}1. EOA signs authorization with address = 0x0
β
2. Transaction includes authorizationList
β
3. EVM processes authorization during transaction
β
4. Delegation is cleared, EOA returns to normal state
β
5. Transaction completes successfully
The revocation script (scripts/revoke.ts) demonstrates:
- β Signing authorization with viem
- β Setting delegation target to zero address
- β Sending EIP-7702 transaction
- β Error handling and logging
- β Transaction confirmation
- Revocation transactions are standard EIP-7702 transactions
- Gas costs are similar to regular transactions
- No additional contract interaction required
- Estimated gas: ~50,000 - 100,000 units
-
π Private Key Security
- Never share or commit your private key
- Use hardware wallets when possible
- Keep
.envin.gitignore
-
β Verify Transactions
- Always review transaction details before signing
- Check the delegation target address
- Verify the chain ID matches your network
-
π‘οΈ Delegation Safety
- Only delegate to audited contracts
- Understand what the delegated contract can do
- Revoke delegations when no longer needed
-
π Network Awareness
- Ensure you're on the correct network
- Use testnet for experimentation
- Mainnet delegations involve real assets
- Malicious Contracts: Delegating to unaudited contracts can be dangerous
- Key Compromise: If your private key is stolen, attacker can control delegations
- Transaction Reverts: Always handle transaction failures gracefully
- Viem - TypeScript interface for Ethereum
- EIP-7702 Tools - EIP-7702 reference
- Revoke.cash EIP-7702 Guide
Contributions are welcome! Please feel free to submit a Pull Request. For major changes:
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
This software is provided "as is", without warranty of any kind. Use at your own risk. Always test on testnets before using on mainnet. The authors are not responsible for any losses or damages.
# 1. Clone and install
git clone https://github.com/Babs0022/eip-7702-revoke-delegation.git
cd eip-7702-revoke-delegation
npm install
# 2. Configure environment
cp .env.example .env
# Edit .env with your PRIVATE_KEY and RPC_URL
# 3. Revoke delegation
npm run revokeIf you have questions or need help:
Made with β€οΈ for the Ethereum community