ERC-5189 · Draft · ERC · 2022-06-29
ERC-5189: Account Abstraction via Endorsed Operations
Account abstraction without protocol changes: wallets submit Operations to a public mempool, and a per-wallet 'endorser' contract tells bundlers whether each one will pay and which state it depends on.
What problem does it solve?
Smart contract wallets need someone, a bundler, to send their transactions on-chain and get paid back for gas. The hard part is denial-of-service. How does a bundler know an operation will actually pay, without running the whole thing and re-running it after every state change?
ERC-4337 answers this with a fixed UserOperation format, a shared EntryPoint and strict validation rules on opcodes and storage. Existing wallets have to adopt that model. ERC-5189 takes another route. It aims to work with already-deployed wallets as they are, with no consensus changes and no restrictions on what wallet code may do. Each wallet developer instead supplies a contract that vouches for their wallet's operations.
How it works
Operation. An off-chain struct sent to a dedicated mempool. Its fields include entrypoint + callData (what to call, usually the wallet itself), fixedGas and gasLimit, fee fields similar to EIP-1559 (maxFeePerGas, priorityFeePerGas), a feeToken with scaling factors for paying in ERC-20, chainId, and the endorser to consult.
Endorser. A contract deployed by the wallet developer. Bundlers simulate calls to it off-chain and never call it on-chain:
simulationSettings(op)returns code and storage overrides to apply before simulating.isOperationReady(op)returnsreadinessplus the operation's dependencies. These are global (base fee, timestamp, block number,maxBlockNumberand so on) and per-address (balance, code, nonce, specific storage slots, or value ranges calledconstraints).
If readiness is true, the operation must execute and must pay the bundler at least:
gasUnits = fixedGas + min(gasUsed, gasLimit)
feePerGas = min(maxFeePerGas, baseFee + priorityFeePerGas)
repayment = gasUnits * feePerGas * feeScalingFactor / feeNormalizationFactor
The bundler only re-checks an operation when one of its dependencies changes. It runs a final simulation inside the actual block before inclusion. If an endorser said "ready" and the operation then fails or underpays, the bundler bans that endorser and drops all of its operations. To make endorsers costly to throw away, they can burn ETH in an EndorserRegistry, and each mempool operator decides how much burn to require.
For code paths the endorser cannot fully check, it can emit UntrustedStarted / UntrustedEnded. Inside that section, the bundler records every state access as a dependency automatically.
Sample code
The registry contract from the spec, slightly trimmed:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.15;
contract EndorserRegistry {
event Burned(address indexed endorser, address indexed sender, uint256 added, uint256 total);
mapping(address => uint256) public burn;
function addBurn(address endorser) external payable returns (uint256 total) {
total = burn[endorser] + msg.value; // ETH is locked here forever
burn[endorser] = total;
emit Burned(endorser, msg.sender, msg.value, total);
}
}
A bundler's admission check, in pseudocode:
settings = endorser.simulationSettings(op) # eth_call
ready, glob, deps = simulate(endorser.isOperationReady, op, overrides=settings)
if ready and registry.burn(op.endorser) >= MIN_ENDORSER_BURN:
mempool.add(op, watch=deps, valid_until=(glob.maxBlockNumber, glob.maxBlockTimestamp))
Things to know
- Status: Draft. In practice, the ecosystem has mostly gone with ERC-4337 and, for EOAs, EIP-7702.
- The spec defines no replay protection or wallet-deployment logic. Those stay with each wallet and its entrypoint.
- Safety rests on bundlers' own policies: minimum burn, dependency limits, re-evaluation limits and endorser bans. The spec suggests constants such as
MAX_ENDORSER_GASandMIN_ENDORSER_BURNbut gives them no values. - An operation can be executed more than once. The protocol does not stop this. Replay protection is up to the wallet, for example a nonce that shows up as a dependency.