From fd9bbaec30ef5b760b1a9db4bc786d84d62f4b90 Mon Sep 17 00:00:00 2001 From: Hadrien Croubois Date: Wed, 9 Jul 2025 21:50:48 +0200 Subject: [PATCH] Add ERC-7786 interface (#5737) --- .changeset/wild-baths-buy.md | 5 ++ contracts/interfaces/README.adoc | 3 ++ contracts/interfaces/draft-IERC7786.sol | 64 +++++++++++++++++++++++++ 3 files changed, 72 insertions(+) create mode 100644 .changeset/wild-baths-buy.md create mode 100644 contracts/interfaces/draft-IERC7786.sol diff --git a/.changeset/wild-baths-buy.md b/.changeset/wild-baths-buy.md new file mode 100644 index 000000000..e2d978fa1 --- /dev/null +++ b/.changeset/wild-baths-buy.md @@ -0,0 +1,5 @@ +--- +'openzeppelin-solidity': minor +--- + +`IERC7786`: Add the (draft) interface for ERC-7786 "Cross-Chain Messaging Gateway" diff --git a/contracts/interfaces/README.adoc b/contracts/interfaces/README.adoc index 9cb4d9a24..760c3c2d2 100644 --- a/contracts/interfaces/README.adoc +++ b/contracts/interfaces/README.adoc @@ -45,6 +45,7 @@ are useful to interact with third party contracts that implement them. - {IERC6909Metadata} - {IERC6909TokenSupply} - {IERC7674} +- {IERC7786} - {IERC7802} == Detailed ABI @@ -99,4 +100,6 @@ are useful to interact with third party contracts that implement them. {{IERC7674}} +{{IERC7786}} + {{IERC7802}} diff --git a/contracts/interfaces/draft-IERC7786.sol b/contracts/interfaces/draft-IERC7786.sol new file mode 100644 index 000000000..9fa440eb2 --- /dev/null +++ b/contracts/interfaces/draft-IERC7786.sol @@ -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); +}