Open LamsyA opened 6 months ago
Video tutorial or a medium thread?
Can the tutorial be added as a comment under this issue?
This illustrates sending a message from an L1 smart contract to an L2 smart contract using Scroll Messenger.
Prerequisites:
Node.js and npm installed
Basic understanding of Solidity and Ethereum development
Scroll L1 and L2 development environment set up (e.g., Hardhat, Alchemy)
Steps:
Create L1 Contract (L1Messenger.sol):
pragma solidity ^0.8.0;
contract L1Messenger {
address public l2Messenger; // Address of L2 Messenger contract
function setL2Messenger(address _l2Messenger) public {
l2Messenger = _l2Messenger;
}
function sendMessage(string memory message) public {
L2ScrollMessenger(l2Messenger).receiveMessage(message);
}
}
Create L2 Contract (L2Messenger.sol):
pragma solidity ^0.8.0;
contract L2Messenger {
string public message;
function receiveMessage(string memory _message) public {
message = _message;
}
}
Deploy Contracts:
Deploy L2Messenger on the L2 Scroll network. Get the deployed address of L2Messenger.
Deploy L1Messenger on the L1 Ethereum network. Set the l2Messenger address in L1Messenger to the deployed L2 address.
Send Message from L1: Call the sendMessage function in L1Messenger with your desired message.
Verify Message: Check the message variable in the deployed L2Messenger contract on the L2 network. The message you sent from L1 should be displayed.
I already solved this issue by providing the comprehensive guide and more scripts on how to interact with the cross-chain interaction using the scroll messenger.
Admin, kindly check this PR https://github.com/scroll-tech/scroll-guides/pull/8.
Create a comprehensive tutorial demonstrating cross-chain interaction between Layer 1 (L1) and Layer 2 (L2) Ethereum networks using Scroll Messenger. This tutorial should include detailed explanations, code examples, and step-by-step instructions for setting up, deploying, and executing cross-chain transactions.