How to deploy a smart contract on any evm chain using thirdweb
Published: 2023-03-16 05:24:07

First, what is Thirdweb?. Thirdweb is a complete web3 development framework that provides developers with the tools and infrastructure they need to build and connect their applications or games to decentralized networks. With Thirdweb, developers can access powerful dev tools and managed infrastructure services that simplify the entire web3 development cycle.

Today i will explain how to deploy smart contracts on goerli using thirdweb

Note: this tutorial will work for any evm compatible chain too

###Prerequisites

1. A MetaMask wallet with some goerliETH.

2. vscode

3. forge(if you do not know how to use forge, you can check it out here [foundry](https://book.getfoundry.sh), you can also use hardhat but we won't cover it in this tutorial

###What we will do

- deploy a contract using thrirdweb

- interact with the contract

- use thirdweb features

###First, we install thirdweb 
we do this by running `npx thirdweb create contract` which installs the thirdweb package
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mnhcsqzpt8jev30d0y9j.png)
we then name our contract, in this tutorial we are going to name it tutorial, next it brings out a new option asking us to select a framework we want to use, for this tutorial we will be using forge(you should totally check forge out if you've not used it before), you should see something like this:
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2iat2ti92y9805l485pi.png)
after that you will be asked to name your smart contract, I named mine tutorial, you can name yours whatever you want, after this you will be asked to pick a type of smart contract of your choice. 
you should see this

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dwsnzyr3lgg4l4jpd9ql.png) 
I picked ERC20 then none meaning a plain ERC20 contract with no extra features like votes,e.t.c. Again for this part you can pick any contract of your choice and experiment with it.

###Deploying the contract
To deploy the contract go to the terminal and type`yarn deploy`, this compiles your contract and uploads it after it provides a link where we can choose the network we wan't to deploy to, it should look like this:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fhz8lkkkjlipbhb04at2.png)
This should give us a link where we would go to and deploy the smart contract, click the link and you should see a dashboard like this:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hya69rs0jcdshjjhnxr4.png)
from this image you can see a connect wallet button, connect your wallet, select goerli, pass in the required parameters if you have a constructor, in my case I do since i'm deploying a ERC20 contract, all I have to do is pass in the name and symbol, now after that i click on the deploy button and it deploys to goerli, the best part about this is you can deploy on any network using this feature and even specidy your own custom network

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mteqgr16ibd8t35u3tny.png)
after deployment you can see a new dashboard that list everything about the contract including name,symbol,owner,e.t.c

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t7n7kkp34mix0bn3bels.png)
Based on the image above you can see the different tabs on the left corner of the screen including the events tab,build tab,e.t.c. lets go through all this tab

###Overview
we've described the overview above, but's lets go through this again, the overview allows you to see the present state of your contract including the last event that was initialised during the contract usage


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

###Build
The tab build allows you to build various part of the smart contract using languages such as javascript,react,unity,python,go, e.t.c. With build you can get  various instances of your smart contract including the token uri, the owner,functions in the contract e.t.c

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

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

###Explorer
The third tab explorer, with explorer you can read various state variables of the contract and also click on various functions in the contract

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

###Events
The events tab allows you to view the history of the contract, i.e the various events that have been triggered in the smart contracts

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

###Settings
with the setting you can specify various part of the contract and change some state variable like ownership, name,e.t.c

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

###Sources
Sources allow you to view the source code of your contract, including inherited and imported codes that were used in the contract, you can also verify the various contracts

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

###Extensions
This allows you to view the various types and part of your contract

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

Here is the link to my contract: https://thirdweb.com/goerli/0xd9AAD7F6FCD8be4fD882d90714bb916666dE5B0D/tokens

All Done, you've successfully deployed a contract on any evm chain of your choice