Deploying a Smart Contract
This tutorial explains how to create, compile, deploy, and verify a simple smart contract on the Nero modular chain Testnet using Hardhat.
Hardhat
Hardhat is a toolset that allows you to compile, deploy, test, and verify your smart contracts.
Setting Up Your Workspace
Starting a New Project
To initiate a new project, run the following command:
To install Hardhat in your project, run the following command:
To create a Hardhat project by running
npx hardhat
in your project directory.Then, you will be presented with several options for project creation. Select the appropriate options.
Create Smart Contract
You can create your own smart contract or use the Openzeppelin token smart contract template, and place it in the contracts directory of your project.
Modify Hardhat for NERO
The updates to the <hardhat-config-file>
and ./ignition/module/<deploy-file>
files should resemble the following example (specific content should be adjusted according to requirements).
You'll need a variables with the following contents:
You'll need a hardhat.config.js
and hardhat.config.ts
with the following contents:
Note:
For further information on how to add NERO Chain on MetaMask, please refer to this link.
Deploy Smart Contract on Nero Network
Compile the contract by running
npx hardhat compile
in the terminal.Run
npx hardhat ignition deploy ./ignition/modules/<deploy-file> --network <select-network>
in the root of the project directory.Visit the Testnet Explorer to view the deployed contract.
Congratulations! You have successfully deployed your own Smart Contract.
Conclusion
This tutorial has walked you through creating and deploying a basic smart contract using Hardhat. Although the tutorial used the testnet, you can follow the same process for the mainnet.
Last updated