EIP-5081 · Stagnant · Core · 2022-05-06
EIP-5081: Expirable Transaction
Proposed a new transaction type with an expire_by block number, after which the transaction can never be included, giving users a clean way to let stale transactions die.
What problem does it solve?
An Ethereum transaction stays valid until its nonce is used. If you send a transaction with a low fee during congestion and then accomplish the same goal another way (a different nonce or another account), the old transaction can still be mined days later when fees drop. The only way to kill it is to send a replacement with the same nonce and a higher fee, which is unreliable and can be expensive if the original fee was already high.
Some transactions are also only useful for a short window, such as a swap that will almost certainly revert if it is not mined within minutes. Users would rather it fail cheaply by never being included at all.
EIP-5081 lets a transaction carry its own deadline.
How it works
-
A new EIP-2718 typed transaction (type byte still TBD, above
0x02). -
Its payload is the EIP-1559 layout plus one field,
expire_by, placed right afterchain_id:rlp([chain_id, expire_by, nonce, max_priority_fee_per_gas, max_fee_per_gas, gas_limit, destination, amount, data, access_list, signature_y_parity, signature_r, signature_s]) -
expire_byis the last block number that may include the transaction. Any block withnumber > expire_bymust not execute it. -
All other fields, intrinsic gas (inherited from EIP-2930 access-list pricing) and the receipt format work the same as for EIP-1559 transactions.
-
Clients that know the current block number must drop and stop gossiping expired transactions. The spec also suggests an optional
gossip_ttlmargin so nodes only relay transactions that still have a few blocks left.
Sample code
Validity check a client or block builder would apply (pseudocode):
def can_include(tx, block_number: int) -> bool:
if tx.type != EXPIRABLE_TX_TYPE: # value TBD in the spec
return True
return block_number <= tx.expire_by
def should_gossip(tx, current_block: int, gossip_ttl: int = 0) -> bool:
return current_block + gossip_ttl <= tx.expire_by
Payload fields in order (illustrative values):
{
"chain_id": 1,
"expire_by": 20000100,
"nonce": 7,
"max_priority_fee_per_gas": "1000000000",
"max_fee_per_gas": "30000000000",
"gas_limit": 21000,
"destination": "0x000000000000000000000000000000000000dEaD",
"amount": "0",
"data": "0x",
"access_list": []
}
Things to know
- Status: Stagnant. No transaction type number or fork was assigned, and the Rationale and Backwards Compatibility sections were left as TODO. Today, apps achieve similar effects at the contract level (for example a
deadlineparameter that makes a swap revert), which still costs gas when the transaction is mined. - The spec's signing preimage is written as
keccak256(0x02 || rlp([...])); with the type byte still undecided, treat that detail as unfinished. - Expiry is by block number, not timestamp.
- Replay protection relies on
chain_idas in EIP-155 and later typed transactions.