-
Inbox contract: https://github.com/ethereum-optimism/optimism/blob/develop/packages/contracts-bedrock/src/L2/interfaces/IL2ToL2CrossDomainMessenger.sol
-
Contract spec: https://github.com/ethereum-optimism/specs/blob/main/specs/interop/predeploys.md#l2tol2crossdomainmessenger
-
Contract addr:
0x4200000000000000000000000000000000000023
-
Contract
SentMessage
event signature:0x579caada8c83076797a5247b3049d2ba67435f2638409ca328de39206d82ae3b
-
Alloy example: https://github.com/tyler-smith/bulkmail/blob/master/src/chain.rs
-
Alloy query logs example: https://alloy.rs/examples/queries/query_logs.html
/// @notice Emitted whenever a message is sent to a destination
/// @param destination Chain ID of the destination chain.
/// @param target Target contract or wallet address.
/// @param messageNonce Nonce associated with the messsage sent
/// @param sender Address initiating this message call
/// @param message Message payload to call target with.
event SentMessage(
uint256 indexed destination, address indexed target, uint256 indexed messageNonce, address sender, bytes message
);
/// @notice Emitted whenever a message is successfully relayed on this chain.
/// @param source Chain ID of the source chain.
/// @param messageNonce Nonce associated with the messsage sent
/// @param messageHash Hash of the message that was relayed.
event RelayedMessage(uint256 indexed source, uint256 indexed messageNonce, bytes32 indexed messageHash);
/// @notice Sends a message to some target address on a destination chain. Note that if the call
/// always reverts, then the message will be unrelayable, and any ETH sent will be
/// permanently locked. The same will occur if the target on the other chain is
/// considered unsafe (see the _isUnsafeTarget() function).
/// @param _destination Chain ID of the destination chain.
/// @param _target Target contract or wallet address.
/// @param _message Message to trigger the target address with.
/// @return msgHash_ The hash of the message being sent, which can be used for tracking whether
/// the message has successfully been relayed.
function sendMessage(uint256 _destination, address _target, bytes calldata _message) external returns (bytes32);
/// @notice Relays a message that was sent by the other CrossDomainMessenger contract. Can only
/// be executed via cross-chain call from the other messenger OR if the message was
/// already received once and is currently being replayed.
/// @param _id Identifier of the SentMessage event to be relayed
/// @param _sentMessage Message payload of the `SentMessage` event
function relayMessage(Identifier calldata _id, bytes calldata _sentMessage) external payable;
- Create list of RPCs for each chain
- Create list of Inbox contracts for each chain
- Create
ChainRelay
struct that is instantiated for each chain- Listens to the RPC for that chain for SentMessage events
- Construct a
relayMessage
transaction for the target chain - Send the transaction to the target chain with that chain's RPC
- Use Tokio to create a
ChainRelay
for each chain