Hardhat

Using Hardhat

What is Hardhat

Hardhat is a development environment to compile, deploy, test, and debug your smart contract.

Setting up the development environment

There are a few technical requirements before we start. Please install the following: Requirements:

Installing

There are a few technical requirements before we start. Please install the following: Requirements:

First, you need to create an empty project npm init --yes

Once your project is ready, you should run

npm install --save-dev hardhat

It's recommeded to install some dependencies.

To use your local installation of Hardhat, you need to use npx to run it (i.e. npx hardhat).

Create A Project

To create your Hardhat project run npx hardhat in your project folder:

  • Intialize your project:

Once this project is initialized, you'll now have a project structure with the following items:

  • contracts/: Directory for Solidity contracts

  • scripts/: Directory for scriptable deployment files

  • test/: Directory for test files for testing your application and contracts

  • hardhat-config.js: Hardhat configuration file

Create Contract

You can write your own smart contract or download the LRC20 token smart contract template.

Config Hardhat for TC

  • Go to hardhat.config.js

  • Update the config with nc-network-crendentials.

Note

It requires mnemonic to be passed in for Provider, this is the seed phrase for the account you'd like to deploy from. Create a new .secret file in root directory and enter your 12 word mnemonic seed phrase to get started. To get the seedwords from metamask wallet you can go to Metamask Settings, then from the menu choose Security and Privacy where you will see a button that says reveal seed words.

Compile Contract

To compile a Hardhat project, change to the root of the directory where the project is located and then type the following into a terminal:

Deploying on LOOP Network

Run this command in root of the project directory:

Remember your address, transaction_hash and other details provided would differ, Above is just to provide an idea of structure.

Congratulations! You have successfully deployed LRC20 Smart Contract. Now you can interact with the Smart Contract.

You can check the deployment status here: https://explorer.testnetloop.com or https://explorer.mainnetloop.com/

Last updated