Coder Social home page Coder Social logo

hhio618 / mantle Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mantlenetworkio/mantle

0.0 1.0 0.0 83.46 MB

Mantle is a high-performance Ethereum layer-2 network built with modular architecture delivering low fees and high security.

Home Page: https://www.mantle.xyz

License: MIT License

Shell 0.25% JavaScript 3.09% Ruby 0.01% Python 0.05% C 4.67% Java 0.21% Go 74.13% Assembly 0.44% TypeScript 7.96% Makefile 0.17% HTML 0.08% NSIS 0.16% M4 0.18% Dockerfile 0.09% Sage 0.21% Solidity 8.31%

mantle's Introduction

Website    |    Tech Docs




Introduction

Mantle is a suite of Ethereum scaling solutions including an optimistic rollup and ZK rollup built using an iterative modular chain approach, and supported by BitDAO’s native token $BIT.

It is designed to bolster support for hyper-scaled throughput decentralized applications (dApps) — from derivatives decentralized exchanges (DEXs), to gaming, to operations of decentralized autonomous organizations (DAOs).


Goals

Layer 2 rollups are built to address the scaling limitations of Ethereum by taking transaction processing to a separate execution layer, but this inevitably exposes users to the high gas fees and limited throughput on Layer 1.

Mantle's modular architecture helps achieve greater network efficiency for resources at hand, while maintaining the same level of security for all network actors. Increased network performance also enables better fraud proof and ZK proof technology, essentially unlocking the true potential of L2 rollups.

Different parts of the Mantle tech stack are specialized to tackle specific issues.

  • Decentralized Sequencer: A permissionless set of L2 block producers
  • Data Availability: Implementing EigenDA, an innovative re-staking solution that leverages Ethereum's validator network to bring the security of L1 to L2
  • EVM-level Fraud Proofs: Improved fraud proofs that are evaluated using EVM-level instructions

We encourage you to check out the Mantle tech docs to learn more about the inner workings of Mantle.


Quick Start

Useful Addresses

Name Value
Testnet Token Faucet https://faucet.testnet.mantle.xyz/
Mantle Testnet Bridge https://bridge.testnet.mantle.xyz/
Mantle Explorer https://explorer.testnet.mantle.xyz/
Mantle Node RPC URL https://rpc.testnet.mantle.xyz/
Chain ID 5001

Set up Local Environment

Setting up local L1 and L2 nodes may be particularly useful for testing out Mantle SDK methods.

  1. Make sure your system has the following tools set up and running.

    • Git - to fetch node software
    • Node.js - to run node instances
    • Yarn - for dependency management
  2. Run L1 and L2 node instances using the following commands.

 git clone https://github.com/mantlenetworkio/mantle.git
 cd mantle/ops
 make up
 # check status
 make ps

Find more details on setting up your local development environment here in this README.md.

dApps need to connect to nodes for fetching block data and sending transactions to the Mantle network. Our JSON-RPC API supports HTTPS and WebSocket connections.

Service URL
RPC https://rpc.testnet.mantle.xyz/
WebSocket wss://ws.testnet.mantle.xyz

Using the Mantle SDK

You can use npm or yarn package managers to download and install the @mantleio/sdk package. We'll use yarn in this example.

  1. Set up a project directory.
mkdir MantleSDK
cd MantleSDK
npm init --yes
  1. Download and install the SDK package using this command.
yarn add -D @mantleio/sdk
  1. Create a .js script and get started by making a request, for instance, to fetch the current L1 gas price.
const ethers = require("ethers")
const mantle = require("@mantleio/sdk")

const l2RpcProvider = new ethers.providers.JsonRpcProvider("https://rpc.testnet.mantle.xyz")

async function main() {

    console.log(await mantle.getL1GasPrice(l2RpcProvider))
}

main();
  1. Run your script using the node <filename>.js command to see the output.

Feel free to browse through our compilation of tutorials that use the Mantle SDK to demonstrate common functionality such as bridging assets between Mantle and Ethereum, and more.

The SDK docs provide complete reference of all the methods available as part of the Mantle SDK to facilitate interaction between applications and Mantle network.


Using the Node RPC API

You can invoke the API endpoints by sending curl requests as well. Let's look at an example of a simple curl request being sent to invoke the rollup_gasPrices method that returns a JSON object containing the L1 and L2 gas prices used by a Sequencer to calculate the transaction gas fees.

Want to get a better understanding of how gas fees are calculated on Mantle? Check out the section on fee basics in the tech docs.

curl -X POST --data '{"jsonrpc":"2.0","method":"rollup_gasPrices","params":[],"id":1}' <node url>

The response is of the form:

{
  "jsonrpc":"2.0",
  "id":1,
  "result":{
    "l1GasPrice":"0x254aa66732",
    "l2GasPrice":"0xf3792"
  }
}

Check out DEVELOP.md for more detailed information on getting started with developing your apps using Mantle.


Spin up a Verifier Node

There are multiple roles associated with Mantle nodes. Rollup Verifiers mainly sync rollup data from Mantle's trusted Sequencer (to be decentralized in the future!). dApp builders who run their own verifier nodes have the benefit of being able to simulate L2 transactions, among other advantages, and have ready access to them without rate-limiting (as opposed to public RPCs).

Here's a tutorial describing the process of deploying a verifier node.


Directory Structure

root
├── packages
│   ├── common-ts: Common tools for building apps in TypeScript
│   ├── contracts: L1 and L2 smart contracts for Mantle
│   ├── core-utils: Low-level utilities that make building Mantle easier
│   ├── data-transport-layer: Service for indexing Mantle-related L1 data
│   ├── fault-detector: Service for detecting Sequencer faults
│   ├── message-relayer: Tool for automatically relaying L1<>L2 messages in development
│   ├── replica-healthcheck: Service for monitoring the health of a replica node
│   └── sdk: provides a set of tools for interacting with Mantle

~~ Production ~~
├── batch-submitter: Service for submitting batches of transactions and results to L1
├── mt-batcher: Service for submitting batches of transactions to EigenDA
├── mt-challenger: EigenDA data fraud proof
├── bss-core: Core batch-submitter logic and utilities
├── gas-oracle: Service for updating L1 gas prices on L2
├── integration-tests: Various integration tests for the Mantle network
├── l2geth: Mantle client software, a fork of geth v1.9.10  (deprecated for BEDROCK upgrade)
├── l2geth-exporter: A prometheus exporter to collect/serve metrics from an L2 geth node
├── op-exporter: A prometheus exporter to collect/serve metrics from an Mantle node
├── proxyd: Configurable RPC request router and proxy
├── technical-documents: audits and post-mortem documents

How to Contribute

Read through CONTRIBUTING.md for a general overview of our contribution process. Then check out our list of good first issues to find something fun to work on!


License

Code forked from optimism under the name optimism is licensed under the GNU GPLv3 in accordance with the original license.

All other files within this repository are licensed under the MIT License unless stated otherwise.

mantle's People

Contributors

bradyjoestar avatar guoshijiang avatar shidaxi avatar curryxbo avatar kukoomomo avatar sha3ns avatar byteflyfunny avatar chengwenxi avatar lagougou avatar fletcherman avatar lqs0317 avatar agnarsong avatar aodhgan avatar ethandavionlabs avatar hsutaiyu avatar

Watchers

 avatar

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.