Introduction

Hi, I'm cardene, a software engineer and technical writer focused on blockchain and AI.

I've also authored Japanese technical books on specification-driven development with LLMs and decentralized application (DApp) development.

I also build and publish a variety of tools, libraries, and open-source projects.

ERC-7796 proposes a JSON-RPC method that lets a sender specify preconditions for transaction execution.

This article explains and expands on the proposal below.

I also cover other Ethereum improvement proposals.

Overview

ERC-7796 proposes eth_sendRawTransactionConditional, a JSON-RPC method that lets a sender attach conditions for block builders or sequencers to check when processing a transaction. The aim is to reduce the number of simulations builders need to run, lowering computation costs and making block construction more efficient.

Motivation

Private block-building APIs such as Flashbots use simulation to validate transactions. Simulation is CPU-intensive, so running many simulations during block construction adds cost and makes it harder to explore alternative orderings efficiently.

The Flashbots API discussed in the proposal has no mechanism to declare dependencies between transactions. Without such a mechanism, a sender cannot guarantee that another transaction will leave the relevant state unchanged. Placing a transaction first in the block avoids interference from earlier transactions. That position is especially valuable, so competing for it can be expensive.

Other positions may command lower gas bids because the sender cannot be sure how preceding transactions will affect execution. The lack of a simple way to detect dependencies also makes finding an optimal ordering computationally expensive.

ERC-7796 addresses this by letting senders specify when a transaction is eligible for inclusion using eth_sendRawTransactionConditional. For example, the sender can require a contract to have a specific expected balance.

Builders can evaluate these declarations without simulating every candidate for every ordering. This reduces computation and simplifies ordering and block construction. Explicit conditions also give senders some control over interference from other transactions. That could reduce demand for first position and give transactions more opportunities elsewhere in a block.

Specification

eth_sendRawTransactionConditional

The method accepts conditions that restrict execution to a particular block range or state. It resembles eth_sendRawTransaction, but takes an additional optional parameter, options, to express inclusion rules.

transaction

As with eth_sendRawTransaction, the sender supplies pre-signed transaction data. The transaction uses the normal Ethereum format. The extra conditions restrict the states in which it can be included.

options

The options parameter describes the conditions a candidate block must meet.

knownAccounts

The sender can specify expected storage slot values for particular accounts. The builder only accepts the transaction when those values match. The original article describes an ETH balance threshold, but the specification makes this an expected balance value rather than a minimum.

  • key
    • The Ethereum account address.
  • balance
    • A condition on the account's ETH balance.
  • code
    • A condition on the presence or contents of account code.
    • An empty string ("") requires the address to have no code.
    • A specific value such as "0xef01..." can require EIP-7702 delegation code.
  • nonce
    • The expected account nonce.
  • Storage values
    • A hexadecimal string sets the expected storage root hash.
    • An object sets expected values for individual slots.
    • Slot keys and values are hexadecimal strings.

For more on EIP-7702, see the following article.

[EIP-7702] How EOAs can delegate to contract code

blockNumberMin / blockNumberMax (block number range)

These fields restrict which blocks may include the transaction.

  • blockNumberMin
    • The earliest block number at which to execute the transaction.
  • blockNumberMax
    • The latest block number at which to execute it.

The transaction is ineligible outside the specified range.

timestampMin / timestampMax (timestamp range)

These fields restrict the timestamp of the block that executes the transaction.

  • timestampMin
    • The earliest eligible timestamp, in seconds.
  • timestampMax
    • The latest eligible timestamp, in seconds.

This gives the transaction a limited eligibility window.

paysCoinbase (payment to the block beneficiary)

The sender can specify the minimum payment to the builder or sequencer. This amount accounts for both gas fees and direct payments. The threshold gives the builder a criterion for selecting the transaction.

Builder and sequencer processing

When a builder or sequencer receives the transaction, it checks the specified conditions before inclusion.

  • If the sender supplied block bounds, check that the block number is in range.
  • If the sender supplied timestamp bounds, check that the block timestamp is in range.
  • Check that the storage root hashes supplied in knownAccounts match.
  • Check that values in the specified knownAccounts storage slots match.

The sequencer rejects the transaction if any applicable condition fails.

Return value

A successful call returns the submitted transaction's hash, as eth_sendRawTransaction does when it accepts a transaction. The hash identifies the transaction.

Handling errors

If the builder rejects the transaction immediately, it responds with a code and a message explaining the reason.

  • A condition fails. Error -32003 identifies the rejection. A message can indicate that a specified slot contains a different value, the block number is outside the permitted range, or the timestamp is outside the permitted window.
  • A request is too expensive to process. Error -32005 indicates that the request exceeds a processing limit. For example, knownAccounts may contain too many accounts.

Inclusion remains conditional

Passing validation does not guarantee inclusion, just as a successful eth_sendRawTransaction does not guarantee confirmation.

A revised ordering can drop a transaction that was initially selected. Other transactions can also delay execution or change the state enough to invalidate a condition. After submitting the transaction, monitor whether a block includes it and resubmit if appropriate.

Example request

json
{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "eth_sendRawTransactionConditional",
    "params": [
        "0x2815c17b00...",
        {
            "blockNumberMax": 12345,
            "knownAccounts": {
                "0xadd1": "0xfedc....",
                "0xadd2": { 
                    "0x1111": "0x1234...",
                    "0x2222": "0x4567..."
                }
            }     
        } 
    ]
}

The example sets two kinds of conditions.

  • Maximum block number. The transaction is eligible at block 12345 or earlier.
  • Account state in knownAccounts. The storage root of 0xadd1 must be 0xfedc.... For 0xadd2, slot 0x1111 must contain 0x1234... and slot 0x2222 must contain 0x4567....

Additional notes

Design rationale

For storage slots, knownAccounts accepts exact matches. A transaction is eligible only if a given slot holds the specified value.

A design could also allow minValue and maxValue bounds. It would then be possible to ask for execution whenever a token balance is 100 or higher. The proposal explains why it leaves out that feature.

Why the API does not support storage value ranges

  • More complicated evaluation. Adding minValue and maxValue would require builders to evaluate range predicates in addition to exact matches, increasing implementation complexity and work per request.
  • Harder choices for senders. A user or bot may know that a slot value fluctuates within a range but still have difficulty choosing bounds that make a transaction valid in the desired situations.

The API therefore uses exact expected values for storage slots.

Alternative approach

The paysCoinbase option can help represent certain economic conditions without adding storage bounds. A sender can require a minimum amount to reach coinbase, the block's beneficiary address, if the transaction is included.

A transaction can structure its payment so that it meets the minimum only under the desired circumstances. The builder can then decide whether to include it based on the resulting payment. That allows the sender to influence inclusion indirectly by making payment contingent on the condition.

Compatibility

The proposal adds a new API method, so existing API behavior remains compatible.

Security considerations

Builders must protect the endpoint against abuse. Requests that are certain to fail still consume resources. A denial-of-service attack can exhaust that capacity and prevent legitimate users from accessing the API.

Throttling

Builders can cap how many requests a sender or account submits within a fixed window. They can also adjust limits based on outcomes.

  • If a request succeeds and its transaction lands in a block, increase the account's allowance.
  • If a request fails because its conditions do not hold, decrease the allowance.

This approach keeps capacity available to legitimate users while limiting repeat abuse.

Arbitrum's approach

Arbitrum implements a similar API and checks storage against recent blocks from the preceding two seconds as well as the current block.

  • Discourage MEV abuse. Checking recent state makes it harder to use the endpoint to react only to a favorable storage change, including attempts at price manipulation or front-running.
  • Maintain ERC-4337 compatibility. ERC-4337 requires verification that a user's wallet meets execution conditions. Looking at recent state can make these checks more stable.

For more on ERC-4337, see the following article.

[ERC-4337] Implementing account abstraction without protocol changes

A short lookback thus limits abuse tied to momentary state changes while allowing normal processing to continue.

Polygon FastLane's approach

Polygon FastLane uses the API for ERC-4337 and checks whether the same transaction already exists in the public mempool before accepting it.

  • Reject unexpected private submissions. A transaction that appears through the endpoint without a corresponding public mempool transaction can be rejected.
  • Process ordinary ERC-4337 traffic. The design expects the relevant transactions to appear in the mempool, so the check helps distinguish eligible traffic.

Citation

Dror Tirosh (@drortirosh), Yoav Weiss (@yoavw), Alex Forshtat (@forshtat), Shahaf Nacson (@shahafn), "ERC-7796: Conditional send transaction RPC [DRAFT]," Ethereum Improvement Proposals, no. 7796, April 2024. [Online serial]. Available: https://eips.ethereum.org/EIPS/eip-7796.

Conclusion

ERC-7796 proposes a JSON-RPC method for attaching preconditions to a transaction. Builders and sequencers can use those conditions when deciding whether a transaction is eligible for inclusion.

Questions are welcome by direct message.

Twitter @cardene777

I also write on the following sites.

https://chaldene.net/