Skip to content

w3hc/w3hc-hardhat-template

Repository files navigation

W3HC Hardhat Template

A comprehensive development environment for Ethereum-compatible networks using Hardhat.

Features

Supported Networks

Network Chain ID Documentation
Optimism Mainnet 10 Documentation
Sepolia Testnet 11155111 Documentation
OP Sepolia Testnet 11155420 Documentation
Base Sepolia Testnet 84532 Documentation

Contract Verification

Network Explorer URL API URL API Key Variable
Sepolia https://sepolia.etherscan.io https://api-sepolia.etherscan.io/api ETHERSCAN_API_KEY
Optimism https://optimistic.etherscan.io https://api-optimistic.etherscan.io/api OP_ETHERSCAN_API_KEY
OP Sepolia https://sepolia-optimism.etherscan.io https://api-sepolia-optimistic.etherscan.io/api OP_ETHERSCAN_API_KEY
Base Sepolia https://sepolia.basescan.org https://api-sepolia.basescan.org/api BASE_ETHERSCAN_API_KEY

Contract Verification

Network Explorer URL API URL API Key Variable
Sepolia https://sepolia.etherscan.io https://api-sepolia.etherscan.io/api ETHERSCAN_API_KEY
Optimism https://optimistic.etherscan.io https://api-optimistic.etherscan.io/api OP_ETHERSCAN_API_KEY
Base https://basescan.org https://api.basescan.org/api BASE_ETHERSCAN_API_KEY
OP Sepolia https://sepolia-optimism.etherscan.io https://api-sepolia-optimistic.etherscan.io/api OP_ETHERSCAN_API_KEY
Base Sepolia https://sepolia.basescan.org https://api-sepolia.basescan.org/api BASE_ETHERSCAN_API_KEY

Manual Contract Verification

When deploying, you may see this error:

ContractStatusPollingResponseNotOkError: The Etherscan API responded with a failure status.
Reason: Fail - Unable to verify. Unable to locate ContractCode at <address>

This is normal - it means the contract needs time to be indexed. Wait 1-2 minutes, then run:

npx hardhat verify --network <NETWORK_NAME> <CONTRACT_ADDRESS> "10000000000000000000000"

Where:

  • <NETWORK_NAME>: optimism, base, op-sepolia, or base-sepolia
  • <CONTRACT_ADDRESS>: The address where your contract was deployed

Note: The constructor argument represents the initial supply in wei (e.g., "10000000000000000000000" for 10,000 tokens with 18 decimals)

If the verification fails with "Unable to locate ContractCode", wait a few minutes for the contract to be indexed by the block explorer and try again.

Alternative Manual Verification via Block Explorers:

When verifying through block explorers:

  1. Choose "Solidity (Single file)"
  2. Fill in:
    • Contract Address
    • Compiler: v0.8.20
    • License: GPL-3.0
    • Optimization: Yes (200 runs)
    • Contract code from Basic.sol
    • Constructor Arguments: 10000000000000000000000

Installation

  1. Install dependencies:
pnpm install
  1. Configure environment:
cp .env.template .env
  1. Update .env with your configuration:
# Required Configuration
OPTIMISM_MAINNET_RPC_ENDPOINT_URL="your_optimism_rpc_url"
OPTIMISM_MAINNET_PRIVATE_KEY="your_private_key"
OP_ETHERSCAN_API_KEY="your_api_key"

# Additional networks...

Usage

Testing

Execute the test suite:

pnpm test

Deployment

Deploy to supported networks:

pnpm deploy:<network>

Supported values for <network>: sepolia, optimism, op-sepolia, base-sepolia

Network Operations

Check wallet balance:

pnpm bal <network>

Mint tokens:

pnpm mint:<network> <amount>

Transfer tokens:

pnpm send:<network> <amount>

Core Dependencies

Support

Feel free to reach out to Julien: Farcaster, Element, Status, Telegram, Twitter, Discord, or LinkedIn.