ERC-7796 · Review · ERC · 2024-04-16
ERC-7796: Conditional send transaction RPC
Defines eth_sendRawTransactionConditional, an RPC that lets users tell a block builder or sequencer to include a transaction only if certain state, block range and timestamp conditions hold.
What problem does it solve?
Private builder APIs make the builder simulate each transaction to decide whether it is worth including. Simulation is CPU-heavy, and the builder still cannot easily tell which transactions depend on each other.
That has odd economic effects. The only way to guarantee no other transaction interferes with yours is to be first in the block, so that slot is very expensive while other positions are cheap. And searching for a good ordering is costly.
ERC-7796 lets the sender state the preconditions for its transaction up front. The builder checks a few storage slots instead of running a full simulation, and different conditional transactions can be ordered safely.
How it works
Method: eth_sendRawTransactionConditional(rawTx, options)
options may contain:
| Member | Meaning |
|---|---|
knownAccounts |
Per-address expectations: a storage root hash (hex string), or an object of exact slot: value pairs, plus special keys balance, nonce and code |
blockNumberMin / blockNumberMax |
Allowed block number range |
timestampMin / timestampMax |
Allowed block timestamp range |
paysCoinbase |
Minimum amount the tx pays the coinbase (fees plus direct payment) |
For code, "" means "no code", and a 0xef0100… prefix means a specific EIP-7702 delegation.
The builder or sequencer should check the ranges, storage roots and slot values, and reject the request if any fail. Errors:
-32003"transaction rejected" with a reason (storage mismatch, out of range…);-32005"limit exceeded" for repeated failures or an oversizedknownAccounts.
On success it returns the transaction hash, like eth_sendRawTransaction. Acceptance is not inclusion: the caller must still watch the chain.
Only exact slot values are supported; min/max ranges were left out to keep the API simple. More complex conditions can be expressed via paysCoinbase with a conditional payment.
Sample code
{
"jsonrpc": "2.0",
"id": 1,
"method": "eth_sendRawTransactionConditional",
"params": [
"0x02f8...signedTx",
{
"blockNumberMax": 12345,
"timestampMax": 1760000000,
"knownAccounts": {
"0x1111111111111111111111111111111111111111": "0x5f3c...storageRoot",
"0x2222222222222222222222222222222222222222": {
"0x0000000000000000000000000000000000000000000000000000000000000001": "0x00000000000000000000000000000000000000000000000000000000000003e8"
},
"0x3333333333333333333333333333333333333333": { "code": "" }
}
}
]
}
Sending it with ethers v6:
const hash = await provider.send("eth_sendRawTransactionConditional", [signedTx, options]);
Things to know
- Status: Review. Some sequencers already expose non-standard methods with this name; they may need changes to match the final spec.
- A successful response does not guarantee inclusion; a reorg can drop or invalidate the transaction.
- Builders must protect against spam of transactions that are designed to fail: the spec suggests per-sender throttling, validating against recent state history, and for ERC-4337 bundles, checking the UserOperations exist in the public mempool.
- The design is especially useful for ERC-4337 bundlers, which need their bundle's validation assumptions to still hold at inclusion time.