Deploy a contract with Hardhat
This section is a guide on how to deploy a smart contract on the TAOVM using Hardhat.
Hardhat is a popular smart contract development frameworks. It is used in the TAOVM rollup as a default for deploying and automatically verifying smart contracts.
Prerequisites
Before you begin, you will need to prepare the following:
Prepare one EVM account
Get some test TAO from the Testnet Faucet: https://faucet.taovm.io
Initialize Hardhat project
mkdir <project-name>;cd <project-name>
Initialize a project with Hardhat:
npx hardhat
.Next, (… To avoid failure … please go slow with this cli dialogue…)
Press
<ENTER>
to set the project root.Press
<ENTER>
again to accept addition of.gitignore
.Type
n
to reject installingsample project's dependencies
.The idea here is to postpone installing dependencies to later steps due to a possible version-related bug.
Configure Hardhat project
Open the hardhat.config.js
file and paste the below code:
Add smart contract
Create a new file, in the contracts folder, named
Counter.sol
:touch contracts/Counter.sol
.Copy the below code and paste it in the Counter contract code:
Add deploy script
Create a new file in the scripts folder
deploy-counter.js
:touch scripts/deploy-counter.js
.Add the code below to the
deploy-counter.js
file:
Compile and deploy
Before compiling the contract, you need to install the toolbox. You may need to change directory to install outside the project. Use this command:
Compile your contract code (i.e., go back to the project root in the CLI):
Now run the scripts:
Last updated