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
function resolve(bytes calldata payload) external view returns (ResolvedOrder memory);: Interprets a protocol-specific payload and returns a ResolvedOrder made up of steps, variables, payments, and assumptions. Solvers call it via eth_call.function PaymentRecipient() external;: A variable role whose value is the account the solver wants payment sent to.function PaymentChain() external;: A variable role whose value is the ID of the chain on which the solver wants to receive payment.function StepCaller(uint256 stepIdx) external;: A variable role whose value is the caller account to use when executing step stepIdx.function ExecutionOutput(string calldata field, uint256 stepIdx) external;: A variable role that holds values observed during the execution of step stepIdx (block number, timestamp, effective gas price).function Witness(string calldata kind, bytes calldata data, uint256[] calldata variables) external;: A variable role that holds the result of running the off-chain procedure indicated by kind, using data and other variable values.function Query(bytes calldata target, bytes4 selector, bytes[] calldata arguments, uint256 blockNumber) external;: A variable role that holds the value returned from sending an eth_call to target. If blockNumber is absent, the latest block is used.function QueryEvents(bytes calldata emitter, bytes1 topicMatch, bytes32 topic0, bytes32 topic1, bytes32 topic2, bytes32 topic3, uint256 blockNumber) external;: A variable role that holds the result of querying eth_getLogs for emitter's logs filtered by topic.function ERC20(bytes calldata token, bytes calldata sender, bytes calldata amountFormula, uint256 recipientVarIdx, uint256 onStepIdx, uint256 estimatedDelaySeconds) external;: A payment under which, once step onStepIdx executes, sender must pay at least amountFormula of token to the recipient address the solver designates.function SpendsERC20(bytes calldata token, bytes calldata amountFormula, bytes calldata spender, bytes calldata recipient) external;: A property stating that the call can pull up to amountFormula of caller's token via transferFrom. The solver must have the balance and approval ready.function SpendsGas(bytes calldata amountFormula) external;: A property stating that the call can use up to amountFormula of gas. The solver must execute it with a gas limit at or above that.function TimingBounds(string calldata field, bytes calldata lowerBound, bytes calldata upperBound) external;: A property requiring that, when the call is included, block.number or block.timestamp fall within a specified range.function NeedsStep(uint256 stepIdx) external;: A property stating that this call has a hard dependency on step stepIdx.function NeedsVariable(uint256 varIdx) external;: A property stating that this call has a hard dependency on variable varIdx.function RevertPolicy(string calldata policy, bytes calldata expectedReason) external;: A property stating that if the call reverts with data starting with expectedReason, it should be handled as either ignore (treated as executed) or abort (the entire order is aborted).function Constant(uint256 val) external;: Represents a constant value in a formula.function Variable(uint256 varIdx) external;: References variable varIdx in a formula.
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
- Scope guaranteed by the standard: This standard only standardizes the way a protocol describes an order to solvers; it does not standardize or guarantee the security of the protocol that ultimately settles the order. Whether following the instructions is safe depends on the resolver implementation, the settlement contract, the assets involved, and the off-chain and cross-chain systems the protocol uses.
- Documenting implicit assumptions: Resolver implementations must document any implicit assumptions they rely on beyond what this standard permits, so that solvers and auditors can evaluate them alongside the explicit assumptions included in the interpreted order.
- The risk window extends until payment is finalized: The solver is exposed to risk from the moment it commits capital, approvals, and transactions to an order until the expected payment is finalized and usable. Security analysis must cover the entire span of execution and settlement, including adversarial changes to protocol state, chain state, token behavior, oracle values, permissions, and message-passing paths.
- Focus of the audit: The audit must focus on whether a solver that correctly follows the resolver's instructions can be led into an unsafe position. It must verify whether the requirements needed for solver safety are enforced by the resolver or protocol or are exposed as assumptions, whether execution steps spend solver assets, demand permissions, or create obligations beyond the disclosed scope, and whether the payment path can be invalidated after the solver has incurred cost.