Currencies28583
Market Cap$ 2.32T+1.72%
24h Spot Volume$ 52.14B-17.7%
BTC Dominance50.26%+0.25%
ETH Gas7 Gwei
Cryptorank
CryptoRankNewsHow to Bridg...

How to Bridge to Mantle?


How to Bridge to Mantle?
Jul, 26, 2023
6 min read
by Watcher.Guru
How to Bridge to Mantle?

Guide: How to Bridge to Mantle?

With the rapid increase in blockchain adoption, the need for efficient and cost-effective solutions that can enhance transaction speeds and reduce costs has never been more urgent.

This is particularly true for the Ethereum network, where high gas fees are a significant user concern.

One such solution is the Mantle Network, a Layer-2 (L2) solution that offers a unique modular architecture for efficient Ethereum scaling. This guide delves into the steps you can take to bridge to the Mantle Network Testnet.

Also read: How to Bridge Polygon to Ethereum?

How to Bridge to Mantle?

Bridging to Mantle: A Brief Overview

Bridging assets from Ethereum to the Mantle Network Testnet is a streamlined process.

This process is facilitated by the official Mantle bridge, which offers a wide range of token compatibility, making it an appealing option for users seeking to enhance their transaction speeds while reducing gas fees.

The Mantle Network Testnet is a significant Layer 2 solution designed to ensure security, high transaction throughput, and lower gas fees, carving a promising path in the landscape of Ethereum-based blockchain technology.

What is Mantle Network?

Mantle Network is an Ethereum scaling solution designed to be Ethereum Virtual Machine (EVM)-compatible, facilitating the seamless execution of Ethereum’s tools and contracts.

It integrates an optimistic roll-up protocol and an innovative data availability solution to ensure security and cost-effectiveness.

How to Bridge to Mantle?

Being a Layer-2 (L2) solution, Mantle saves on Ethereum’s gas fees and increases transaction throughput.

Its modular approach separates transaction execution, consensus, settlement, and storage tasks, enhancing the user experience through lower gas fees, faster transactions, and higher throughput.

How to Bridge Assets to the Mantle Network Testnet

The process of bridging assets from Ethereum to the Mantle Network Testnet involves using the official Mantle bridge, which connects wallets such as MetaMask, and Coinbase, among others.

It also offers wide-ranging token compatibility, including WETH, USDC, USDT, and DAI.

Here’s a simplified guide on how to add a mantle testnet to MetaMask and bridge assets:

  1. Visit the official Mantle bridge and link your MetaMask or Web3 wallet.
  2. Choose the token and the amount you want to bridge from Goerli Ethereum testnet to Mantle.
  3. Specify the amount you wish to bridge and click ‘Approve’.
  4. Follow the instructions on your wallet, and your funds will be bridged to the Mantle Testnet promptly.

Bridging Fees on Mantle Network

The bridging fees for transferring assets from Ethereum to the Mantle Network Testnet are essentially negligible.

The Mantle Network Testnet operates on a testnet environment, and the gas fees, which typically impact transaction costs, are paid using Goerli ETH, which carries no real-world value.

Hence, the costs associated with bridging transactions are zero in real terms.

How to Bridge to Mantle

Creating an EVM-Compatible Bridge on Mantle

An EVM-compatible bridge is a blockchain interoperability solution that allows two or more blockchain networks to communicate and transfer assets and data between each other.

The bridge is designed to work with blockchain networks compatible with the Ethereum Virtual Machine (EVM), allowing the bridge to interact with other EVM-compatible networks without significant changes to the underlying code.

The EVM-compatible bridge consists of a smart contract on the source network and a corresponding smart contract on the destination network.

Additionally, the source network’s smart contract holds the assets being transferred, while the destination network’s smart contract represents the assets on the destination network.

Steps to Create an EVM-Compatible Bridge on Mantle

Prerequisites

To develop the smart contracts, make sure you have Node.js (>14) and npm installed on your local machine.

To check your Node version, run the following command in your terminal:

node -v

Step 1: Create a Node Project

To create a new node project, navigate to your command line and type the following:

mkdir my-bridge   
cd my-bridge  
npm init -y

Step 2: Create a Hardhat Project

In your terminal, run the following commands:

npm install --save-dev hardhat  
npx hardhat

You should then see a welcome message and options on what you can do. Use your “arrow keys” to navigate the small menu and select “Create a JavaScript Project” by clicking “Enter”.

Step 3: Install OpenZeppelin Contracts Package

After successfully configuring your Hardhat development environment, install the OpenZeppelin contracts package. We will import this package later in our smart contracts.

npm install @openzeppelin/contracts

Step 4: Create Smart Contracts

We will create two .solidity files: ERC20Token.sol for the Ethereum side of the bridge, and ERC20BurnableToken.sol for the Mantle side of the bridge.

ERC20 Token on Ethereum Testnet:

pragma solidity ^0.8.0;  

import "hardhat/console.sol";  
import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";  

contract TokenEthTestnet is ERC20 {  
    constructor(  
        uint256 _initialSupply  
    ) ERC20("TokenEthTestnet", "TET") {  
        _mint(msg.sender, _initialSupply * (10**uint256(10)));  
        console.log("Tokens are successfully minted %s", _initialSupply);  
        console.log("Contract deployed! Tokens sent to %s", msg.sender);  
    }  
}

ERC20 Token on Mantle Testnet:

// SPDX-License-Identifier: MIT  
pragma solidity ^0.8.0;  

import "hardhat/console.sol";  

import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";  
import {ERC20Burnable} from "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol";  

contract TokenMantleTestnet is ERC20, ERC20Burnable {  
    address bridge;  

    constructor(address _bridge) ERC20("TokenMantleTestnet", "TMT") {  
        bridge = _bridge;  
    }  

    modifier onlyBridge() {  
        require(  
            bridge == msg.sender,  
            "TokenMantleTestnet: only bridge can call this method"  
        );  
        _;  
    }  

    function mint(address _recipient, uint256 _amount)  
        public  
        virtual  
        onlyBridge  
    {  
        _mint(_recipient, _amount);  
        console.log("Tokens minted for %s", _recipient);  
    }  

    function burnFrom(address _account, uint256 _amount)  
        public  
        virtual  
        override(ERC20Burnable)  
        onlyBridge  
    {  
        super.burnFrom(_account, _amount);  
        console.log("Tokens burned successfully from %s", _account);  
    }  
}

Step 5: Connect MetaMask & Mantle to Your Project

Now that we’ve created a smart contract, it’s time to connect it with the Mantle Testnet.

Additionally, we can safely store our private key in an environmental file to allow our program to send transactions from your virtual wallet.

To use the env file, install the dotenv package in your project directory by running:

npm install dotenv --save

Then, create a .env file in your project’s root directory (Main Folder), and add your MetaMask private key.

Step 6: Update hardhat.config.js

We’ve added several dependencies and plugins so far. Now we need to update hardhat.config.js so that your project knows all the configurations to deploy the contract.

Step 7: Write the Deployment Script

Now it’s time for you to write the contract deploy script after completing your contract and configuration file.

Step 8: Deploy the Contract

We’re finally ready to deploy our smart contract!

Navigate back to the root of your project directory and in the command line run:

npx hardhat run ./scripts/deployOrigin.js --network origin

npx hardhat run ./scripts/deployDestination.js --network mantle-testnet

Step 9: Confirm the Contract Deployment

With our contract deployment complete, let’s head over to Mantle Explorer to verify the successful deployment of our contract.

Additionally, paste your smart contract address in the search box and you will get the details about the same.

How to Bridge to Mantle

Conclusion

In conclusion, in this tutorial, we’ve learned how to create and deploy smart contracts required to bridge assets between Ethereum Testnet and Mantle Testnet.

This serves as a foundation to build a dApp with a frontend and a backend to execute the full functionality of a bridge.

With its commitment to security, high transaction throughput, and lower gas fees, the Mantle Network is an exciting development in the landscape of Ethereum-based blockchain technology.

Read the article at Watcher.Guru

Read More

How to Buy Bitcoin Under 18?

How to Buy Bitcoin Under 18?

Crypto 101: How to Buy Bitcoin Under 18? So, you’re under 18 and you really want to g...
May, 02, 2024
2 min read
by Watcher.Guru
What is Crypto AI Project Grass?

What is Crypto AI Project Grass?

Your guide: what is crypto AI project grass? Are you looking for extra ways to earn i...
May, 02, 2024
2 min read
by Watcher.Guru
CryptoRankNewsHow to Bridg...

How to Bridge to Mantle?


How to Bridge to Mantle?
Jul, 26, 2023
6 min read
by Watcher.Guru
How to Bridge to Mantle?

Guide: How to Bridge to Mantle?

With the rapid increase in blockchain adoption, the need for efficient and cost-effective solutions that can enhance transaction speeds and reduce costs has never been more urgent.

This is particularly true for the Ethereum network, where high gas fees are a significant user concern.

One such solution is the Mantle Network, a Layer-2 (L2) solution that offers a unique modular architecture for efficient Ethereum scaling. This guide delves into the steps you can take to bridge to the Mantle Network Testnet.

Also read: How to Bridge Polygon to Ethereum?

How to Bridge to Mantle?

Bridging to Mantle: A Brief Overview

Bridging assets from Ethereum to the Mantle Network Testnet is a streamlined process.

This process is facilitated by the official Mantle bridge, which offers a wide range of token compatibility, making it an appealing option for users seeking to enhance their transaction speeds while reducing gas fees.

The Mantle Network Testnet is a significant Layer 2 solution designed to ensure security, high transaction throughput, and lower gas fees, carving a promising path in the landscape of Ethereum-based blockchain technology.

What is Mantle Network?

Mantle Network is an Ethereum scaling solution designed to be Ethereum Virtual Machine (EVM)-compatible, facilitating the seamless execution of Ethereum’s tools and contracts.

It integrates an optimistic roll-up protocol and an innovative data availability solution to ensure security and cost-effectiveness.

How to Bridge to Mantle?

Being a Layer-2 (L2) solution, Mantle saves on Ethereum’s gas fees and increases transaction throughput.

Its modular approach separates transaction execution, consensus, settlement, and storage tasks, enhancing the user experience through lower gas fees, faster transactions, and higher throughput.

How to Bridge Assets to the Mantle Network Testnet

The process of bridging assets from Ethereum to the Mantle Network Testnet involves using the official Mantle bridge, which connects wallets such as MetaMask, and Coinbase, among others.

It also offers wide-ranging token compatibility, including WETH, USDC, USDT, and DAI.

Here’s a simplified guide on how to add a mantle testnet to MetaMask and bridge assets:

  1. Visit the official Mantle bridge and link your MetaMask or Web3 wallet.
  2. Choose the token and the amount you want to bridge from Goerli Ethereum testnet to Mantle.
  3. Specify the amount you wish to bridge and click ‘Approve’.
  4. Follow the instructions on your wallet, and your funds will be bridged to the Mantle Testnet promptly.

Bridging Fees on Mantle Network

The bridging fees for transferring assets from Ethereum to the Mantle Network Testnet are essentially negligible.

The Mantle Network Testnet operates on a testnet environment, and the gas fees, which typically impact transaction costs, are paid using Goerli ETH, which carries no real-world value.

Hence, the costs associated with bridging transactions are zero in real terms.

How to Bridge to Mantle

Creating an EVM-Compatible Bridge on Mantle

An EVM-compatible bridge is a blockchain interoperability solution that allows two or more blockchain networks to communicate and transfer assets and data between each other.

The bridge is designed to work with blockchain networks compatible with the Ethereum Virtual Machine (EVM), allowing the bridge to interact with other EVM-compatible networks without significant changes to the underlying code.

The EVM-compatible bridge consists of a smart contract on the source network and a corresponding smart contract on the destination network.

Additionally, the source network’s smart contract holds the assets being transferred, while the destination network’s smart contract represents the assets on the destination network.

Steps to Create an EVM-Compatible Bridge on Mantle

Prerequisites

To develop the smart contracts, make sure you have Node.js (>14) and npm installed on your local machine.

To check your Node version, run the following command in your terminal:

node -v

Step 1: Create a Node Project

To create a new node project, navigate to your command line and type the following:

mkdir my-bridge   
cd my-bridge  
npm init -y

Step 2: Create a Hardhat Project

In your terminal, run the following commands:

npm install --save-dev hardhat  
npx hardhat

You should then see a welcome message and options on what you can do. Use your “arrow keys” to navigate the small menu and select “Create a JavaScript Project” by clicking “Enter”.

Step 3: Install OpenZeppelin Contracts Package

After successfully configuring your Hardhat development environment, install the OpenZeppelin contracts package. We will import this package later in our smart contracts.

npm install @openzeppelin/contracts

Step 4: Create Smart Contracts

We will create two .solidity files: ERC20Token.sol for the Ethereum side of the bridge, and ERC20BurnableToken.sol for the Mantle side of the bridge.

ERC20 Token on Ethereum Testnet:

pragma solidity ^0.8.0;  

import "hardhat/console.sol";  
import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";  

contract TokenEthTestnet is ERC20 {  
    constructor(  
        uint256 _initialSupply  
    ) ERC20("TokenEthTestnet", "TET") {  
        _mint(msg.sender, _initialSupply * (10**uint256(10)));  
        console.log("Tokens are successfully minted %s", _initialSupply);  
        console.log("Contract deployed! Tokens sent to %s", msg.sender);  
    }  
}

ERC20 Token on Mantle Testnet:

// SPDX-License-Identifier: MIT  
pragma solidity ^0.8.0;  

import "hardhat/console.sol";  

import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";  
import {ERC20Burnable} from "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol";  

contract TokenMantleTestnet is ERC20, ERC20Burnable {  
    address bridge;  

    constructor(address _bridge) ERC20("TokenMantleTestnet", "TMT") {  
        bridge = _bridge;  
    }  

    modifier onlyBridge() {  
        require(  
            bridge == msg.sender,  
            "TokenMantleTestnet: only bridge can call this method"  
        );  
        _;  
    }  

    function mint(address _recipient, uint256 _amount)  
        public  
        virtual  
        onlyBridge  
    {  
        _mint(_recipient, _amount);  
        console.log("Tokens minted for %s", _recipient);  
    }  

    function burnFrom(address _account, uint256 _amount)  
        public  
        virtual  
        override(ERC20Burnable)  
        onlyBridge  
    {  
        super.burnFrom(_account, _amount);  
        console.log("Tokens burned successfully from %s", _account);  
    }  
}

Step 5: Connect MetaMask & Mantle to Your Project

Now that we’ve created a smart contract, it’s time to connect it with the Mantle Testnet.

Additionally, we can safely store our private key in an environmental file to allow our program to send transactions from your virtual wallet.

To use the env file, install the dotenv package in your project directory by running:

npm install dotenv --save

Then, create a .env file in your project’s root directory (Main Folder), and add your MetaMask private key.

Step 6: Update hardhat.config.js

We’ve added several dependencies and plugins so far. Now we need to update hardhat.config.js so that your project knows all the configurations to deploy the contract.

Step 7: Write the Deployment Script

Now it’s time for you to write the contract deploy script after completing your contract and configuration file.

Step 8: Deploy the Contract

We’re finally ready to deploy our smart contract!

Navigate back to the root of your project directory and in the command line run:

npx hardhat run ./scripts/deployOrigin.js --network origin

npx hardhat run ./scripts/deployDestination.js --network mantle-testnet

Step 9: Confirm the Contract Deployment

With our contract deployment complete, let’s head over to Mantle Explorer to verify the successful deployment of our contract.

Additionally, paste your smart contract address in the search box and you will get the details about the same.

How to Bridge to Mantle

Conclusion

In conclusion, in this tutorial, we’ve learned how to create and deploy smart contracts required to bridge assets between Ethereum Testnet and Mantle Testnet.

This serves as a foundation to build a dApp with a frontend and a backend to execute the full functionality of a bridge.

With its commitment to security, high transaction throughput, and lower gas fees, the Mantle Network is an exciting development in the landscape of Ethereum-based blockchain technology.

Read the article at Watcher.Guru

Read More

How to Buy Bitcoin Under 18?

How to Buy Bitcoin Under 18?

Crypto 101: How to Buy Bitcoin Under 18? So, you’re under 18 and you really want to g...
May, 02, 2024
2 min read
by Watcher.Guru
What is Crypto AI Project Grass?

What is Crypto AI Project Grass?

Your guide: what is crypto AI project grass? Are you looking for extra ways to earn i...
May, 02, 2024
2 min read
by Watcher.Guru