ERC-7683 Cross-chain intents (Cross Chain Intents)

Draft · Other · created 2024-04-11

A resolver standard that translates cross-chain intent (desired-outcome) orders into a common format solvers can read. By verifying only the resolver, a solver can fulfill orders from multiple intent protocols.

Why it is needed

Cross-chain transactions use an intent model in which the user states only the desired outcome, and a specialized actor called a solver performs the necessary execution in exchange for compensation. However, without a common format for presenting orders to solvers, solver liquidity gets fragmented across protocol-specific integrations. Because solvers must implement a different payload format, execution procedure, and payment method for each protocol, integration costs rise, shared solver networks and order-distribution services weaken, and new protocols struggle to attract competitive execution. At the same time, protocols have good reasons for their order creation, fund approval, settlement verification, pricing, and escrow-first-versus-fill-first design to differ from one another, making it hard to unify the entire process into one. This standard strikes a middle ground: it standardizes only the way solvers consume orders, leaving the rest of the design up to each protocol.

What to implement

In depth

Resolvers and off-chain resolve

A protocol distributes an order as an opaque payload (a byte string) and deploys a resolver contract on-chain to interpret it. Rather than via a transaction, the solver calls resolve(payload) off-chain through eth_call and receives a ResolvedOrder made up of four arrays: steps, variables, payments, and assumptions. Because the interpretation is not part of on-chain execution, complex decoding and validation can be done without gas-cost constraints. The resolver is the point of trust: solver operators whitelist resolver addresses they have verified through audits, bounties, and similar means, and they trust the instructions those resolvers produce. A resolver must guarantee that an order can only be aborted in the cases specified by its RevertPolicy, and that unless the abort policy is triggered, the solver that began execution will be able to fulfill all requirements and receive all payments.

Call steps and properties

The order's requirements are expressed as a list of steps and a list of variables. A step is a Call, consisting of target (an interoperable address), selector (a 4-byte function selector), arguments, and attributes. The attributes are SpendsERC20 (the call may pull up to amountFormula of the caller's tokens via transferFrom, and the solver must guarantee the balance and allowance), SpendsGas (must execute with at least the specified gas limit; if not specified, it can be estimated by simulation before executing other steps), RevertPolicy (reverts matching an expectedReason prefix are handled as ignore or abort; reverts matching no policy are forbidden), TimingBounds (block.number or block.timestamp at execution time must lie between a lower and upper bound), and NeedsStep and NeedsVariable (explicit hard dependencies). Hard dependencies must be acyclic, and a step can only execute once all of its dependencies have executed successfully.

Seven variable roles

A variable is a placeholder for a value the solver determines, and once set, that value must be used consistently everywhere it is referenced. PaymentRecipient and PaymentChain are the account and chain ID at which the solver wants to receive payment, and StepCaller is the caller account that will execute a particular step. ExecutionOutput is a value observed from execution, supporting three fields: block.number, block.timestamp, and receipt.effectiveGasPrice. Witness is a value obtained by running the off-chain procedure indicated by kind with data and other variable values. Query is the result of an eth_call sent to target, and the call must not revert. QueryEvents holds the result of eth_getLogs as the framed ABI encoding of an array of EthLog structs (emitter, topics, data, blockNumber, transactionHash, etc.). For both Query and QueryEvents, omitting blockNumber uses the latest block.

ERC20 payments

The order includes a list of payments to be made in exchange for fulfillment. The parameters of an ERC20 payment are token, sender, amountFormula, recipientVarIdx, onStepIdx, and estimatedDelaySeconds. Once step onStepIdx has executed, at least the amount given by amountFormula of token must be paid from sender, and the payment must be sent to the address value of variable recipientVarIdx (the PaymentRecipient role), on the chain indicated by token. The payment delay must, with high confidence, be within estimatedDelaySeconds. Because the solver sets the recipient address and chain directly as variables, the solver can receive payment wherever it prefers.

Value representation and framed ABI encoding

Values assigned to variables are untyped, represented only by their ABI encoding and whether their size is static or dynamic; the consuming context interprets them as a specific type (for example, SpendsGas's formula is uint256). On the EVM, values are represented as framed ABI encoding. This is the standard ABI encoding of a two-element tuple consisting of an empty string and the value, i.e., the byte string produced by Solidity's abi.encode("", value). For a dynamically sized value, it begins with a fixed 96-byte prefix followed by the ABI encoding of the value itself. For a statically sized value, the value's encoding is placed between a 32-byte prefix (the length of the value encoding plus 32) and a 32-byte zero-padded suffix. Call data is constructed by concatenating the 4-byte function selector with the ABI encoding of the arguments.

Named assumptions and implicit assumptions

Safety conditions that a resolver cannot verify on its own are specified to the solver as an Assumption struct with name and data. Before fulfilling an order, the solver must verify this assumption, for example by checking it against a whitelist. The liveness and censorship resistance of the underlying chain, and the liveness and censorship resistance of the token used in SpendsERC20, may be assumed implicitly. A specific resolver may additionally impose and document other implicit assumptions (for example, the security of a specific protocol), and the solver must review all such implicit assumptions before trusting the resolver.

Changes from the previous draft

The earlier draft standardized the entire lifecycle, including order encoding (OnchainCrossChainOrder, GaslessCrossChainOrder), the on-chain feed (IOriginSettler.open), and the fill function (IDestinationSettler.fill). However, because the standard types were parameterized by implementation-specific fields, solvers ended up having to support protocol-specific subtypes separately. maxSpent and minReceived only provided a lower bound on profit, so loose bounds could cause a profitable order to go unfilled (in the worst case, maxSpent could be UINT256_MAX). It also presupposed per-order escrow, which did not fit resource-lock-based pre-fill protocols, and forced gas overhead through large calldata structs and the Open event. The current design moves the standardization boundary to a solver-facing interpretation interface, preserving protocol flexibility for user approval, order creation, settlement verification, and execution ordering.

Draft status and required standards

This proposal was created on April 11, 2024 and is currently in Draft status. Since it is still under review, the interfaces and specification may change, and progress may stall. In fact, there is precedent for the standardization scope changing significantly from the previous draft, so it is advisable to check the latest source text and discussion threads before implementing. This standard also requires ERC-7930, which defines interoperable addresses, so that standard must be consulted alongside this one when implementing.

Things to watch out for

Original ERC · ← ERCs