89DEVs

Deploy smart contracts to Gnosis Blockchain

The Gnosis Network is an alternative to deploying to the Ethereum network. It offers blockchain developers lower fees and faster transaction times compared to Ethereum. The networks average transaction time was measured at only 5 seconds which makes it suitable even for large-scale use cases. 

Deploy to Gnosis Chains in 3 steps:
  1. Add Gnosis to MetaMask
  2. Get free funds
  3. Deploy contract
Alternatives worth considering to Gnosis blockchain are Binance Smart Chain, Polygon Network and Avalanche. Each blockchains has advantages and disadvantages and it depends on the use-case and personal preferences to select the right blockchain for deployment. To continue deploying our Solidity smart contract to Gnosis, let's start by adding the Gnosis testnet and mainnet to our MetaMask wallet.

Add Gnosis to MetaMask

The first step is to add the Gnosis Chain to our MetaMask wallet. While Gnosis is a evm-compatible blockchain it is not supported by default. We have to enter the network settings ourself to set it up accordingly. To do so we have to select the network settings in MetaMask: click settings in metamask 1. Click on the account icon and then on settings in MetaMask click on networks in metamask 2. Click on Networks to open Networks view add network in metamask 3. Click the blue Add Network button The next step is to enter the Network settings for the Gnosis chain. There is the Mainnet and the Sokal Testnet. It makes sense to set up both networks at the same time to have them ready in MetaMask. However, you can also come back later to setup more networks in MetaMask. Just follow the three steps outlined here.

Network Settings for Gnosis

Enter the network settings for the Sokal Testnet and the Mainnet to add them to MetaMask.

Sokal Testnet settings (Gnosis Chain)

The network settings for Sokal Testnet.
Parameter Gnosis Sokal Testnet
Network Name Gnosis Sokal Testnet
RPC URL https://sokol.poa.network/
Chain ID 77
Currency Symbol xDai
Block Explorer URL https://blockscout.com/poa/sokol

Gnosis Mainnet settings

The network settings for Gnosis Mainnet.
Parameter Gnosis Mainnet
Network Name Gnosis Mainnet
RPC URL https://rpc.gnosischain.com/
Chain ID 100
Currency Symbol xDai
Block Explorer URL https://blockscout.com/xdai/mainnet/
After both networks have been added it is now time to acquire some funds, which are needed to pay for gas costs.

Get funds

In this tutorial we will deploy a test contract to the testnet. The next step is to get some funds to pay for the deployment fees. To get us some xDAI we use a faucet that dispenses test xDAI. Go to the faucet website and request 1 xDAI. To do so paste the address from MetaMask to the input field on the Sokal faucet website. It will take only a moment until the transaction is confirmed. copy address from metamask After the transaction is completed the success message is shown and we can verify in MetaMask that we have received the funds. There is also a link to the block explorer to verify the transaction. faucet success message With the test funds in our wallet we are ready for the next and final step: Deploying our contract.

Deploy contract to Gnosis chain

The last and final step is to deploy our smart contract to the Gnosis Testnet. In this tutorial we will use a random test contract and the remix Web IDE for simple demonstration. The schema is similar for the Gnosis Mainnet. To get started we compile our contract in Remix and then go to the Deploy & Run Transactions tab, which can be selected on the right side. There we select Injected Web3 on the Environment dropdown menu. If it's our first time to select this option, MetaMask will open to ask for confirmation. Please make sure to connect the correct account if you have multiple accounts in MetaMask. connect MetaMask to remix After that we can select the our contract on the Contract dropdown menu and click the Deploy button. Then Remix will open once again and ask us for confirmation. We can also see an estimate of the estimated gas fees for the deployment of the contract. If everything looks fine we can click the blue Confirm button to confirm the deployment. gnosis gas estimate in metamask It will take a moment until the contract is deployed to the blockchain and we can watch the status in MetaMask. If the deployment was successful we will see the confirmed status in MetaMask. The next step is to test our contract in Remix like we would test a contract deployed in the virtual Environment and to check the contract address on the blockchain using the Gnosis block explorer.

Block explorer for Gnosis

To check transactions and smart contract on the Gnosis blockchain we can use the block explorers: block explorer for sokol testnet block explorer for gnosis mainnet gnosis block explorer We can see the latest blocks and the latest transactions and also paste in the address of our smart contract to verify the deployment. It is very similar to block explorers for the Ethereum network like etherscan.io. The block explorer shows us also some interesting stats about the blockchain like the average block time, the total transactions, total blocks and total number of wallet addresses. Advanced developers can even use APIs.
The average block time of the Gnosis Mainnet is currently 5.2 seconds

alternatives to Gnosis Chain

There are many alternatives to the Gnosis chain and each come with advantages and disadvantages. Learn how to deploy smart contracts to other chains:

        

Summary

Click to jump to section