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.
$ npx hardhat
888 888 888 888 888
888 888 888 888 888
888 888 888 888 888
8888888888 8888b. 888d888 .d88888 88888b. 8888b. 888888
888 888 "88b 888P" d88" 888 888 "88b "88b 888
888 888 .d888888 888 888 888 888 888 .d888888 888
888 888 888 888 888 Y88b 888 888 888 888 888 Y88b.
888 888 "Y888888 888 "Y88888 888 888 "Y888888 "Y888
Welcome to Hardhat v2.10.1
√ What do you want to do? · Create a JavaScript project
√ Hardhat project root: · Project-Directory
√ Do you want to add a .gitignore? (Y/n) · y
You need to install these dependencies to run the sample project:
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
npm install --save-dev "hardhat@^2.10.1" "@nomicfoundation/hardhat-toolbox@^1.0.1"
Project created
See the README.md file for some example tasks you can run
Give Hardhat a star on Github if you're enjoying it!
https://github.com/NomicFoundation/hardhat
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.
require("@nomicfoundation/hardhat-toolbox");
const { mnemonic } = require('./secrets.json');
// This is a sample Hardhat task. To learn how to create your own go to
// https://hardhat.org/guides/create-task.html
task("accounts", "Prints the list of accounts", async () => {
const accounts = await ethers.getSigners();
for (const account of accounts) {
console.log(account.address);
}
});
// You need to export an object to set up your config
// Go to https://hardhat.org/config/ to learn more
/**
* @type import('hardhat/config').HardhatUserConfig
*/
module.exports = {
defaultNetwork: "mainnet",
networks: {
localhost: {
url: "http://127.0.0.1:8545"
},
hardhat: {
},
testnet: {
url: "https://rpc-testnet.juncachain.com/",
chainId: 669,
gasPrice: 20000000000,
accounts: {mnemonic: mnemonic}
},
mainnet: {
url: "https://rpc.juncachain.com/",
chainId: 668,
gasPrice: 20000000000,
accounts: {mnemonic: mnemonic}
}
},
solidity: {
version: "0.8.9",
settings: {
optimizer: {
enabled: true
}
}
},
paths: {
sources: "./contracts",
tests: "./test",
cache: "./cache",
artifacts: "./artifacts"
},
mocha: {
timeout: 20000
}
};
:::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.