How to Deploy Your Smart Contract on Mantle Network?
Published: 2023-06-06 13:30:48



## Understanding the Process:

Deploying a smart contract may appear complex, but with the right tools and understanding, it becomes a straightforward process. In this guide, we will walk you through the essential steps for deploying contracts on the [Mantle network](https://www.mantle.xyz/). We will cover the necessary tools, contract compilation, deployment, and interacting with your deployed contract.

To follow along, we will be using the Remix IDE, accessible through any browser with MetaMask installed. Please install MetaMask, acquire some $BIT tokens from the faucet. Once you have completed these steps, you'll be ready for the tutorial.

## Familiarizing Yourself with the Remix IDE Interface:

Before we begin, let's familiarize ourselves with the Remix IDE interface, which consists of four main components:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f68mcac8bnssvvjjnr1h.png)


1. Side Panel: This panel allows you to switch between different views such as file explorer, contract compiler, deployment interface, and debugger.
2. Icon Panel: Located on the side, it acts as a menu to change the contents of the side panel.
3. Main Panel: This area is dedicated to editing contracts and debugging.
4. Terminal: It provides an interface to view execution results and traces.

## Step-by-Step Guide to Deploying Your Smart Contract on Mantle Network:

Now that we understand the interface, let's proceed with deploying our contract. By default, Remix provides three contracts: Storage, Owner, and Ballot. For the purpose of this tutorial, we will focus on the Storage.sol contract.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/okwy9t8ljc7q3w3bvjqp.png)

The Storage.sol contract is a simple contract with two actions:

1. "store": This action stores a number on-chain.
2. "retrieve": This action reads the stored number.

Since our focus is on deployment, we will use the Storage.sol contract. To compile the contract, click on the Solidity icon in the left navigation bar and then click "compile". Any errors, if present, will be displayed at the bottom.

Once the contract is compiled, we can proceed to deploy it on the Mantle Testnet. Click on the deploy icon on the left, select "Injected Provider — MetaMask" as the environment, and click "Deploy" (ensure that your MetaMask network is set to "Mantle Testnet").

A deployment confirmation popup will appear. Click "Confirm" to deploy your contract on the Mantle Testnet. Congratulations! You have successfully deployed a contract on Mantle Testnet! The "deployed contracts" section will now provide more information, and you can interact with the contract directly on Remix.

## Exploring How to Interact with Your Deployed Smart Contract on Mantle Network:


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/25a491iwnhvih99hrebw.png)



Let's now interact with the deployed contract using Remix. Enter a number in the textbox next to the "store" function and click the "store" button. Since this function modifies the state, you will need to pay some $BIT tokens to perform the transaction.

Once the transaction is processed, clicking on the "retrieve" function will display the previously stored number.

## Exploring the Mantle Block Explorer to Gather Information about Your Contract Deployment:


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2gysxf4otfjohaxy2i1q.png)



To gain further insights into our contract and its deployment, we can utilize the Mantle block explorer. Return to the deployment interface in Remix, copy the contract address, and navigate to the Mantle explorer. Paste the address in the search bar and click "Search".

It may take a few moments for the information to update after the contract deployment. Here, you will find details of your deployment transaction, as well as any transactions performed while interacting with the contract through Remix.

Inspecting the contract address on the explorer will show the two transactions that occurred:

1. Contract creation transaction.
2. Transaction to change the stored value.

Feel free to explore the explorer further by copying your MetaMask wallet address to check various transactions, deposits, withdrawals, and more!

Have a look into the [video demonstration by ETHGlobal](https://www.youtube.com/watch?v=kJKn597f-Gs)

## Celebrating Your Success in Deploying Your Contract on Mantle Testnet:

> Congratulations on successfully deploying your first contract on the Mantle Testnet!

We have covered the essential steps for onboarding, including setting up MetaMask, adding Mantle Testnet, and acquiring gETH and $BIT tokens for smart contract deployment. After deployment, we demonstrated how to interact with the contract using a state-mutating function to store a value.

Stay tuned and follow us for more advanced techniques to build, test, deploy, and interact with your contracts using tools like Forge and ethers.js.