eip7702reset

Crates.ioeip7702reset
lib.rseip7702reset
version1.0.0
created_at2025-10-11 01:35:09.629791+00
updated_at2025-10-11 01:35:09.629791+00
descriptionA CLI to inspect, set, and clear EIP-7702 delegations.
homepage
repositoryhttps://github.com/maikelordaz/eip7702reset
max_upload_size
id1877718
size149,180
Maikel Ordaz (maikelordaz)

documentation

README

eip7702reset

A tiny, batteries-included CLI to inspect, set, and clear EIP-7702 delegations for an EOA.
It uses the latest Alloy stack under the hood and hides private-key input by default.


What it does

  • check <address> — Reads bytecode at an EOA and classifies it as:
    • safe (no code),
    • EIP-7702 (prints the delegated template contract address), or
    • other code.
  • set <delegated_contract> — Creates and broadcasts an EIP-7702 Authorization so a user EOA can execute code from a template contract. Uses a relayer account to pay gas.
  • clear — Creates and broadcasts an EIP-7702 De-authorization (authorization list with the zero address) to revert an EOA back to a normal account. Also uses a relayer to pay gas.

[!NOTE] Keys are requested interactively and typed/pasted without echo in the terminal.


Why

EIP-7702 allows an EOA to temporarily delegate execution to a delegation contract (e.g., a smart account), without permanently converting the EOA. This CLI is a minimal, auditable tool to:

  • check if an EOA is currently delegated,
  • set a delegation (opt-in),
  • and clear it (opt-out).

It’s useful for migrations, recoveries, support flows, and ops where you need a simple, scriptable UX.


How it works (at a glance)

  • check
    • Calls eth_getCode on the EOA.
    • Detects the EF 01 00 EIP-7702 bytecode prefix and, if present, extracts/prints the 20-byte template address.
  • set
    • Prompts for User private key (the EOA to be authorized) and Relayer private key (pays gas).
    • Builds an Authorization with the template contract as target and signs it with the User key.
    • Wraps it in an EIP-1559 transaction signed by the Relayer, broadcasts, and waits for receipt.
  • clear
    • Same flow, but the authorization uses the zero address as target to remove delegation.

[!NOTE] We rely on Alloy Providers/Signers. Gas fields can be set explicitly or left to Alloy’s fillers if you enable them in the code.


Security model (read me)

  • The tool never echoes private keys when prompting (uses rpassword).
  • Keys are parsed immediately; temporary buffers are zeroized to reduce plaintext lifetime in memory.
  • For production use, dedicated relayer accounts are recommended.
  • Prefer running in terminals with predictable echo behavior (e.g., Windows Terminal, PowerShell, macOS Terminal).

Supported chains

Any EVM chain that supports EIP-7702.
The flow has been tested on Arbitrum Sepolia. You’ll need an RPC endpoint that accepts raw transactions.


Install

From crates.io (latest release)

cargo install eip7702reset

Using Cargo (local source)

# In the repo root
cargo install --path .

This builds a release binary and installs it into Cargo’s bin dir

From source without installing

cargo build --release
# binary at: target/release/eip7702reset

Build locally

Requirements:

Rust (stable) with MSVC toolchain on Windows (installed via rustup)

A recent git

(Optional) make if you want to use the convenience Makefile targets

With Cargo

# Format + lints + tests + build
cargo fmt
cargo clippy -- -D warnings
cargo test
cargo build --release

With Make (if you’re using the provided Makefile)

# Common workflows:
make fmt
make lint
make test
make build

Usage

Get help:

eip7702reset --help
eip7702reset check --help
eip7702reset set --help
eip7702reset clear --help

Example flow

# Vars
# Arbitrum Sepolia RPC endpoint
RPC="https://sepolia-rollup.arbitrum.io/rpc"
# EOA to inspect/delegate/clear
VICTIM="<your_eoa_address>"
# Metamask EIP7702 delegator contract
TEMPLATE="0x63c0c19a282a1B52b07dD5a65b58948A07DAE32B"

# 1) Check (expect "safe" if not delegated)
eip7702reset check "$VICTIM" --rpc-url "$RPC"

# 2) Set delegation (prompts for USER key and RELAYER key; no echo)
eip7702reset set "$TEMPLATE" --rpc-url "$RPC" --gas-limit 50000

# 3) Check again (expect EIP-7702 + template address)
eip7702reset check "$VICTIM" --rpc-url "$RPC"

# 4) Clear (prompts for VICTIM key and RELAYER key; no echo)
eip7702reset clear --rpc-url "$RPC" --gas-limit 50000

# 5) Final check (expect safe)
eip7702reset check "$VICTIM" --rpc-url "$RPC"

Notes:

Relayer must have a small balance on the target chain to pay gas.

If your endpoint auto-fills fees/nonces, you may remove explicit gas settings in the code (disable disable_recommended_fillers()).

Testing

We include:

Unit tests for bytecode classification.

Integration tests that spin a tiny mock JSON-RPC server for check, set, and clear.

Run all tests:

cargo test

Configuration & flags

  • --rpc-url <URL> — RPC endpoint (HTTP).

  • --gas-limit <u64> — Gas limit for the outer EIP-1559 tx (default: 100000 via global CLI flag in cli.rs).

  • --debug — Prints extra diagnostic output.

  • RUST_LOG — Use with tracing_subscriber (e.g., RUST_LOG=info).

Caveats

Some public endpoints may reject raw transactions or have strict rate limits. If you hit eth_sendRawTransaction failed, try another RPC or a project key from a provider.

Acknowledgements

Built with ❤️ using:

  • Alloy for providers/signers/EIP-7702 types
  • clap, tokio, tracing
  • rpassword, zeroize for safer key handling
Commit count: 0

cargo fmt