Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/wild-baths-buy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'openzeppelin-solidity': minor
---

`IERC7786`: Add the (draft) interface for ERC-7786 "Cross-Chain Messaging Gateway"
3 changes: 3 additions & 0 deletions contracts/interfaces/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ are useful to interact with third party contracts that implement them.
- {IERC6909Metadata}
- {IERC6909TokenSupply}
- {IERC7674}
- {IERC7786}
- {IERC7802}

== Detailed ABI
Expand Down Expand Up @@ -99,4 +100,6 @@ are useful to interact with third party contracts that implement them.

{{IERC7674}}

{{IERC7786}}

{{IERC7802}}
64 changes: 64 additions & 0 deletions contracts/interfaces/draft-IERC7786.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
// SPDX-License-Identifier: MIT

pragma solidity >=0.8.4;

/**
* @dev Interface for ERC-7786 source gateways.
*
* See ERC-7786 for more details
*/
interface IERC7786GatewaySource {
/**
* @dev Event emitted when a message is created. If `outboxId` is zero, no further processing is necessary. If
* `outboxId` is not zero, then further (gateway specific, and non-standardized) action is required.
*/
event MessageSent(
bytes32 indexed sendId,
bytes sender, // Binary Interoperable Address
bytes receiver, // Binary Interoperable Address
bytes payload,
uint256 value,
bytes[] attributes
);

/// @dev This error is thrown when a message creation fails because of an unsupported attribute being specified.
error UnsupportedAttribute(bytes4 selector);

/// @dev Getter to check whether an attribute is supported or not.
function supportsAttribute(bytes4 selector) external view returns (bool);

/**
* @dev Endpoint for creating a new message. If the message requires further (gateway specific) processing before
* it can be sent to the destination chain, then a non-zero `outboxId` must be returned. Otherwise, the
* message MUST be sent and this function must return 0.
*
* * MUST emit a {MessageSent} event.
*
* If any of the `attributes` is not supported, this function SHOULD revert with an {UnsupportedAttribute} error.
* Other errors SHOULD revert with errors not specified in ERC-7786.
*/
function sendMessage(
bytes calldata recipient, // Binary Interoperable Address
bytes calldata payload,
bytes[] calldata attributes
) external payable returns (bytes32 sendId);
}

/**
* @dev Interface for the ERC-7786 client contract (receiver).
*
* See ERC-7786 for more details
*/
interface IERC7786Receiver {
/**
* @dev Endpoint for receiving cross-chain message.
*
* This function may be called directly by the gateway.
*/
function executeMessage(
bytes32 receiveId,
bytes calldata sender, // Binary Interoperable Address
bytes calldata payload,
bytes[] calldata attributes
) external payable returns (bytes4);
}