89DEVs

Deploy to Ethereum Testnet: Ropsten, Kovan, Rinkeby, Goerli

Before deploying a smart contract to the Ethereum main net it is a good idea to deploy it first to one of the test nets in the Ethereum network. On the test net, the contract can be tested without affecting real funds and it also saves gas fees because the contract can be deployed for free. Especially since the congestion has risen, the gas price soared as well, which can make deploying a contract to the main net quite costly. We will learn later how to acquire test funds for the test net for free. 

Ropsten, Kovan, Rinkeby and Goerli

There are four test nets in Ethereum named after places in Stockholm, Sweden: Ropsten, Kovan, Rinkeby, and Goerli. Ropsten is actually a metro station in Stockholm and is also the name of the test net we want to use for this tutorial.
Contracts can be deployed to the Ethereum test nets Ropsten, Kovan, Rinkeby, and Goerli.
The difference between the test nets is the consensus algorithm they are using. The Ropsten test net is using the proof of work consensus, while Rinkeby is using proof of authority for example. Since we want to simulate our smart contract in an environment that's as similar as possible to the mainnet we will use the Ropsten test net.

Alternative chains

An alternative to the Ethereum network can be the deployment of Solidity smart contracts to alternative chains. We have explained already how to deploy smart contracts to the Binance Smart Chain (BSC), Polygon Network and Avalanche Network. Each of these networks has different Pros and Cons and should be chosen based on the requirements of the project. All these chains have their own test net like the Mumbai test net for Polygon or the FUJI test net for Avalanche.

Deploy to the Ethereum test net

How can we deploy our smart contract to the Ethereum test net? The deployment is a three-step process: First, we need to have an Ethereum wallet like MetaMask to pay for the deployment fees, then we have to acquire the necessary funds and lastly, we can compile and deploy the Solidity smart contract to the blockchain. In this tutorial, we will use the MetaMask wallet to deploy a HelloWorld test contract to the Ropsten test net. MetaMask is already configured for all of the four test nets so we don't have to add the networks like we had to do on other chains. The next step is to acquire test funds.

How to get test ETH

To receive test ether on the Ropsten test net we have to use a so-called faucet. A faucet is basically a web app that dispenses free Ether. Unfortunately, the test Ethers are completely worthless, we can't use them on the mainnet. Nonetheless, they are useful to pay for the gas fees during the deployment of our smart contract. Each test net has its own faucet website and there are usually multiple faucets per test net to provide redundancy. get test ether ropsten fauceth We will use FauceETH which provides test funds for multiple chains without social media verification. So we can just copy our address from MetaMask to the clipboard and then paste it into the faucet website. We then have to select the right chain, in our case the Ropsten test net, pass the captcha, and then request the funds. It might take a few minutes until the test ETH appear in our MetaMask wallet.

Compile and Deploy contract

The next step is to connect our IDE to our wallet. In this tutorial, we will use Remix as beginner-friendly IDE and MetaMask an easy-to-use wallet. To connect remix and MetaMask we open our smart contract code in remix, compile it and then go to the Deploy and Run tab (see screenshot below). There we can choose Injected Web3 under the Environment setting. This allows us to use MetaMask with remix and if it is the first time that we chose this setting a confirmation is required as seen below. After confirming the connection we can use Injected Web3 to deploy the contract with MetaMask. connect remix and metamask Now we can hit the Deploy button (orange or red depending on the pay ability of the contract) and another confirmation is needed to Deploy the contract. In the confirmation popup, we can also see an estimate of the required gas fees. We can pay the transaction fee with the test Ether we acquired earlier. After the contract is deployed we can test if everything works properly and play around with it. Since the Ropsten test net is using the same consensus as the mainnet it is the closest we can get to a real-world application. To learn more about Solidity visit our tutorial.

        

Summary

Click to jump to section