Zero to Hero: Getting Started on Mantle Testnet

Introducing Mantle

Mantle is an Ethereum Layer-2 (L2) scaling solution that allows for faster and cheaper transactions on the Ethereum network. If you haven’t heard, we recently launched our Testnet! That means you can now connect your dApp to Mantle in just a few steps. In this tutorial we’ll walk through:

  1. Adding Mantle Testnet to MetaMask

  2. Acquiring $BIT from the Testnet Faucet

  3. Bridging your tokens to Mantle

  4. Connecting directly to a Mantle RPC Endpoint

  5. Using the Mantle SDK to fetch L1 gas price

Just remember, if you have any questions or need support at any point in your journey, send a message in the Mantle Developer Telegram or our Discord channel. We’ll be right there with you!

This tutorial assumes you are already familiar with wallets, Goerli ETH, and adding custom tokens and networks. If you are stuck on any step, or looking for a more in-depth guide, check our Complete Onboarding Guide here.

Add Mantle Testnet to MetaMask

First, you will need to have MetaMask installed on your browser.

1. Once MetaMask is set up, click on your account icon in the top-right corner. 

2. This will open a menu. Click “Settings” near the bottom.

3. From there, click on the "Networks" tab.

4. You will see a button labeled "Add a network".

5. Click on the button “Add a network manually”, which will allow you to enter the following information.

Network Name: Mantle Testnet
New RPC URL: https://rpc.testnet.mantle.xyz
Chain ID: 5001
Currency Symbol: BIT
Block Explorer URL: https://explorer.testnet.mantle.xyz

You can now click "Save" and Mantle Network will now appear in your list of networks in MetaMask.

Now that we have our Mantle Testnet configured with MetaMask, we can move on to acquiring $BIT tokens and also gETH that will be needed for gas in various steps.

Acquiring Test $BIT

The Mantle Testnet Faucet allows developers to receive testnet $BIT to experiment with the network and deploy their own dApps.

  1. Using the faucet will require a small amount of Goerli ETH ($gETH) to cover the gas fee for minting $BIT. If you need Goerli ETH, you can use either the Paradigm or Alchemy faucets.

  2. Visit https://faucet.testnet.mantle.xyz, verify your humanity, and enter your Ethereum address. You can mint up to 1,000 $BIT.

  3. If you’re having trouble with the faucet, or need more $BIT, let us know in our developer Telegram group. We can also send $BIT directly into your Mantle testnet account.

  4. You should see $BIT in your wallet shortly! If not, make sure you’ve imported the Goerli testnet $BIT token contract to MetaMask: 0x5a94dc6cc85fda49d8e9a8b85dde8629025c42be

Bridging to Mantle

You are now ready to bridge your funds over to Mantle. In case you’re wondering, your very same wallet address is waiting for you on the other side.

  1. Visit https://bridge.testnet.mantle.xyz and connect your wallet to Goerli.

  2. $BIT is the native token on Mantle, so let’s start by bridging some $BIT. Input your desired amount and click deposit.

  3. Confirm the transactions (both on the bridge and in MetaMask).

Congratulations, your tokens are on their way to Mantle Testnet! You can confirm their arrival in two ways:

  1. In MetaMask, add Mantle Testnet using ChainList. You should see your $BIT amount displayed as the native balance.

    1. Click here to see a list of ERC20 tokens supported by the bridge.

    2. If you’ve bridged $gETH you will need to import Mantle’s WETH contract to see it under your asset list: 0xdEAddEaDdeadDEadDEADDEAddEADDEAddead1111

  2. Your tokens may still be on their way, in which case you can enter your address on the Mantle Block Explorer and click “Tokens” to view all tokens in your wallet.

Connecting to the RPC Node

Connecting to a node allows dApps to read block data and send transactions to facilitate their business logic. This isn’t limited to initiating token transfers and checking their status, but also other operations where a public record is maintained on-chain for anyone to access and verify. This role is performed by Sequencers on Mantle.

Mantle’s node API supports the JSON-RPC implementation of Ethereum. All the endpoints can be accessed by sending HTTP requests, or establishing a WebSocket connection. More on that here.

For simplicity, let’s look at the rollup_gasPrices endpoint, which is one of the most commonly invoked since checking the current gas price is essential to sending valid transactions. The simplest way to use it would be to send HTTP requests to a node. Here’s a sample request that uses the command line tool Curl to fetch the current gas price on L1 and L2.

Request

Response

Notice how the gas price on L1 is orders of magnitude higher than that on L2! Head over to the tech docs to find more reference on other API endpoints. Our GitHub is also a good place to get started.

Using the SDK

The Mantle SDK is an easy way to integrate the features of Mantle to your dApp. It is a TypeScript library of useful methods and tools that make block data handling and chain interactions more convenient. For instance, tasks such as generating Merkle proofs by passing state data, generating Merkle-Patricia trie proofs for wallet accounts or storage slots, etc.

Let’s look at the getL1GasPrice method that fetches the current L1 gas price from a node provider.

1. Once you’ve created and initialized a project directory, you can install the SDK package using the following command.

2. Next, create a test JS script and initialize an ethers and an SDK object. Then call the getL1GasPrice method with the SDK object passing an L2 node provider address as parameter. We’ll call the Mantle Testnet RPC, but the same works for a locally deployed node as well.

3. Finally, run the script using the node .js command to see the result. The gas price is in wei.

Feel free to explore the SDK docs that contain descriptions for all available SDK methods.

Looking for more examples? You can refer to this compilation of tutorials that use the SDK to demonstrate flows such as bridging assets between Ethereum and Mantle, and more.

What’s Next?

You’re now one step closer to connecting your dApp to Mantle! If you’re building a dApp (or thinking about it!), fill out this form to let us know what you’re working on and how we can support you. It will also make sure you hear about our future grants and developer success programs. Once you’ve deployed on Mantle, let us know on our Developer Telegram so we can celebrate alongside you!

Until next time đź‘‹

The End


Subscribe to Mantle Network
Receive the latest updates directly to your inbox.
Mint this entry as an NFT to add it to your collection.
Verification
This entry has been permanently stored onchain and signed by its creator.