ERC-1077 Relayed gas payment using tokens (Gas relay for contract calls)

Stagnant · Accounts & wallets · created 2018-05-04

A contract call standard in which a user only needs to sign a message, without holding ETH, while a third party relayer executes the transaction on their behalf and is reimbursed for gas in tokens or ETH.

Why it is needed

Executing a transaction on Ethereum always requires ETH. But many apps use their own tokens, and users often don't want to separately acquire or hold ETH. Without ETH, users can't even send a transaction no matter how many tokens they have, creating a major barrier to onboarding new users. Users find it tedious to sign a new transaction every time and manage private keys or recovery phrases themselves, and they are also reluctant to install extra programs to use an app or wallet. Meanwhile, app and wallet developers lack a clear revenue model for relaying large numbers of transactions on users' behalf, so a standardized way to design gas-sponsoring services is needed.

What to implement

In depth

Structure of the message to be signed

The signed message consists of six fields: nonce (or timestamp), Execute Data which is the bytecode to run, Gas Price denominated in the token, Gas Limit allocated for the relayed execution, Gas Token to pay gas in (0 means ether), and Gas Relayer who receives the gas reimbursement (0 means block.coinbase).

How the EIP-191 hash is generated

The message is computed as keccak256(abi.encodePacked(byte(0x19), byte(0x0), address(this), chainID, bytes4(keccak256("executeGasRelay(uint256,bytes,uint256,uint256,address,address)")), _nonce, _execData, _gasPrice, _gasLimit, _gasToken, _gasRelayer)). The 0x19 and version byte follow the EIP-191 spec, the validator address is the account contract itself, and chainID follows EIP-1344. The signature must be made by the account owner, and if the owner is a contract, it must implement EIP-1271 to delegate verification.

Handling multiple signatures

Multiple signatures over the same parameters can be included in the messageSignatures field and executed at once. This field is split into individual 72-byte signatures, each of which is verified separately. For actions requiring approval from multiple parties, the signatures must be ordered according to account order, and the account contract must either iterate (JUMP) EIP-1271 verification locally or delegate it (STATIC_CALL) to the owner contract.

Nonce management and replay prevention

executeGasRelay does not take _nonce as a parameter. The contract tracks the current nonce itself, only allows execution in order, and updates lastNonce after execution to prevent reordering or re-execution. Transactions with nonce set to 0 can also be allowed, in which case the contract must store the full transaction hash to prevent replay. This can be used for transactions that may execute out of order or not at all, such as transactions scheduled for the future or only executed upon a state channel dispute, but it costs more in memory.

Handling execution data (_execData)

After signature verification, interpreting and executing _execData is left to the account contract implementation. A common approach is to call the contract itself, like address(this).call.gas(_gasLimit)(_execData), to execute the contract's own methods such as call, create, create2, approveAndCall, delegatecall, or changeOwner. This ERC does not address standardizing the account contract itself, and the methods above are presented only as implementation examples.

Gas calculation and reimbursement rules

The contract must track the gas used, for example via the difference in gasLeft() before and after execution, and pay gasSpent * gasPrice in _gasToken (ether if zero) to _gasRelayer. If _gasRelayer is zero, payment must go to block.coinbase. If funds are insufficient or the total exceeds _gasLimit, the transaction must revert, and even if the internal execution fails, the nonce must still be updated and the gas must still be paid. The contract may choose not to support refunding unwanted tokens or ether.

A proposal still stalled

This ERC has Stagnant status, meaning it is no longer actively discussed or advanced. Test Cases are also left as TBD, so it was never finalized as a standard.

Things to watch out for

Original ERC · ← ERCs