melonask/eip-7702-skills
Overview
This skill is an expert guide for implementing EIP-7702 to enable gasless and delegated transaction patterns. It focuses on building the delegate contract, securing delegated execution, and integrating with Viem v2 for signing and sending authorizations. The guide includes batching, sponsorship flows, and testing patterns for reliable production deployments.
How this skill works
The skill explains how an EOA temporarily delegates its code to a smart contract which executes actions on the EOA's behalf. It covers contract-side authentication (inner signatures and nonces) and replay protection so relayers can safely pay gas for sponsored transactions. Client-side patterns with Viem v2 are included for signing authorizations and attaching them to transactions.
When to use it
- Enable sponsored (gasless) token transfers where a relayer pays gas for EOAs.
- Implement batching: combine multiple calls into a single atomic transaction.
- Build delegated smart accounts that can rotate keys or recover access programmatically.
- Integrate a relayer service that must validate nonces and inner signatures before submitting.
- Test EIP-7702 flows locally and in CI with Foundry supporting Prague EVM features.
Best practices
- Enforce an inner EOA signature that signs the intent payload and a nonce to prevent replay.
- Design clear execute() variants: one for sponsored calls with signature checks and one for internal calls.
- Use strong typed ABIs and writeContract in Viem v2 to avoid encoding mistakes.
- Keep nonce management chain-visible and include chainId or domain separation in the signed hash.
- Test extensively with Foundry cheatcodes signDelegation/attachDelegation and include edge cases.
Example use cases
- A dApp pays gas for first-time users to onboard with a gasless transfer of tokens.
- A multiservice operation that needs to perform token transfer, approval, and state update atomically via batching.
- A wallet that allows emergency key rotation by delegating execution to a recovery contract.
- A relayer gateway that validates inner signatures and nonces then sponsors transactions for users.
- Integration examples using Viem v2: signAuthorization then writeContract with an authorizationList.
FAQ
No. The EIP only delegates code execution. The implementation contract must validate intent via an inner signature and nonce to ensure the EOA authorized the specific payload.
Which tools support testing EIP-7702 flows?
Foundry supports EIP-7702 via the Prague EVM version and provides cheatcodes like signDelegation and attachDelegation for end-to-end tests.