IERC7786OpenBridge
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)
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
| Name | Type | Description |
|---|---|---|
| <none> | address[] |
getThreshold
function getThreshold() external view returns (uint8);Returns
| Name | Type | Description |
|---|---|---|
| <none> | uint8 |
getRemoteBridge
function getRemoteBridge(bytes calldata chain) external view returns (bytes memory);Parameters
| Name | Type | Description |
|---|---|---|
| chain | bytes |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | bytes |
minDirectCoverage
The minimum DIRECT registry coverage sendMessage requires of a destination (0 = disabled).
function minDirectCoverage() external view returns (uint8);Returns
| Name | Type | Description |
|---|---|---|
| <none> | uint8 |
addGateway
function addGateway(address gateway) external;Parameters
| Name | Type | Description |
|---|---|---|
| gateway | address |
removeGateway
function removeGateway(address gateway) external;Parameters
| Name | Type | Description |
|---|---|---|
| gateway | address |
setThreshold
function setThreshold(uint8 threshold) external;Parameters
| Name | Type | Description |
|---|---|---|
| threshold | uint8 |
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
| Name | Type | Description |
|---|---|---|
| bridge | bytes |
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
| Name | Type | Description |
|---|---|---|
| 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
| Name | Type | Description |
|---|---|---|
| sendId | bytes32 | |
| outbox | bytes32[] |
Received
Emitted when a gateway attests an inbound message.
event Received(bytes32 indexed id, address indexed gateway);Parameters
| Name | Type | Description |
|---|---|---|
| id | bytes32 | |
| gateway | address |
ExecutionSuccess
Emitted when an inbound message reaches the threshold and the recipient call succeeds.
event ExecutionSuccess(bytes32 indexed id);Parameters
| Name | Type | Description |
|---|---|---|
| id | bytes32 |
ExecutionFailed
Emitted when the recipient call fails (the message stays retryable — no revert).
event ExecutionFailed(bytes32 indexed id);Parameters
| Name | Type | Description |
|---|---|---|
| id | bytes32 |
RegisteredRemoteBridge
Emitted when a matching remote bridge is registered for a chain.
event RegisteredRemoteBridge(bytes bridge);Parameters
| Name | Type | Description |
|---|---|---|
| bridge | bytes |
GatewayAdded
Emitted when a gateway is added to / removed from the M-set.
event GatewayAdded(address indexed gateway);Parameters
| Name | Type | Description |
|---|---|---|
| gateway | address |
GatewayRemoved
event GatewayRemoved(address indexed gateway);Parameters
| Name | Type | Description |
|---|---|---|
| gateway | address |
ThresholdUpdated
Emitted when the N threshold changes.
event ThresholdUpdated(uint8 threshold);Parameters
| Name | Type | Description |
|---|---|---|
| threshold | uint8 |
MinDirectCoverageUpdated
Emitted when the minimum direct-coverage requirement changes (0 = check disabled).
event MinDirectCoverageUpdated(uint8 minDirectCoverage);Parameters
| Name | Type | Description |
|---|---|---|
| minDirectCoverage | uint8 |
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
| Name | Type | Description |
|---|---|---|
| chain | bytes |
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 < N <= 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
| Name | Type | Description |
|---|---|---|
| have | uint256 | |
| want | uint256 |