Skip to content
Lattice

IERC7786OpenBridge

Git Source

Title: IERC7786OpenBridge

Authors: David Dada <daveproxy80@gmail.com> (https://github.com/dadadave80), Adapted for EIP-2535 from OpenZeppelin community-contracts ERC7786OpenBridge (https://github.com/OpenZeppelin/openzeppelin-community-contracts, commit f7e5f08)

(https://github.com/OpenZeppelin/openzeppelin-community-contracts/blob/f7e5f08e8fd42023084eb41f4a992d7be897b915/contracts/crosschain/ERC7786OpenBridge.sol)

Admin/read surface of the ERC-7786 OpenBridge: an N-of-M aggregator that fans a message out across M gateways and delivers to the recipient once N independent gateways have attested it. The standard sendMessage/supportsAttribute are on IERC7786GatewaySource; the inbound receiveMessage is on IERC7786Recipient.

Functions

getGateways

function getGateways() external view returns (address[] memory);

Returns

NameTypeDescription
<none>address[]

getThreshold

function getThreshold() external view returns (uint8);

Returns

NameTypeDescription
<none>uint8

getRemoteBridge

function getRemoteBridge(bytes calldata chain) external view returns (bytes memory);

Parameters

NameTypeDescription
chainbytes

Returns

NameTypeDescription
<none>bytes

minDirectCoverage

The minimum DIRECT registry coverage sendMessage requires of a destination (0 = disabled).

function minDirectCoverage() external view returns (uint8);

Returns

NameTypeDescription
<none>uint8

addGateway

function addGateway(address gateway) external;

Parameters

NameTypeDescription
gatewayaddress

removeGateway

function removeGateway(address gateway) external;

Parameters

NameTypeDescription
gatewayaddress

setThreshold

function setThreshold(uint8 threshold) external;

Parameters

NameTypeDescription
thresholduint8

registerRemoteBridge

Registers the matching OpenBridge on a remote chain (full ERC-7930 interoperable address). Reverts with ThresholdViolation until setThreshold has been called (configure gateways, then the threshold, then remotes).

function registerRemoteBridge(bytes calldata bridge) external;

Parameters

NameTypeDescription
bridgebytes

setMinDirectCoverage

Sets the M-of-N coverage-awareness knob: when non-zero, sendMessage hard-refuses destinations whose DIRECT gateway coverage in the IChainRegistry is below minDirectCoverage_ (set 2+ to refuse M=1 routes; 0 — the default — disables the check and preserves prior behavior).

function setMinDirectCoverage(uint8 minDirectCoverage_) external;

Parameters

NameTypeDescription
minDirectCoverage_uint8

Events

OutboxDetails

Emitted with the per-gateway send ids when an outbound message is fanned out.

event OutboxDetails(bytes32 indexed sendId, bytes32[] outbox);

Parameters

NameTypeDescription
sendIdbytes32
outboxbytes32[]

Received

Emitted when a gateway attests an inbound message.

event Received(bytes32 indexed id, address indexed gateway);

Parameters

NameTypeDescription
idbytes32
gatewayaddress

ExecutionSuccess

Emitted when an inbound message reaches the threshold and the recipient call succeeds.

event ExecutionSuccess(bytes32 indexed id);

Parameters

NameTypeDescription
idbytes32

ExecutionFailed

Emitted when the recipient call fails (the message stays retryable — no revert).

event ExecutionFailed(bytes32 indexed id);

Parameters

NameTypeDescription
idbytes32

RegisteredRemoteBridge

Emitted when a matching remote bridge is registered for a chain.

event RegisteredRemoteBridge(bytes bridge);

Parameters

NameTypeDescription
bridgebytes

GatewayAdded

Emitted when a gateway is added to / removed from the M-set.

event GatewayAdded(address indexed gateway);

Parameters

NameTypeDescription
gatewayaddress

GatewayRemoved

event GatewayRemoved(address indexed gateway);

Parameters

NameTypeDescription
gatewayaddress

ThresholdUpdated

Emitted when the N threshold changes.

event ThresholdUpdated(uint8 threshold);

Parameters

NameTypeDescription
thresholduint8

MinDirectCoverageUpdated

Emitted when the minimum direct-coverage requirement changes (0 = check disabled).

event MinDirectCoverageUpdated(uint8 minDirectCoverage);

Parameters

NameTypeDescription
minDirectCoverageuint8

Errors

UnsupportedNativeTransfer

sendMessage was called with non-zero msg.value (native transfer unsupported).

error UnsupportedNativeTransfer();

RemoteBridgeAlreadyRegistered

A matching remote bridge is already registered for this chain.

error RemoteBridgeAlreadyRegistered(bytes chain);

Parameters

NameTypeDescription
chainbytes

InvalidCrosschainSender

The inbound sender is not the registered matching bridge for its chain.

error InvalidCrosschainSender();

InvalidExecutionReturnValue

The recipient returned a value other than the ERC-7786 magic.

error InvalidExecutionReturnValue();

ThresholdViolation

The threshold must satisfy 0 &lt; N &lt;= M (M = number of gateways). Also thrown by registerRemoteBridge while the threshold is still 0.

error ThresholdViolation();

OpenBridgeInsufficientCoverage

The destination chain's DIRECT gateway coverage in the IChainRegistry is below the configured minimum (hub-routed coverage never counts) — the route is refused as too centralized.

error OpenBridgeInsufficientCoverage(uint256 have, uint256 want);

Parameters

NameTypeDescription
haveuint256
wantuint256