Zero to Hero: Getting Started on Mantle Testnet
02/01/2315 min read
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:
- Adding Mantle Testnet to MetaMask
- Acquiring $BIT from the Testnet Faucet
- Bridging your tokens to Mantle
- Connecting directly to a Mantle RPC Endpoint
- Using the Mantle SDK to fetch L1 gas price
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.
Mantle TestnetNew RPC URL:
Block Explorer URL:
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.
- 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.
- Visit https://faucet.testnet.mantle.xyz, verify your humanity, and enter your Ethereum address. You can mint up to 1,000 $BIT.
- 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.
- You should see $BIT in your wallet shortly! If not, make sure you’ve imported the Goerli testnet $BIT token contract to MetaMask:
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.
- Visit https://bridge.testnet.mantle.xyz and connect your wallet to Goerli.
- $BIT is the native token on Mantle, so let’s start by bridging some $BIT. Input your desired amount and click deposit.
- 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:
- In MetaMask, add Mantle Testnet using ChainList. You should see your $BIT amount displayed as the native balance.
- Click here to see a list of ERC20 tokens supported by the bridge.
- If you’ve bridged $gETH you will need to import Mantle’s WETH contract to see it under your asset list:
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.
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.
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 👋