Git Product home page Git Product logo

sepolia-to-optimism's Introduction

Sepolia to Optimism message bridge

This Hardhat project implements secure cross-domain message passing between the Sepolia and Optimism networks using Sender and Receiver smart contracts.

Source code of smartcontracts is at ./contracts

> Live test dApp < Source code of dapp in next-frontend

Features:

  • Cross-Domain Messaging. Utilizes an interface (IL1CrossDomainMessenger) to send messages across different blockchain networks (Sepolia to Optimism).

  • Event Emission. Emits a Message event in the Receiver contract to log incoming messages, including the sender, text, and nonce.

  • Nonce Management. Maintains a nonce in the Sender contract to ensure the uniqueness of each message and prevent replay attacks.

  • Access Control. Uses OpenZeppelin's Ownable contract to restrict certain functions (like pausing and unpausing the contract) to the contract owner.

  • Contract Pausability. Incorporates OpenZeppelin's Pausable contract to allow the owner to enable or disable the Sender contract's doSendMessage function.

  • Reentrancy Protection. Applies OpenZeppelin's ReentrancyGuard to the Sender contract to prevent reentrancy attacks.

  • Message Validation. Validates that the text parameter in the doSendMessage function is not empty and does not exceed a specified maximum length (256 characters).

  • Authorized Sender Check. Ensures that the Receiver contract only accepts messages from a specific authorized sender address (0x4200000000000000000000000000000000000007).

Sender Contract:

Source code

The Sender contract is responsible for sending messages from the Sepolia network to the Optimism sepolia network. It ensures each message is unique using a nonce, validates the message content, and can be paused or unpaused by the contract owner to control its functionality.

Receiver Contract:

Source code

The Receiver contract on the Optimism network handles incoming messages from the Sender contract. It logs the messages with the sender's address, message text, and nonce, and only accepts messages from a specific authorized sender address.

Summary

The Sender and Receiver smart contracts are designed to facilitate secure and controlled cross-domain messaging between the Sepolia and Optimism networks. By leveraging OpenZeppelin's libraries, the contracts implement robust security measures such as access control, reentrancy protection, and pausability. Input validation ensures message integrity, and nonce management prevents replay attacks. The Receiver contract strictly enforces that messages are only accepted from a designated authorized sender, enhancing security.

Instructions

To deploy these smartcontracts with Hardhat:

Localhost

Deploy Sender only:

npx hardhat node
npx hardhat ignition deploy ./ignition/modules/Lock.ts

Testnets

From Ethereum Sepolia to Optimism Sepolia:

# Sender contract to sepolia
npx hardhat ignition deploy ignition/modules/Sender.ts --network sepolia
# Reciever contract to optimism
npx hardhat ignition deploy ignition/modules/Receiver.ts --network optimism

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.