Crosschain
Smart contract crosschain utilities and implementations
This directory contains contracts for sending and receiving cross chain messages that follows the ERC-7786 standard.
ERC7786Recipient: generic ERC-7786 crosschain contract that receives messages from a trusted gateway
Helpers
import "@openzeppelin/contracts/crosschain/ERC7786Recipient.sol";Base implementation of an ERC-7786 compliant cross-chain message receiver.
This abstract contract exposes the receiveMessage function that is used for communication with (one or multiple)
destination gateways. This contract leaves two functions unimplemented:
-
ERC7786Recipient._isAuthorizedGateway, an internal getter used to verify whether an address is recognised by the contract as a valid ERC-7786 destination gateway. One or multiple gateway can be supported. Note that any malicious address for which this function returns true would be able to impersonate any account on any other chain sending any message. -
ERC7786Recipient._processMessage, the internal function that will be called with any message that has been validated.
This contract implements replay protection, meaning that if two messages are received from the same gateway with the
same receiveId, then the second one will NOT be executed, regardless of the result of ERC7786Recipient._isAuthorizedGateway.
Functions
Errors
receiveMessage(bytes32 receiveId, bytes sender, bytes payload) → bytes4
external
#Endpoint for receiving cross-chain message.
This function may be called directly by the gateway.
_isAuthorizedGateway(address gateway, bytes sender) → bool
internal
#Virtual getter that returns whether an address is a valid ERC-7786 gateway for a given sender.
The sender parameter is an interoperable address that include the source chain. The chain part can be
extracted using the InteroperableAddress library to selectively authorize gateways based on the origin chain
of a message.
_processMessage(address gateway, bytes32 receiveId, bytes sender, bytes payload)
internal
#Virtual function that should contain the logic to execute when a cross-chain message is received.
ERC7786RecipientUnauthorizedGateway(address gateway, bytes sender)
error
#ERC7786RecipientMessageAlreadyProcessed(address gateway, bytes32 receiveId)
error
#