ERC-7985 · Draft · ERC · 2024-07-04
ERC-7985: Gateway Attributes for Message Control
Standard ERC-7786 attributes for cross-chain messages: cancellation, delivery windows, retry policy, revert behavior, dependencies and minimum gas, so apps can request the same controls from any gateway.
What problem does it solve?
ERC-7786 defines one interface for sending messages across chains through any bridge or messaging protocol (a "gateway"). It deliberately leaves protocol-specific features to attributes: extra bytes entries attached to each message, each starting with a 4-byte key. ERC-7786 recommends standardizing common attributes in separate ERCs.
ERC-7985 is that follow-up for the controls nearly every cross-chain app ends up needing: cancel a message, stop it from arriving too late or too early, retry on failure, decide what happens when delivery fails, enforce ordering and guarantee enough gas. Without a shared definition, each gateway invents its own, and applications have to special-case every provider.
How it works
Each attribute key is the function selector of a descriptive signature, and its value is the ABI encoding of the arguments, so an entry can be built with abi.encodeWithSignature. A gateway may support any subset, must validate the encoding of those it supports, and must revert on bad encoding.
| Attribute | Selector | Meaning |
|---|---|---|
cancellable(bool) |
0xde986d7f |
If true, the gateway must offer a way to cancel the pending message. Defaults to false. |
deliverBefore(uint256) |
0x3e97d7ee |
Unix timestamp after which delivery is forbidden; 0 means no expiry. |
deliverAfter(uint256) |
0x745910eb |
Earliest delivery timestamp; 0 means no delay. Together with deliverBefore this forms a window. |
retryPolicy(bytes) |
0xf002c055 |
Packed uint16 maxRetries, uint32 retryDelay (seconds), uint32 backoffMultiplier (basis points, 10000 = 1x). |
revertBehavior(uint8) |
0x9e521a77 |
0 revert on failure (default), 1 emit MessageFailed and continue, 2 fail silently. |
dependsOn(bytes32[]) |
0xa9fed7b9 |
Message IDs that must be delivered successfully first. |
minGasLimit(uint256) |
0x39f87ba1 |
Minimum gas the gateway must make available for delivery. |
Gateways that do not know these attributes keep working under ERC-7786's rules; senders can check supportsAttribute(selector) first.
Sample code
Sending a message with a delivery window, a gas floor and a dependency:
// SPDX-License-Identifier: CC0-1.0
pragma solidity ^0.8.20;
interface IERC7786GatewaySource {
function supportsAttribute(bytes4 selector) external view returns (bool);
function sendMessage(bytes calldata recipient, bytes calldata payload, bytes[] calldata attributes)
external payable returns (bytes32 sendId);
}
contract Sender {
IERC7786GatewaySource public immutable gateway;
constructor(IERC7786GatewaySource g) { gateway = g; }
function send(bytes calldata recipient, bytes calldata payload, bytes32 previous)
external payable returns (bytes32)
{
bytes32[] memory deps = new bytes32[](1);
deps[0] = previous;
bytes[] memory attrs = new bytes[](4);
attrs[0] = abi.encodeWithSignature("deliverAfter(uint256)", block.timestamp + 10 minutes);
attrs[1] = abi.encodeWithSignature("deliverBefore(uint256)", block.timestamp + 1 days);
attrs[2] = abi.encodeWithSignature("minGasLimit(uint256)", 200_000);
attrs[3] = abi.encodeWithSignature("dependsOn(bytes32[])", deps);
require(gateway.supportsAttribute(0xa9fed7b9), "no dependsOn support");
return gateway.sendMessage{value: msg.value}(recipient, payload, attrs);
}
}
recipient is a binary Interoperable Address as used by ERC-7786 (see ERC-7930).
Things to know
- Status: Draft. Selectors are fixed by their signatures, but semantics may still change.
- Security Considerations are not written yet. An open question noted in the draft is how gateways should handle circular
dependsOnchains. - The
retryPolicydefault text is ambiguous: an empty value is described as "infinite retries", whilemaxRetries = 0is described as "no retries". Do not rely on the default; set it explicitly if your gateway supports it. - Attributes are requests. Whether they are enforced depends on the gateway and the underlying bridge; check
supportsAttributebefore relying on any of them.