HadHat
In this tutorial, we explain step-by-step how to create, compile and deploy a simple smart contract on the JuncaChain Testnet 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.
Pre-requisites
There are a few technical requirements before we start as listed below:
Node.js v10+ LTS and npm (comes with Node)
Create an empty project
npm init --yes
Once your project is ready, run
npm install --save-dev hardhat
to install Hardhat.Install hardhat toolbox
npm install @nomicfoundation/hardhat-toolbox
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 to intialize your project.Select
Create an empty hardhat.config.js
with your keyboard and hit enter.
When Hardhat is run, it searches for the closest hardhat.config.js
file starting from the current working directory. This file normally lives in the root of your project and an empty hardhat.config.js
is enough for Hardhat to work. The entirety of your setup is contained in this file.
Create Smart Contract
You can write your own smart contract, place it in the contracts
directory of your project and remane it as JRC20Token.sol
.
Configure Hardhat for JuncaChain
Go to
hardhat.config.js
Update the config with junca-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 secrets.json
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 Smart 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:
Deploy Smart Contract on JuncaChain Network
Copy and paste the following content into the
scripts/deploy.js
file.
Run this command in root of the project directory:
Sample Output
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 JRC20 Smart Contract. Now you can interact with the Smart Contract.
You can check the deployment status here: https://scan.juncachain.com or https://scan-testnet.juncachain.com
Last updated