Skills2026年5月14日·1 分钟阅读

Hardhat — Ethereum Development Environment for Professionals

Hardhat is a development environment for compiling, deploying, testing, and debugging Ethereum smart contracts. It features a built-in local network (Hardhat Network) with advanced debugging capabilities like Solidity stack traces, console.log, and mainnet forking. Hardhat uses a JavaScript/TypeScript task and plugin system for extensibility.

Agent 就绪

这个资产可以被 Agent 直接读取和安装

TokRepo 同时提供通用 CLI 命令、安装契约、metadata JSON、按适配器生成的安装计划和原始内容链接,方便 Agent 判断适配度、风险和下一步动作。

Stage only · 29/100Stage only
Agent 入口
任意 MCP/CLI Agent
类型
Skill
安装
Stage only
信任
信任等级:Established
入口
Hardhat
通用 CLI 安装命令
npx tokrepo install 59935d2e-4f90-11f1-9bc6-00163e2b0d79

Introduction

Hardhat is a JavaScript and TypeScript development environment for Ethereum smart contracts maintained by Nomic Foundation. It provides a flexible task runner, a built-in local blockchain with advanced debugging, and a rich plugin ecosystem. Hardhat is one of the most popular choices for professional Solidity development teams.

What Hardhat Does

  • Compiles Solidity contracts with configurable compiler versions and optimization settings
  • Runs JavaScript or TypeScript tests using Mocha and Chai with built-in assertions
  • Provides Hardhat Network, a local Ethereum node with Solidity stack traces and console.log
  • Supports mainnet forking to simulate transactions against live chain state
  • Deploys contracts via scripts with built-in provider and signer management

Architecture Overview

Hardhat is built as a task runner where each command (compile, test, deploy) is a task that can be overridden or extended via plugins. The Hardhat Runtime Environment (HRE) is injected into scripts and tests, providing access to ethers.js, network configuration, and artifacts. Hardhat Network is an in-process EVM powered by EDR (Ethereum Development Runtime) written in Rust for improved performance. Plugins hook into compilation, testing, and deployment phases.

Self-Hosting & Configuration

  • Initialize with npx hardhat init and select a project template (JavaScript, TypeScript, or empty)
  • Configure networks, compiler, and paths in hardhat.config.ts
  • Install plugins like @nomicfoundation/hardhat-toolbox for a batteries-included setup
  • Set INFURA_API_KEY or ALCHEMY_API_KEY in .env for testnet and mainnet deployment
  • Use hardhat-deploy plugin for reproducible, deterministic deployments

Key Features

  • Solidity stack traces pinpoint the exact line where a transaction reverts
  • console.log in Solidity contracts outputs to the terminal during tests
  • Mainnet forking lets you test against real contract state at any block number
  • TypeScript-first with full type generation from contract ABIs via TypeChain
  • Plugin ecosystem includes verification (Etherscan), gas reporting, and coverage

Comparison with Similar Tools

  • Foundry — Rust-based with Solidity-native tests and faster execution; Hardhat offers a richer JS plugin ecosystem
  • Truffle — Earlier JavaScript framework now largely superseded; Hardhat has better debugging and TypeScript support
  • Brownie — Python-based framework; Hardhat is the standard for JavaScript/TypeScript teams
  • Remix — Browser-based IDE for quick prototyping; Hardhat is designed for full project lifecycles

FAQ

Q: Can I use Hardhat with TypeScript? A: Yes. Hardhat has first-class TypeScript support. Running npx hardhat init offers a TypeScript project template.

Q: How does mainnet forking work? A: Set forking.url in the Hardhat Network config to an archive node RPC. Hardhat replays state from a specific block, letting you test against real contracts.

Q: Is Hardhat free? A: Yes. Hardhat is open-source and free. Nomic Foundation offers optional paid services but the core tool has no cost.

Q: How do I verify contracts on Etherscan? A: Install @nomicfoundation/hardhat-verify and run npx hardhat verify --network mainnet <address> <constructor-args>.

Sources

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产

Foundry — Blazing Fast Ethereum Development Toolkit in Rust

Foundry is a portable, modular toolkit for Ethereum smart contract development written in Rust. It includes Forge for testing, Cast for chain interaction, Anvil for local node simulation, and Chisel for an interactive Solidity REPL. Foundry compiles and runs tests significantly faster than JavaScript-based alternatives.

Skills
AI Open Source

Go Ethereum (Geth) — Official Go Implementation of the Ethereum Protocol

Geth is the official Go client for the Ethereum network. It lets developers run full or light nodes, deploy and interact with smart contracts, manage accounts, and mine blocks. Geth powers a large share of the Ethereum mainnet and serves as the reference implementation for protocol upgrades.

Skills
Script Depot

OpenZeppelin Contracts — Secure Smart Contract Library for Ethereum

OpenZeppelin Contracts is an open-source library of audited, reusable Solidity smart contracts. It provides standard implementations of ERC-20, ERC-721, ERC-1155, access control, upgradeable proxies, and governance patterns. Developers use it to build secure on-chain applications without reinventing common primitives.

Skills
AI Open Source

Viem — TypeScript Interface for Ethereum

Viem is a modern TypeScript library for interacting with the Ethereum blockchain. It provides composable, type-safe modules for public client reads, wallet actions, contract interactions, ABI encoding, and ENS resolution. Viem is the low-level transport layer that powers Wagmi and has become the successor to ethers.js for many TypeScript-first teams.

Skills
AI Open Source