scroll-tech / scroll-guides

MIT License
47 stars 213 forks source link

Comprehensive Cross-Chain Interaction Tutorial Using Scroll Messenger #10

Open LamsyA opened 8 months ago

LamsyA commented 8 months ago

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.

DTopGoat commented 8 months ago

Video tutorial or a medium thread?

Traicye commented 8 months ago

Can the tutorial be added as a comment under this issue?

Traicye commented 8 months ago

This illustrates sending a message from an L1 smart contract to an L2 smart contract using Scroll Messenger.

Prerequisites:

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:

LamsyA commented 8 months ago

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.