Skip to main content
In this guide you set up a Hardhat 3 project that can compile, deploy and verify contracts on BOT Chain testnet and mainnet. Your private key never goes in a file you commit.
Everything on this page uses testnet (chain 968). Get free test tokens from the faucet.

What you’ll build

A TypeScript Hardhat 3 project with:
  • botTestnet and botMainnet networks.
  • A private key read through configVariable, so it stays out of your code.
  • chainDescriptors that point Hardhat at BOTScan for verification.
  • A small network hook that fixes the fee Hardhat Ignition sends on BOT Chain.

Prerequisites

Steps

1

Create the project

Tested with hardhat 3.18.1, @nomicfoundation/hardhat-toolbox-viem 5.0.7 and @nomicfoundation/hardhat-ignition 3.1.8.
2

Add the fee hook

BOT Chain blocks have a base fee of 0. Hardhat Ignition reads that as “gas is free” and sends transactions with a fee of 0, which the node rejects with transaction underpriced. This hook asks the node what tip it wants and adds it.
plugins/bot-chain-fees.ts
Transactions that already carry a fee pass through unchanged, so the hook is safe on other chains too.
3

Write the config

hardhat.config.ts
What each part does:
  • evmVersion: "cancun" stops the compiler from using opcodes BOT Chain doesn’t support yet.
  • configVariable("BOT_PRIVATE_KEY") is resolved only when a task needs it, so npx hardhat build works without a key.
  • chainDescriptors tells Hardhat that BOTScan is a Blockscout explorer. hardhat verify blockscout uses it. No API key is needed.
4

Provide your private key

Use a key made only for testing. You have two options.Option 1: the Hardhat keystore (recommended). The key is stored encrypted on your machine and Hardhat asks for the password when it needs it.
Option 2: an environment variable for the current terminal session only.
Never paste a private key into hardhat.config.ts or a file you commit. If you use a .env file, add it to .gitignore first. Hardhat does not read .env files on its own.
5

Add a contract and compile

contracts/Counter.sol

Verify it worked

Check that Hardhat can reach the network and load your key with a small script:
scripts/check-network.ts
You should see Chain ID: 968, your address and your tBOT balance.

Troubleshooting

The fee hook isn’t loaded. Check that plugins/bot-chain-fees.ts exists and that the config imports it as ./plugins/bot-chain-fees.js (with .js, even though the file is .ts).
Hardhat couldn’t find BOT_PRIVATE_KEY. Set it with the keystore or export it in the same terminal you run Hardhat from.
You compiled for a newer EVM version. Make sure evmVersion: "cancun" is set, then run npx hardhat clean and build again.

Next steps

Deploy with Hardhat

Deploy Counter to testnet with Ignition.

Verify with Hardhat

Publish your source on BOTScan.
Last modified on October 3, 2026