Skip to main content

Using Hardhat

Hardhat is a development environment used for smart contract compiling, deploying, testing and debugging.

Get started with Hardhat for general installation and overview.

Config Hardhat for Gnosis

Update the config with Gnosis networks, check the highlighted lines for instructions:

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

//https://hardhat.org/hardhat-runner/docs/config#json-rpc-based-networks

//Note: keep your mnemonic and private keys securely
//Read more: https://hardhat.org/hardhat-runner/docs/config#hd-wallet-config
//1) You can configure private keys or mnemonic:
//let accounts = ["your private key here"]
let accounts = { mnemonic: "your mnemonic here", }

const config: HardhatUserConfig = {
solidity: "0.8.17",
//2) select the default network "gnosis" or "chiado"
defaultNetwork: "gnosis",
networks: {
hardhat: {
},
gnosis: {
url: "https://rpc.gnosischain.com",
accounts: accounts,
},
chiado: {
url: "https://rpc.chiadochain.net",
gasPrice: 1000000000,
accounts: accounts,
},
},
etherscan: {
customChains: [
{
network: "chiado",
chainId: 10200,
urls: {
//Blockscout
apiURL: "https://blockscout.com/gnosis/chiado/api",
browserURL: "https://blockscout.com/gnosis/chiado",
},
},
{
network: "gnosis",
chainId: 100,
urls: {
// 3) Select to what explorer verify the contracts
// Gnosisscan
apiURL: "https://api.gnosisscan.io/api",
browserURL: "https://gnosisscan.io/",
// Blockscout
//apiURL: "https://blockscout.com/xdai/mainnet/api",
//browserURL: "https://blockscout.com/xdai/mainnet",
},
},
],
apiKey: {
//4) Insert your Gnosisscan API key
//blockscout explorer verification does not require keys
chiado: "your key",
gnosis: "your key",
},
}
};

export default config;

Compile your contract

npx hardhat compile

Deploy your contract

Gnosis Mainnet
npx hardhat run scripts/deploy.ts --network gnosis
Chiado Testnet
npx hardhat run scripts/deploy.ts --network chiado

View your deployed contract on any of the explorers.

Visit our Tools page for other support.

Verify Contract

npx hardhat verify --network chiado <deployed contract address>

Visit our Contract Verification Page for more documentation on verification tools.

Additional Hardhat Documentation

  • Additional Hardhat deployment documentation is located here.