What is EIP-7702?

GitHubarrow-up-right

EIP-7702 introduces a new EIP-2718arrow-up-right transaction type that enables Externally Owned Accounts (EOAs) to temporarily set executable code on their accounts. This is achieved by attaching a list of authorization tuples—each formatted as [chain_id, address, nonce, y_parity, r, s]—to a transaction. For each tuple, a delegation marker (0xef0100 || address) is written to the account’s code. During execution, all code execution operations are delegated to the code located at the specified address.

While smart contract wallets offer advanced features, EOAs still dominate user interactions but lack similar flexibility. EIP-7702 aims to enhance EOAs with limited smart-contract-like capabilities, facilitating broader UX improvements across the Ethereum ecosystem. The proposal targets three primary use cases:

  1. Batching: Enables atomic execution of multiple actions within a single transaction (e.g., ERC-20 approval and subsequent usage), reducing friction in multi-step workflows.

  2. Sponsorship: Allows one account (e.g., a relayer or dApp operator) to pay gas fees on behalf of another, enabling use cases like meta-transactions or subsidized user onboarding.

  3. Privilege De-escalation: Supports creating signed sub-keys with limited permissions, such as spending caps, token-specific allowances, or app-specific access, enhancing security and usability.

Specification

Parameters

Parameter
Value

SET_CODE_TX_TYPE

0x04

MAGIC

0x05

PER_AUTH_BASE_COST

12500

PER_EMPTY_ACCOUNT_COST

25000

  • SET_CODE_TX_TYPE = 0x04 This value defines the unique transaction type identifier for the new "set code transaction" introduced in EIP-7702. It allows this transaction to be distinguished from other EIP-2718 typed transactions.

  • MAGIC = 0x05 This constant byte is used as a prefix in the message that is signed in each authorization tuple. It serves as a unique identifier to distinguish the signature message format and to ensure secure and deterministic verification.

  • PER_AUTH_BASE_COST = 12,500 This is the base gas cost charged for processing each authorization tuple in the authorization_list. The cost is applied regardless of whether the tuple is valid or invalid.

  • PER_EMPTY_ACCOUNT_COST = 25,000 If the account being authorized (the signer) is an empty account (i.e., with no code and zero nonce), this additional gas cost is charged to reflect the cost of initializing the account. This aligns with existing Ethereum behavior for activating empty accounts.

Set code transaction

EIP-7702 introduces a new type of EIP-2718 transaction called the "Set Code Transaction." This transaction is identified by the SET_CODE_TX_TYPE and contains the following fields serialized using RLP:

  • The authorization_list is a list of tuples formatted as [chain_id, address, nonce, y_parity, r, s]. Each tuple specifies what code the signer wants to execute in the context of their Externally Owned Account (EOA).

  • The transaction is invalid if the authorization_list is empty (i.e., has zero length).

  • The other fields of the transaction (chain_id, nonce, max_priority_fee_per_gas, etc.) follow the same semantics as defined in EIP-4844, which means the destination field cannot be null and must contain a valid address.

  • The signature fields (signature_y_parity, signature_r, and signature_s) represent a secp256k1 signature over the hash of SET_CODE_TX_TYPE || TransactionPayload computed with Keccak-256.

Last updated