EIP-7701 Native account abstraction

No call decision · Account abstraction · EIP status Withdrawn · created 2024-05-01

A protocol level account abstraction proposal that splits Ethereum transactions into deployment, validation, execution, and post-processing phases, and uses a new transaction type and opcodes to let smart contract accounts verify signatures directly and let other accounts pay gas on their behalf.

Why it is needed

Today, EOAs that sign directly with a private key are locked into ECDSA as their only signature verification method, so they cannot use custom verification logic such as social recovery or multisig. For a smart contract wallet to use such features, it must mimic them outside the protocol, as ERC-4337 does with a separate EntryPoint contract, bundler, and mempool, which introduces extra trust assumptions and gas estimation complexity. EIP-7701 embeds verification logic and gas payment logic directly into transaction processing itself, so the protocol can natively support per-account custom verification, wallet deployment via a deployer, and gas sponsorship via a paymaster, without a separate EntryPoint contract.

What changes

Today

After EIP-7701

Who is affected

In depth

Splitting the transaction into multiple stages

EIP-7701 splits transaction processing into multiple stages: deployment, validation, execution, and post-operation. Whether a transaction can be included in a block (its validity) is determined solely by the results of the validation stages, separately from the success or failure of the execution stage. It also separates validation for authentication from validation for gas payment, supporting at the protocol level a structure where one contract (the sender) executes the transaction while another contract (the paymaster) pays the gas on its behalf.

The new transaction type AA_TX_TYPE and its fields

AA_TX_TYPE (value TBD) is introduced as an EIP-2718 transaction type, referred to as an 'AA transaction'. Its RLP payload consists of chain_id, nonce, sender/sender_validation_data, deployer/deployer_data, paymaster/paymaster_data, sender_execution_data, max_priority_fee_per_gas/max_fee_per_gas, sender_validation_gas/paymaster_validation_gas/sender_execution_gas/paymaster_post_op_gas, access_list, and authorization_list. The addresses of the three roles, sender, deployer, and paymaster, along with the data passed to each and their per-role gas limits, are explicitly included in the transaction.

CURRENT_ROLE / ACCEPT_ROLE opcode

A context variable called current_context_role is set to the current role (ROLE_SENDER_DEPLOYMENT=0xA0, ROLE_SENDER_VALIDATION=0xA1, ROLE_PAYMASTER_VALIDATION=0xA2, ROLE_SENDER_EXECUTION=0xA3, ROLE_PAYMASTER_POST_OP=0xA4) for each top-level call of an AA transaction. In a normal transaction it is always ROLE_SENDER_EXECUTION. The value is preserved across DELEGATECALL, and is reset to ROLE_SENDER_EXECUTION on CALL/STATICCALL/CALLCODE, behaving similarly to msg.sender. The CURRENT_ROLE opcode returns this value. ACCEPT_ROLE terminates by copying memory and returning it as return data, like RETURN, but additionally takes a frame_role input and reverts if it differs from current_context_role. Each role in the lifecycle must have a matching successful ACCEPT_ROLE call, and if even one is missing, the transaction fails validation and cannot be included in a block.

The TXPARAM* opcode family

TXPARAMDLOAD, TXPARAMSIZE, and TXPARAMCOPY follow the same pattern as the CALLDATA*/RETURNDATA* opcodes such as CALLDATALOAD, CALLDATASIZE, and CALLDATACOPY, but additionally take a stack input n specifying which transaction field to read. n=0x01 returns nonce, 0x02 returns sender, 0x03 returns sender_validation_data, 0x04-0x07 return the deployer/paymaster addresses and data, 0x0B-0x10 return gas-related values, 0x11/0x12 return the hashes of access_list/authorization_list, 0xf1/0xf2 return execution_status and execution_gas_used, and 0xff returns the pre-signature transaction hash (tx_hash_for_signature). This lets a contract access the transaction's full set of fields even without calldata.

Changes in the meaning of CALLER/ORIGIN/CALLDATA

In every top-level frame of an AA transaction, CALLER (msg.sender) is fixed to the AA_ENTRY_POINT address (address(0x7701)), and ORIGIN (tx.origin) is fixed to the transaction's sender address. CALLDATA* (msg.data) is populated with sender_execution_data only in the sender execution frame, and is empty in all other call frames (deployment, validation, post-operation).

Gas cost structure

The sender address is included in AA_BASE_GAS_COST (15000) and is pre-warmed. If a nonzero address different from the sender is specified as the paymaster or deployer, the EIP-2930 ACCESS_LIST_ADDRESS_COST of 2400 gas is additionally charged and the address is added to accessed_addresses. The transaction's overall maximum gas (max_gas) is the sum of sender_validation_gas, paymaster_validation_gas, sender_execution_gas, and paymaster_post_op_gas, and gas_price is the lesser of max_fee_per_gas and base_fee_per_gas+max_priority_fee_per_gas. This maximum cost is deducted upfront, at the start of processing, from the paymaster's balance if one exists, or otherwise the sender's balance, and any unused gas is refunded once processing completes.

Processing flow and revert conditions

If the sender has no code, the deployer is first called with ROLE_SENDER_DEPLOYMENT to deploy it. The sender is then called with ROLE_SENDER_VALIDATION, and the paymaster, if present, with ROLE_PAYMASTER_VALIDATION, for validation. Only if all these validation stages succeed at ACCEPT_ROLE does processing move to the execution stage. Before execution, a state snapshot is taken, the sender is called with ROLE_SENDER_EXECUTION to execute the actual logic, and execution_status and execution_gas_used are then recorded in transaction-scoped variables. If a paymaster is present, it is called for post-processing with ROLE_PAYMASTER_POST_OP; if this fails at ACCEPT_ROLE, only the state changes from the execution stage are reverted to the snapshot point (gas consumption and validation results are not reverted).

Security considerations and withdrawal status

Because the ACCEPT_ROLE opcode is a general-purpose means of approving arbitrary actions on behalf of a contract, correct and secure implementation of this code is critical. Compilers targeting the EVM are expected to play a key role in ensuring the security of smart contract accounts. Auditors and security tools must verify that contracts not intended to perform a role in an AA transaction do not contain an unexpected ACCEPT_ROLE opcode, since otherwise this could pose an immediate security threat. Block explorers should tag contracts whose source code uses the ACCEPT_ROLE opcode as a 'user account' or 'paymaster'. This proposal has now been superseded by EIP-8141 and is in Withdrawn status.

Original EIP · ← EIPs