EIP-2831 Transaction replacement notification message (Transaction Replacement Message Type)

No call decision · Other · EIP status Stagnant · created 2020-07-26

A proposal that extends EIP-1193 so that when a wallet cancels or speeds up a transaction, the provider notifies the dapp of this via an event.

Why it is needed

Wallets offer a transaction replacement feature that lets users cancel a sent transaction or resend it with a higher gas price so it processes faster. However, the current communication method between provider and dapp has no way to convey this replacement. The dapp has no way of knowing why the original transaction disappeared, so it must guess the outcome by querying blocks one by one, and it is also difficult to link the replaced transaction to the new one. This is a significant usability problem for dapp developers who need to track transactions.

What changes

Today

After EIP-2831

Who is affected

In depth

Definitions: provider, wallet, transaction replacement

The original text defines a provider as a JavaScript object that gives access to the Client, and a wallet as an application that manages private keys and performs signing, acting as middleware between the provider and the Client. Transaction replacement is defined as sending a transaction with the same nonce and a gasPrice at least 10% higher than the original before the original transaction is included in a block.

tx_speedup event

tx_speedup is a replacement where the user only adjusts gasPrice for faster inclusion. To be valid, the replacement transaction must have the same nonce, to, value, and data as the original transaction. The event carries oldTx, newTx, nonce, and from as a txSpeedupInfo type.

tx_cancel event

tx_cancel is a replacement where the user wants to invalidate a pending transaction. To be valid, the replacement transaction must have the same nonce, the same from and to, value of 0, and no data. The event carries oldTx, newTx, nonce, and from as a txCancelInfo type.

tx_replacement event

tx_replacement is when the user replaces a previous transaction with an entirely new transaction. The only required condition is the same nonce; to, value, and data can all differ. The event carries oldTx, newTx, nonce, and from as a txReplacementInfo type.

Implementation approach: EventEmitter

All three events MUST be implemented using the Node.js EventEmitter API. The dapp registers a listener in a form such as Provider.on('tx_speedup', ...) and receives the information via callback.

Rationale and backward compatibility

The original text extends the already widely used ProviderMessage approach so that a dapp can implement this by adding just one conditional to its existing message listener. Thanks to this approach, even when a provider has not yet implemented these events, the dapp does not panic with an undefined error, unlike calling a native method such as ethereum.txCancel(). Because it directly extends the event logic of EIP-1193, backward compatibility with existing providers is not broken either.

Current status

This EIP requires EIP-1193 and its current status is Stagnant. The original text links GitHub issues in the Web3.js and MetaMask repositories as implementation examples, but these are only issues under discussion, not confirmed adopted implementations.

Original EIP · ← EIPs