Using Hardhat

Hardhat is a development environment to compile, deploy, test, and debug your Ethereum software.

A sample project is available at https://github.com/thundercore/hardhat-thunder-projectarrow-up-right

Setting up Hardhat

Please follow Hardhat offcial guide to prepare your environmentarrow-up-right.

Once your environment is ready, we can create an empty folder and init a Hardhat project in it.

$ mkdir my-thundercore-project && cd $_

# We choose a basic sample project and install its dependences here:
$ npx hardhat init

 What do you want to do? · Create a basic sample project

 Do you want to install this sample project's dependencies with npm (hardhat @nomiclabs/hardhat-waffle ethereum-waffle chai @nomiclabs/hardhat-ethers ethers)? (Y/n) · y

After initialization, we can test the project with the hardhat compile command:

$ npm exec -- hardhat compile
Downloading compiler 0.8.25
Compiling 2 files with 0.8.25
Compilation finished successfully

Hardhat Config

To start developing on ThunderCore, we'll make some changes to the Hardhat config file. A great option is to use the tt-hardhat pluginarrow-up-right.

Then, in hardhat.config, simply paste import "tt-hardhat"; at the top. We'll now be able to use networks thunder-testnet and thunder-mainnet.

Alternatively, we can configure the network manually. Open and edit hardhat.config.js in the root directory of your project.

circle-exclamation

Deploy to ThunderCore Network

Let's deploy the first contract.

circle-info

You'll need some gas tokens to deploy contracts. To test on ThunderCore testnet, you can get some testnet tokens from ThunderCore testnet Faucetarrow-up-right

By using the tt-hardhat plugin, you can import logDeployContracts from hardhat to log your deployed contracts. More infoarrow-up-right

Congratulations! You have successfully deployed a smart contract onto the ThunderCore network, you will find the deployed messages look like:

Verify contract by plugin

Once you deployed your contract, you might want to verify your contract code.

On ThunderCore testnet, we provide Blockscoutarrow-up-right as our block explorer. You can use hardhat-etherscan plugin to verify your contract.

after installed the package, modify your hardhat.config.js

Now, you can verify your contract by command:

For more details, you can check hardhat-etherscanarrow-up-right document.

Remember that a sample Hardhat project is available at https://github.com/thundercore/hardhat-thunder-projectarrow-up-right!

Last updated