Hardhat
Last updated
Last updated
Hardhat is another essential tool that should be found in every dApp developer's arsenal. Hardhat allows seamless deployment of smart contracts, running of tests, and debugging outside of live environments.
One of the biggest advantages of Hardhat is its flexibility - there is a series of plugins available for different types of developers, and Hardhat's extensible ecosystem allows for efficient tooling.
This guide assumes that the reader has at least some familiarity with the Solidity programming language for smart contracts, and general dApp development on the Ethereum network.
The following is a short guide for deploying a smart contract using Hardhat. The best solution is to use a development environment like VSCode for an optimal deployment experience.
1. First of all, make sure you have HardHat set up on your local machine. Check out this guide if you encounter problems: https://hardhat.org/hardhat-runner/docs/guides/project-setup
2. There are 3 files that you will have to edit. First, create a Solidity file under the contracts folder. You can right click on the folder and create a new file. For this example, we named it HHToken.sol
3. Paste this piece of simple contract code in your HHToken.sol equivalent file:
4. Once you’re done, go to the scripts folder, then look for deploy.js. As part of the setting up Hardhat, there are already some lines in the that file. You will just have to edit some variables like the ones below:
Make sure that for getContractFactory you enter the contract name of your token.
5. Once you have entered your contract name, go to the main folder and look for the file named hardhat.config.js. Enter the Metanovaverse Network details:
RPC: https://web3.metanovaverse.com
Chain ID: 10096
For the accounts, we stored our private key to a variable and named it privKey. You can also put your private key there. This private key should belong to the account of the one who deploys the contract, so make sure it has some MNV tokens.
6. Open the Terminal in your VSCode so you can enter a deployment command like the following:
We named the network metanovaverse in the hardhat.config.js file, which is why we used metanovaverse after the –-network
flag.
7. You should now see an output like this:
That’s it, you’ve successfully deployed your token using Hardhat on the Metanovaverse Network!