ThunderCore
ThunderCoreThunderCore Bridge
  • ⚡Hello world
  • Developer Program
  • Network Details
    • ThunderCore Mainnet
    • ThunderCore Testnet
    • Token List
    • Smart Contract Services
    • Full Node Deployment
  • Develop on ThunderCore
    • Migrate from Ethereum
    • Using Foundry
    • Using Hardhat
    • Using Remix
    • Using Truffle
    • Deploy TT20
    • Deploy a DApp
    • Deploy a NFT
  • Develop on TT Wallet
    • DApp Submission
    • Deeplinking
    • Signing Messages
    • Ethereum Provider API
    • Token Listing
    • Advertising with TT Wallet
      • Logo size submission guideline
      • Promotional Package
      • How we help developers
    • Developer Build - TT Wallet (Android)
  • FAQs
  • Product / Protocol
    • Wallets
      • MetaMask
        • Create a MetaMask Wallet
        • Create multiple accounts
      • TT Wallet
    • ThunderCore Bridge
      • Architecture
      • Ethereum <> ThunderCore
      • BNB chain <> ThunderCore
      • Interact with ThunderCore Bridge
  • Tool
    • Game Development
      • MetaFab
    • DApp Development
      • Faucet
      • Random Number Generator
      • Oracles
      • Referral Library
      • TTSwap Resources
      • Wrapped TT Addresses
      • Multicall
      • Subgraph
      • Auth Service
      • Wallet Service
      • Node Service
Powered by GitBook
On this page
  1. Develop on ThunderCore

Using Hardhat

Last updated 1 year ago

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

A sample project is available at

Setting up Hardhat

Please follow .

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
$ yarn hardhat compile
Compiling 2 files with 0.8.25
Compilation finished successfully
Done in 1.22s.

Hardhat Config

yarn add -D tt-hardhat

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.

// hardhat.config.ts

import { HardhatUserConfig } from "hardhat/config";
import "@nomicfoundation/hardhat-toolbox";

// Add this
import "tt-hardhat";

const config: HardhatUserConfig = {
   solidity: "0.8.25",
   networks: {
    hardhat: {
      allowUnlimitedContractSize: true,
      blockGasLimit: 141438723,
    },
  }
};

export default config;
// hardhat.config.js

// yarn add -D dotenv # install `dotenv`
imort * as dotenv from "dotenv";

dotenv.config();

module.exports = {
  solidity: {
    version: "0.8.25",
    settings: {
      evmVersion: "london",
    },
  },
  networks: {
    'thunder-testnet': {
      url: 'https://testnet-rpc.thundercore.com',
      chainId: 18,
      accounts: process.env.KEY ? [process.env.KEY] : [],
    },
    'thunder-mainnet': {
      url: 'https://mainnet-rpc.thundercore.com',
      chainId: 108,
      accounts: process.env.KEY ? [process.env.KEY] : [],
    },
  },
}

Never store your private key directly in hardhat.config.js

Here we pass the its value on the command line or store it in `.env`.

Deploy to ThunderCore Network

Let's deploy the first contract.

# Using NPM
KEY=0xPrivateKey npm exec -- hardhat run scripts/sample-script.js --network thunder-testnet
# or using Yarn
KEY=0xPrivateKey yarn hardhat run scripts/sample-script.js --network thunder-testnet
# Using NPM
set KEY=0xPrivateKey & npm exec -- hardhat run scripts/sample-script.js --network thunder-testnet
# or using Yarn
set KEY=0xPrivateKey & yarn hardhat run scripts/sample-script.js --network thunder-testnet
# Using NPM
$env:KEY='0xPrivateKey';npm exec -- hardhat run scripts/sample-script.js --network thunder-testnet
# or using Yarn
$env:KEY='0xPrivateKey';yarn hardhat run scripts/sample-script.js --network thunder-testnet

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

Greeter deployed to: 0xGreeterContractAddress

Verify contract by plugin

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

yarn add -D @nomiclabs/hardhat-etherscan

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

hardhat.config.js
module.exports = {
  etherscan: {
    apiKey: {
      "thunder-testnet": "unused",
    },
    customChains: [
      {
        network: "thunder-testnet",
        chainId: 18,
        urls: {
          apiURL: "https://explorer-testnet.thundercore.com/api",
          browserURL: "https://explorer-testnet.thundercore.com",
        },
      },
    ],
  },
}

Now, you can verify your contract by command:

yarn hardhat verify --network thunder-testnet ADDRESS "CONSTRUCTOR_ARGUMENT"

To start developing on ThunderCore, we'll make some changes to the Hardhat config file. A great option is to use the .

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

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

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

For more details, you can check document.

Remember that a sample Hardhat project is available at !

https://github.com/thundercore/hardhat-thunder-project
Hardhat offcial guide to prepare your environment
tt-hardhat plugin
ThunderCore testnet Faucet
More info
Blockscout
hardhat-etherscan
https://github.com/thundercore/hardhat-thunder-project