$120 tested Claude codes · real before/after data · Full tier $15 one-timebuy --sheet=15 →
$Free 40-page Claude guide — setup, 120 prompt codes, MCP servers, AI agents. download --free →
clskills.sh — terminal v2.4 — 2,347 skills indexed● online
[CL]Skills_
Web3 & BlockchainintermediateNew

Hardhat Setup

Share

Set up Hardhat development environment for Solidity

Works with OpenClaude

You are a blockchain developer setting up a professional Hardhat development environment for Solidity smart contract development.

What to check first

  • Run node --version to confirm Node.js 16+ is installed
  • Check if npm or yarn is available with npm --version
  • Verify you have a clean project directory or existing package.json

Steps

  1. Create a new project directory and initialize npm: mkdir my-hardhat-project && cd my-hardhat-project && npm init -y
  2. Install Hardhat as a dev dependency: npm install --save-dev hardhat
  3. Initialize Hardhat project: npx hardhat and select "Create a JavaScript project" when prompted
  4. Install the Hardhat toolbox which includes ethers.js, chai, and other essentials: npm install --save-dev @nomicfoundation/hardhat-toolbox
  5. Create your first contract file in contracts/ directory with a .sol extension
  6. Configure network settings in hardhat.config.js by adding RPC endpoints for testnets (Sepolia, Mumbai) or mainnet
  7. Set up environment variables using npm install dotenv and create a .env file with SEPOLIA_RPC_URL and PRIVATE_KEY
  8. Test compilation with npx hardhat compile to verify Solidity contracts build without errors

Code

// hardhat.config.js - Complete configuration file
require("@nomicfoundation/hardhat-toolbox");
require("dotenv").config();

module.exports = {
  solidity: {
    version: "0.8.20",
    settings: {
      optimizer: {
        enabled: true,
        runs: 200,
      },
    },
  },
  networks: {
    hardhat: {
      chainId: 31337,
    },
    localhost: {
      url: "http://127.0.0.1:8545",
    },
    sepolia: {
      url: process.env.SEPOLIA_RPC_URL || "",
      accounts: process.env.PRIVATE_KEY ? [process.env.PRIVATE_KEY] : [],
      chainId: 11155111,
    },
    mumbai: {
      url: process.env.MUMBAI_RPC_URL || "",
      accounts: process.env.PRIVATE_KEY ? [process.env.PRIVATE_KEY] : [],
      chainId: 80001,
    },
  },
  etherscan: {
    apiKey: process.env.ETHERSCAN_API_KEY || "",
  },
  paths: {
    sources: "./contracts",
    tests: "./test",
    cache: "./cache",
    artifacts: "./artifacts",
  },
};
// .env.example - Template for environment variables
SEPOLIA_RPC_URL=https://rpc.sepolia.org

Note: this example was truncated in the source. See the GitHub repo for the latest full version.

Common Pitfalls

  • Treating this skill as a one-shot solution — most workflows need iteration and verification
  • Skipping the verification steps — you don't know it worked until you measure
  • Applying this skill without understanding the underlying problem — read the related docs first

When NOT to Use This Skill

  • When a simpler manual approach would take less than 10 minutes
  • On critical production systems without testing in staging first
  • When you don't have permission or authorization to make these changes

How to Verify It Worked

  • Run the verification steps documented above
  • Compare the output against your expected baseline
  • Check logs for any warnings or errors — silent failures are the worst kind

Production Considerations

  • Test in staging before deploying to production
  • Have a rollback plan — every change should be reversible
  • Monitor the affected systems for at least 24 hours after the change

Quick Info

Difficultyintermediate
Version1.0.0
AuthorClaude Skills Hub
web3hardhatethereum

Install command:

curl -o ~/.claude/skills/hardhat-setup.md https://claude-skills-hub.vercel.app/skills/web3/hardhat-setup.md

Related Web3 & Blockchain Skills

Other Claude Code skills in the same category — free to download.

Want a Web3 & Blockchain skill personalized to YOUR project?

This is a generic skill that works for everyone. Our AI can generate one tailored to your exact tech stack, naming conventions, folder structure, and coding patterns — with 3x more detail.