EIP-2938 Account abstraction (PAYGAS approach) (Account Abstraction)
No call decision · Account abstraction · EIP status Withdrawn · created 2020-09-04
EIP-2938 proposes adding a new opcode called PAYGAS, allowing a smart contract to become the top-level entity of a transaction, pay fees directly, and freely define its own signature verification scheme.
Why it is needed
Today, Ethereum determines transaction validity using only a fixed set of rules: ECDSA signature, nonce, and balance. Because of this, wallets using alternative verification schemes such as multisig or social recovery, features that pay fees in tokens other than ETH, and privacy services like tornado.cash all have to go through an intermediary (relayer) such as the Gas Station Network. These intermediaries demand an extra 21000 gas plus a fee, which is inefficient, and carry the risk that the feature itself stops working if the intermediary service disappears. EIP-2938 aims to remove this dependence on intermediaries by letting a contract define its own fee-payment conditions directly in EVM code.
What changes
Today
- A transaction's validity is verified using only a single ECDSA signature.
- Using other signature schemes (Schnorr, BLS, etc.), multisig, or social recovery requires going through an intermediary.
- Paying fees in tokens other than ETH requires an intermediary service.
After EIP-2938
- A contract calls the PAYGAS opcode to set the gas price and limit directly and pay the fee itself.
- Signature verification logic can be written freely in EVM code, enabling multisig, social recovery, and non-ECDSA signatures.
- Single-tenant wallets are supported first, with multi-tenant applications like tornado.cash and Uniswap extended to in a later stage.
Who is affected
- Wallet developers: Signature schemes other than ECDSA, as well as multisig and social recovery, can be implemented at the protocol level.
- Users: Smart contract wallets that set their own fee conditions can be used without a transaction intermediary.
- Miners and nodes: Before including a transaction in a block or rebroadcasting it, part of the validation code must be executed to pre-check its validity.
- Privacy and DeFi app developers: Services like tornado.cash and Uniswap can build structures that collect fees without an intermediary (at the multi-tenant stage).
In depth
New transaction type and nonce
This introduces a new transaction type based on EIP-2718, AA_TX_TYPE (value 2). Its payload consists of rlp([nonce, target, data]), and since there is no signature, the base gas cost is lowered from 21000 to AA_BASE_GAS_COST (15000). The nonce is handled the same way as before, by checking tx.nonce == tx.target.nonce, and if valid, it is immediately incremented via tx.nonce += 1. This transaction type has no intrinsic gas limit; at the start of execution the gas limit is set to the entire amount of gas remaining in the block, and the PAYGAS opcode subsequently lowers it.
PAYGAS opcode
PAYGAS(0x49) operates with gas cost G_base and takes two values from the stack: version_number and memory_start. When version_number==0, it reads the 32 bytes at memory_start as gas_price, and the next 32 bytes as gas_limit. It only executes if the contract balance is at least gas_price*gas_limit, globals.transaction_fee_paid is False, and this is the top-level AA execution frame, in which case it deducts the fee from the balance upfront and sets globals.transaction_fee_paid to True. PAYGAS also acts as a checkpoint: if the top-level frame reverts after the call, execution only rolls back to the point immediately after PAYGAS, and the fee has already been paid to the miner.
globals variables and the NONCE, GASPRICE opcodes
New transaction-wide global variables globals.transaction_fee_paid, globals.gas_price, and globals.gas_limit are introduced, starting as False, 0, and 0 respectively in AA transactions. The new opcode NONCE(0x48) pushes the callee's nonce onto the stack, letting verification code check the nonce together with the signature. CALLER and ORIGIN are changed to return AA_ENTRY_POINT (0xffff...ff) during AA transaction execution, and GASPRICE(0x3A) returns globals.gas_price, leaving behavior unchanged for normal transactions.
Replay protection
An AA contract's nonce must not be reused after SELFDESTRUCT, in order to prevent replay attacks. This requires implementing one of two approaches as a consensus change. One is to force the AA transaction's target contract to start with EIP-2937's SET_INDESTRUCTIBLE opcode; the other is to preserve the contract's nonce rather than resetting it to 0 when SELFDESTRUCT is called. This change must be handled at the protocol consensus-rule level rather than at the contract code level (e.g. via AA_PREFIX), in order to preserve the uniqueness of transaction hashes.
Verification-step constraints for single-tenant AA
To let miners and nodes filter out transactions that look falsely valid during the pre-PAYGAS verification step, verification code may only call contracts starting with AA_PREFIX, and using environment opcodes (BLOCKHASH, COINBASE, etc.), BALANCE, or external calls/code reads to addresses other than target immediately fails validation. Validation also fails if gas consumption exceeds VERIFICATION_GAS_CAP (90000, six times AA_BASE_GAS_COST) or exceeds the block's remaining gas. This mechanism is designed to prevent denial-of-service (DoS) attacks in which an external transaction unrelated to the target account simultaneously invalidates thousands of mempool transactions aimed at that target.
Extending to multi-tenant AA
Supporting cases like tornado.cash, where a single contract handles both deposits (from many users) and withdrawals (AA transactions) at once, or Uniswap, where arbitrageurs check price conditions during the verification step before trading, requires going beyond the single-tenant approach that allows only one pending transaction per account. The original text sketches an approach requiring EIP-2930-style binding access lists, so that transactions touching different storage slots can remain in the mempool simultaneously. However, it notes that this stage requires further research, since miners would need to be able to reorder the nonces of incoming transactions, making transaction hashes unpredictable at issuance time, and it leaves the concrete design as future work.
Current status
This proposal's status is Withdrawn, with the withdrawal-reason specified as "Very out of date; needs rewrite." In other words, the design in this document is no longer being pursued. No fork-inclusion decision was found in the call records.