EIP-7768 · Stagnant · Meta · 2024-09-14
EIP-7768: No-Ether transactions with free-for-all tips
A no-protocol-change scheme where an account with zero ETH still sends its own transactions: the block builder fronts the gas and is paid in tokens left at a shared 'free-for-all' contract.
What problem does it solve?
A new user who receives tokens but no ETH cannot do anything with them: every transaction needs ETH for gas. Existing fixes either need protocol changes, or have a different account submit the transaction (relayers, ERC-4337 bundlers), which changes tx.origin. Some actions, such as an ERC-721 setApprovalForAll from an EOA, care about who the real originator is.
EIP-7768 (a Meta EIP) describes a technique that works with today's clients and keeps tx.origin as the user: the block builder gives the user just enough ETH inside the same block, and collects payment in tokens.
How it works
User side
- Alice, with no ETH, signs one or more ordinary transactions with consecutive nonces.
- To pay, one of them (normally the last) sends tokens, such as ERC-20, ERC-721 or ERC-1155, to a well-known free-for-all contract.
- She must assume any prefix of her transactions might be executed: none, the first, the first two, and so on.
- She sends the bundle to a service that talks to block builders. Normal mempools will not relay these transactions, because her account has no ETH to pay gas.
Builder side
- In a scratch execution context, insert a transaction sending Alice ETH to cover gas, then Alice's transactions.
- See what consideration landed in the free-for-all contract, and add a transaction that claims it.
- Measure the gas actually used, roll back, and replay with the exact ETH amount, aborting if the payment differs.
- If the payment is worth more than the ETH fronted, keep the result in the block; otherwise discard it, and possibly lower the sender's reputation.
The free-for-all contract has no owner. Whoever builds the block can sweep what is in it, so payment reaches the builder without Alice needing to know who that will be.
Sample code
Illustrative shape of the shared contract (the spec's interface is still rough):
// SPDX-License-Identifier: CC0-1.0
pragma solidity ^0.8.20;
interface IFreeForAll {
/// Anyone (in practice: the block builder) can make the bucket call out,
/// e.g. to transfer tokens it holds to themselves.
function execute(address recipient, bytes calldata data, uint256 gasLimit, uint256 value) external;
/// Pre-set return values for the next N calls to this contract in this block.
function preloadExecutions(bytes[] calldata responses) external;
}
Alice's bundle, conceptually:
nonce 7: router.swap(...) // the action she wants
nonce 8: usdc.transfer(FREE_FOR_ALL, 2e6) // tip: 2 USDC for the builder
Things to know
- Status is Stagnant, and the spec still has TODOs: the
preloadExecutionsbehaviour, backward compatibility and security considerations are unfinished. No canonical free-for-all contract address is defined. - Because the bucket is open to anyone, tips are only safe if the builder sweeps them in the same block; tokens left there can be taken by whoever acts first.
- Builders must simulate twice and take on risk, so in practice this depends on builders choosing to support it. It is not a guarantee of inclusion.
- Alternatives listed in the spec include allowing zero-gas-price transactions under EIP-1559 if the builder burns the equivalent, or a wrapper transaction type. Since Pectra, EIP-7702 delegation also lets a sponsor pay gas on behalf of an EOA, through a different mechanism.