EIP 7702 - Set EOA account code for one transaction

EIP-7702: Expanding Ethereum Account Functionality

Vitalik Buterin's EIP-7702 introduces a novel transaction type that significantly enhances the capabilities of Externally Owned Accounts (EOAs) within the Ethereum ecosystem. EIP-7702 achieves this by introducing a temporary code execution environment for EOAs. During a transaction, the EOA's code is overridden with a specified contract_code, effectively transforming it into a smart contract for the duration of the transaction. Upon successful transaction execution, the EOA's code reverts back to its original empty state. This approach aims to deliver similar benefits to EIP-3074 (account abstraction) but with a design that is more compatible with future Ethereum upgrades.

Technical Breakdown of EIP-7702 Transactions:

The new transaction type introduced by EIP-7702 incorporates two key fields:

contract_code: This field carries the bytecode of the smart contract that will be temporarily executed by the EOA. The EOA essentially acts as a vessel for executing this external code. Signature: As with standard Ethereum transactions, a valid signature is required to authorize the execution of the EIP-7702 transaction. This signature originates from the private key associated with the EOA. The execution flow of an EIP-7702 transaction can be broken down into three distinct phases:

Execution Initialization: The transaction sets the EOA's code to the provided contract_code. This essentially replaces the EOA's native functionality with the functionality defined within the contract_code. Temporary Smart Contract Execution: The transaction proceeds to execute the logic defined within the contract_code. This allows the EOA to leverage smart contract capabilities for the specific transaction. Reset to Original State: Following successful execution, the EOA's code reverts back to its original empty state. This ensures that the EOA remains an EOA after the transaction completes.

Cost Considerations and Use Cases

While EIP-7702 offers increased flexibility, it's important to consider the associated gas costs. For simple transactions like token transfers, the base cost of an EIP-7702 transaction is likely to be higher compared to a standard EOA transaction due to the additional overhead involved in setting and resetting the EOA's code. However, EIP-7702 shines in complex scenarios:

Batching Transactions: EIP-7702 allows for multiple operations to be batched within a single transaction by including the relevant code for each operation within the contract_code field. This can significantly improve gas efficiency compared to executing each operation as a separate transaction. Sponsored Transactions: EIP-7702 enables the separation of the transaction fee payer from the EOA initiating the transaction. This allows a separate account (payer) to cover the gas costs associated with the EOA's transaction, offering flexibility for specific use cases. Security Implications and Trust Assumptions:

The introduction of temporary code execution within EOAs through EIP-7702 necessitates careful consideration of security:

EOA Owner Responsibility: The onus of security remains primarily with the EOA owner. Users must thoroughly audit and understand any contract_code they interact with, as malicious code can exploit vulnerabilities during execution and potentially steal funds or perform unauthorized actions. Wallet Reliance: Due to the complexity of smart contract bytecode, most users will likely rely on their wallets and transaction interfaces to manage the contract_code securely. These wallets and interfaces become crucial in ensuring the accuracy and security of the code being executed. Revocation Mechanisms and Developer Flexibility:

The approach to revoking permissions granted through EIP-7702 differs from the mechanism employed by EIP-3074:

EIP-7702: Revoking permissions associated with EIP-7702 transactions is less straightforward. Potential solutions involve signing over account nonce or implementing expiration mechanisms within the temporary contract_code itself. EIP-3074: EIP-3074 offers a simpler revocation approach that leverages nonces. Users can simply increase their account nonce to revoke permission delegations granted earlier. EIP-7702 prioritizes flexibility for developers by allowing the authorized code within the contract_code to manage its own access control rather than relying on a protocol-level enforcement mechanism. This enables the implementation of custom logic, checks, and restrictions beyond simple transfers. While this approach offers greater developer flexibility, it also contributes to the higher base cost associated with EIP-7702 transactions compared to standard EOA transactions.

Was this page helpful?