mcpField
S
solidity-hardhat-development

solidity-hardhat-development

github.com/whackurDevelopment051 installsUpdated 2d ago
Repository

About solidity-hardhat-development

solidity-hardhat-development is a guide skill for Hardhat 3 development, covering project setup, Solidity testing, deployment, multichain work, and v2 migration. It is intended for developers building and testing Solidity contracts.

Key features

  1. 01Configure Hardhat 3 projects and plugins
  2. 02Run Solidity and TypeScript tests
  3. 03Deploy declarative modules with Hardhat Ignition
  4. 04Test multiple chains concurrently
  5. 05Migrate project configuration from v2

Use cases

  1. 01Start a Hardhat 3 project
  2. 02Test Solidity contracts and review gas use
  3. 03Simulate and deploy contract modules
  4. 04Port a Hardhat v2 project

MCP support

The guide describes optional use with solidity-agent-toolkit. Its tools can compile contracts, run tests, produce gas snapshots, simulate deployments, and run security analysis.

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/whackur/solidity-agent-toolkit --skill solidity-hardhat-development

After installing, type/solidity-hardhat-developmentin Claude Code to confirm it loaded.

Bundled filesreferences/hardhat-cheatsheet.md

Details

From the project README

Hardhat 3 Development Guide

When to Apply

  • Starting new Hardhat 3 projects.
  • Migrating from v2 to v3.
  • Testing Solidity contracts with Foundry-compatible tests.
  • Deploying with Hardhat Ignition.
  • Building multichain applications.

Requirements

RequirementValue
Node.jsv22.10 or newer
Module systemESM — set "type": "module" in package.json
Init commandnpx hardhat --init
Config entrydefineConfig from hardhat/config

Configuration

Organize setup with solidity, networks, and plugins keys. Use configVariable("KEY") for secrets to keep them out of code. Plugins MUST be listed explicitly — side-effect imports from v2 no longer work.

Network typeUse for
edr-simulatedLocal in-process testing
httpRemote RPC connections

chainType accepts "l1", "op", or "generic". Build profiles allow per-environment settings (e.g., enabling the optimizer for production).

import { defineConfig, configVariable } from "hardhat/config";
import { hardhatIgnition } from "@nomicfoundation/hardhat-ignition";

export default defineConfig({
  solidity: "0.8.28",
  plugins: [hardhatIgnition],
  networks: {
    hardhat: { type: "edr-simulated" },
    mainnet: { type: "http", url: configVariable("MAINNET_RPC_URL") },
  },
});

Testing

Test typeRunnerNotes
Solidity (.t.sol)Rust-poweredInherits forge-std/Test.sol; full vm cheatcodes; fuzzing built-in
TypeScriptNode test runner + Viem, or Mocha + EthersAccess network helpers via the networkHelpers property
CommandRuns
npx hardhat testAll tests
npx hardhat test soliditySolidity tests only
--coverageCoverage data
--gas-statsGas usage data

Deployment (Ignition)

Hardhat Ignition is the primary deployment framework: declarative modules via buildModule, automatic transaction parallelization, and automatic resume of failed deployments.

  • Deploy: npx hardhat ignition deploy ignition/modules/MyModule.ts --network <network>
  • Verify: @nomicfoundation/hardhat-verify plugin

Multichain Support

Hardhat 3 simulates multiple chains at once. Connect per-network with const mainnet = await network.connect("mainnet"). Fork several chains concurrently for complex cross-chain testing.

Debugging

ToolPurpose
console.log (hardhat/console.sol)Print debugging inside contracts
Verbosity flags on the test commandIncrease trace detail
EDR stack tracesDetailed failure traces

Migration from v2

v2v3
CommonJSESM ("type": "module")
Node.js < 22Node.js v22.10+
module.exportsdefineConfig
Side-effect plugin importsExplicit plugins array
Ethers v5Ethers v6 or Viem
Single network objectMultichain NetworkManager
v2 pluginsv3-specific plugin versions

Essential plugins: hardhat-verify, hardhat-ignition, hardhat-keystore.

Enhanced with MCP

When the solidity-agent-toolkit is available:

  • compile_contract: Build contracts and get artifacts.
  • run_tests: Execute the test suite.
  • gas_snapshot: Get gas reports.
  • dry_run_deploy: Simulate deployments.
  • run_slither, run_aderyn: Perform security analysis.

References

See the Hardhat 3 Cheatsheet for examples.

Comments

Markdown supported