Deploying on Metis

In case when you need higher limits of the public RPC endpoint, there are two options: 1. Setting up a private RPC endpoint using a provider such as Nodies or BlastAPI 2. Setting up a replica node

Using Solidity Language and Remix IDE

Solidity is a free programming language you can use for deploying smart contracts. The Remix IDE helps us easily deploy our projects in a web-based programming environment. Before using the Remix IDE, you need to take a few steps and configure your MetaMask account. The MetaMask wallet is used as a tool to provide an account address and see the results.

Make sure you’re on the Metis Testnet in MetaMask. Otherwise, you can simply switch to the Metis HoleskyTestnet using the MetaMask networks section.

You would have some Metis test tokens in your account if you got some using the instructions given in this section. Otherwise, you can follow the instructions to get Metis test tokens and bridge them from L1 to the Metis Testnet.

What is OpenZeppelin?

OpenZeppelin is an open-source and powerful platform designed to offer simplicity and secure smart contract deployment. When dealing with Ethereum smart contract deployment, you need to write your code quickly and automatically. OpenZeppelin platform provides everything for you to create and automate Web 3 applications. Please refer to the OpenZeppelin setup guide to configure everything if you haven’t done the configuration process. You can easily install the OpenZeppelin library with a terminal command.

Method 1: How to Use OpenZeppelin to Prepare Smart Contracts?

Step 1

Go to the OpenZeppelin Contracts Wizard page to start the first project. You will have an interactive generator that offers simplicity to generating your desired code.

Choose the settings you want to be applied and use a name and symbol for your contract.

You can even choose between ERC20 and ERC721 and check/uncheck several features to get your desired output. We set the test token to be mintable and burnable.

Step 2

After doing the settings and preparing your code, you have two options. You can copy the code to use on any deployment platform, or you have the option to click on “Open in Remix” to proceed to the Remix development environment.

Step 3

You can select the Solidity compiler from the left to compile the smart contract. Use Auto-compile to perform everything with peace of mind, and after doing your desired settings, you can click on the “Compile contract” button.

Once you click the compile button, it works on your code and shows a message indicating that the compilation process was successful. Note that you can select the Solidity compiler version and EVM version. We check the optimization option to have cheaper transactions.

Step 4

Working with the Remix IDE is really simple. You can do the compilation process in the blink of an eye and proceed to the next step. Select the “Deploy and run transactions” option from the left, and you can start deploying your smart contract using a wide range of possibilities here.

We will deploy our smart contract on a testnet using a MetaMask account. So, make sure your MetaMask account is configured and ready to use.

First, select the environment you want to deploy your smart contract. Choose the “Injected Provider” option from the environment menu. A pop-up window will appear, and you will be able to connect the Remix IDE to your desired MetaMask account.

Once you have connected to Remix IDE, you can see that your account address has been successfully added to the Remix IDE.

Step 5

After doing all the settings, you can click on the “Deploy” button. Be careful your MetaMask network must be switched to the Metis Testnet, and you must have enough Metis tokens in your account.

Click on the “Deploy” button, and you will see a MetaMask pop-up window. Confirm the deployment process to finish everything.

Step 6

If everything goes well, MetaMask shows you a success message. You can then verify your smart contract deployment.

Click on the recent activity to see the details. You can check all the details and verify your transaction. So, click on the “View on block explorer” option to open a window with detailed information about your transaction deployment.\

Method 2: Configuring Hardhat to Get a Comprehensive Environment for Deploying Contracts

Hardhat is a highly reliable deployment environment that provides a secure and simple platform to deploy smart contracts. Hardhat allows developers to run Solidity code locally, and you can get a bunch of features in an integrated platform. Hardhat needs the latest version of Nodejs, and you can install it using different options. Use the instructions given on the Node Js website to install a supported version and then you can install Hardhat and configure the environment for smart contract deployment.

Head over to and follow the instructions to install Hardhat on your system. You can easily install it on Windows, Linux, or Mac. Note that you need to install the latest version of Nodejs and Typescript on your system to run Hardhat commands without any error. More importantly, you need the npm package manager installed on your system.

Here are the required steps for configuring Hardhat, creating a project, and compiling it to be deployed on the Metis platform. We configure Hardhat for Linux (Debian-based distros), but the procedure is the same for Windows and Mac.

Step 1

After installing the latest version of Git, Nodejs, and Hardhat, create a project folder for your sample project.

Use the following commands to create a demo project and initialize git for the project. You can create a folder and then change the working directory.

$ mkdir metis-demo
$ cd metis-demo
$ git init
$ npm init -y

Step 2

If it’s a new project and you have not run Hardhat in the project folder, running Hardhat for the first time gives you the following options. Select the 3rd option to create an advanced sample project that uses Typescript. You then need to hit the enter button to initialize the project. If everything goes well, you get a message showing that creating the project was successful.

$ npx hardhat

Step 3

First, you need to open the project folder using VSCode. Then edit the project config file and add the following lines of code to it.

metis: {
url: "",
process.env.PRIVATE_KEY !== undefined ? [process.env.PRIVATE_KEY] : [],

Step 4

You need to add your account private key to the .env file in your project. Follow these steps to get your account private key.

  • Open your MetaMask and click on account details. You will be able to export your account private key and copy it to use for deploying your smart contract.

Step 5

We use a test code to deploy our first smart contract. So, let's leave it unchanged and compile it to start deploying the first smart contract.

Step 6

Use the following command to compile the smart contract. Then, you can test by using the test command. If everything is good, you can get the success message.

$ npx hardhat compile
$ npx hardhat test

Step 7

You can now deploy your smart contract using the following command.

$ npx hardhat run scripts/deploy.ts --network metis

Step 8

Let’s check the results on the Metis platform. Click on the “View account explorer” option to open the Metis Testnet explorer website.

You can explore your last transactions here and check that your last smart contract deployment was successful.

You can explore your last transactions here and check that your last smart contract deployment was successful.

Please feel free to reach out to our Help Center if you have any technical questions.

Last updated