The process of developing a contract, going through the necessary configurations and testing of the contract, ends with the deployment of the contract to the desired blockchain.
Contract deployment with Hardhat
To deploy your contract, you will need to compile it. Hardhat also helps us with that thanks to the npx hardhat compile
command. You will see that it creates several directories in your project with the bytecode of the developed contract. Remember that EVM doesn't understand anything about Solidity, contracts must be compiled to be interpreted correctly with the Ethereum network.
In addition to the contract bytecode, you will find a file called Application Binary Interface or ABI. The ABI, is a JSON that we can use from any client to know how to interact with the contract. What methods it has, what parameters it receives, etc. In the next classes, we will use it to type the information and communicate with the smart contract deployed on the blockchain.
After compiling your contract, configuring the hardhat.config.js
file and developing the deployment script with Hardhat, the command npx hardhat run scripts/deploy.js --network goerli
will be in charge of deploying the contract, in this case, in Goerli.
You will notice in the development console that, after the successful launch of the contract, it delivers a completely unique address that you will use to locate your smart contract on the blockchain in question where it has been deployed.
Each blockchain, whether it is the mainnet or a test network, will have its own browser that will allow you to visualize and get more information about what is happening on the network. By using Goerli's explorer, plus the address of the contract, you will be able to visualize the status of the contract and corroborate its correct deployment and all the transactions that interact with it.
Knowing how to use blockchain explorers will be key to become a great web developer3.
To this point, it only remains to congratulate you for having developed and deployed your first smart contract with Hardhat.
Contributed by: Kevin Fiorentino (Platzi Contributor).
Want to see more contributions, questions and answers from the community?