ERC-3005 Batched meta transaction standard (Batched meta transactions)

Stagnant · Tokens · created 2020-09-25

An ERC-20 extension function that lets token holders without ether (gas) send tokens with just a signature, while allowing a relayer to bundle multiple people's meta transactions into a single on chain transaction.

Why it is needed

Meta transactions are a gasless transfer scheme that let holders send tokens with just a signature even without ether, but existing relayer implementations could only process one meta transaction at a time, or could only bundle transactions from the same sender. Without the ability to bundle multiple people's meta transactions into one on chain transaction, a relayer must submit a separate transaction for each person, which increases the gas cost burden and makes it harder to sustain a gasless service. Without this standard, the economics of running a relayer business worsen, and users who hold only tokens and no ether also lose the opportunity to send tokens gaslessly.

What to implement

In depth

Meta transaction data and hash

The hash to be signed is constructed as keccak256(sender ++ recipient ++ amount ++ relayerFee ++ nonce ++ expirationDate ++ tokenContract ++ relayer). This hash is signed with the sender's private key. Including the token address and relayer address in the hash binds the meta transaction so it is valid only for that specific token contract and that specific relayer.

processMetaBatch function interface

It takes eight arrays in total: senders, recipients, amounts, relayerFees, blocks (expiration blocks), and sigV, sigR, sigS (the three signature parts). The same index across all arrays must refer to a single meta transaction's data; if the order is mismatched, signature verification will reject it. The nonce, token address, and relayer address are not sent as parameters but are derived from contract state, address(this), and msg.sender.

Validation rules

The new nonce must be exactly one greater than the sender's previous nonce. Neither the sender nor the recipient may be the 0x0 address. A meta transaction must be processed before its specified expiration block. The sender's balance must be at least the sum of the amount and the relayer fee. If any single meta transaction in the batch fails to satisfy these conditions, only that entry is skipped rather than reverting the entire transaction.

Nonce management

The contract tracks each account's nonce per token contract using the _metaNonces mapping, which can be queried via nonceOf(). The nonce is computed as the previous nonce plus one rather than taken as a function parameter, because the value is always derivable this way and to avoid a stack too deep error.

Token transfer and relayer fee

Once validation passes, the sender's nonce is incremented by one, the specified amount is sent to the recipient, and the relayer fee is sent to the relayer (msg.sender). In the reference implementation, fees are not paid out on every loop iteration but are summed and paid once at the end of the function, reducing repeated SSTORE costs.

Failure handling approach

Even if the batch contains invalid meta transactions due to signature mismatch, insufficient balance, or an expired block, the entire on chain transaction is not reverted; only that entry is skipped (continue). Relayers do not receive a fee for invalid meta transactions, so relayers are expected to validate them in advance before relaying.

A proposal still stalled

This EIP is in Stagnant status. Open questions such as whether EIP-2612's permit() nonce mapping could be reused, and whether an upper bound should be placed on the expiration block, remain unresolved in the original text and may change or see no further progress.

Things to watch out for

Original ERC · ← ERCs