Hardhat Documentation

website·Indexed 40 days ago

https://hardhat.org/

Development environment for Ethereum smart contracts, featuring documentation for Hardhat 3 and Hardhat 2. Includes guides on writing and testing Solidity contracts, deploying with Hardhat Ignition, managing configuration variables, forking networks, and using the Hardhat console.

Tokens
170.8K
Snippets
1.1K
Records
1.3K
Agent score
73%

What's inside Hardhat

  1. Overview of EDR Simulated Networks in Hardhat

    Hardhat uses the Ethereum Development Runtime (EDR) to provide in-process blockchain simulations of Ethereum and Layer 2 networks. Unlike remote JSON-RPC nodes, simulated networks run entirely on the local machine, offering complete control over blockchain state, block production, and transaction execution without requiring a consensus mechanism or peer-to-peer network. Each simulation created is isolated, allowing multiple independent simulations to run simultaneously.
  2. Overview of Hardhat 3 Hooks and Hook Handlers

    Hooks are extension points in Hardhat 3 that allow plugins to introduce custom logic or intercept existing behavior. A Hook Handler is the actual function (callback) implemented by a plugin that executes when a specific Hook is triggered. Hooks are organized into categories (e.g., config, network, test, solidity) to improve organization, loading speed, and robustness.
  3. Overview of Hardhat 3 architectural changes

    Hardhat 3 is a complete rewrite of Hardhat 2 and is not directly compatible. Key changes include:

    • ESM-first: The Hardhat config must be an ES module. While scripts and tests can remain CommonJS, ESM is the default.
    • Declarative Configuration: Plugins and tasks must be explicitly configured in the config file rather than registered via side effects.
    • Explicit Network Connections: Users must now create and manage network connections manually. hre.network no longer provides a single, immediately available connection.
    • Hooks System: extendConfig and subtask overriding are replaced by a new hooks system. extendEnvironment is no longer supported.
  4. Overview of slang-solx compiler

    slang-solx is a Solidity compiler based on solc and LLVM. It provides faster compilation speeds, better optimized bytecode, and resolves "stack too deep" errors. It is intended for speeding up development workflows and should not be used for production deployments as it is under heavy development.
  5. Overview of Hardhat Ignition

    Hardhat Ignition is a declarative system for deploying smart contracts on Ethereum. Instead of writing imperative deployment scripts, developers define 'Ignition Modules' that describe the desired state of the system (contract instances and operations). Hardhat Ignition then determines the optimal execution path, allowing for parallel execution, automatic error recovery, and the ability to resume interrupted deployments.
  6. Overview of Hardhat VS Code extension features

    The Hardhat VS Code extension (also known as Solidity by Nomic Foundation) provides language support for Solidity and integration with Hardhat and Foundry projects. Key features include:

    • Code completions: Autocomplete for contract instances, globally available variables, built-in types, and import directives.
    • Navigation: Support for 'go to definition', 'go to type definition', and 'go to references'.
    • Symbol renames: Ability to rename identifiers across the entire codebase.
    • Hover help: Display of type and signature information on hover.
    • Inline validation: Real-time compiler warnings and errors.
    • Code actions: Quick fixes for visibility modifiers, data locations, interface function implementation, mutability constraints, and address checksums.
    • Formatting: Document formatting for Solidity files.
  7. Overview of Hardhat Configuration Variables

    Configuration Variables in Hardhat 3 are named values used in the project configuration that are read only when needed (lazy loading). They provide several advantages over standard environment variables:

    • Lazy loading: Values are read only upon access, allowing tasks to run without unnecessary variables.
    • Validation and type safety: Values are validated and converted to specific types (e.g., URL, bigint) with clear error messages.
    • Extensibility: Plugins can define custom sources for values (e.g., encrypted vaults).
    • Format reuse: A single stored value can be formatted differently for multiple configuration fields.
    • Fallback values: Default values can be provided to prevent resolution errors.
    • Security: Values are stored outside the repository, reducing the risk of accidentally committing sensitive data (unlike .env files).
  8. Overview of Hardhat 3 core features and tutorial goals

    Hardhat 3 provides a development environment for Ethereum smart contracts. The core workflow involves compiling smart contracts, writing and executing tests, deploying contracts to live networks, and verifying those contracts on Etherscan. Prerequisites for using Hardhat include a basic understanding of smart contract concepts, Node.js, and command-line interface (CLI) usage.
  9. Overview of Hardhat VS Code extension features

    The Hardhat VS Code extension (also known as Solidity by Nomic Foundation) provides language support for Solidity and integration with Hardhat and Foundry projects. Key features include:

    • Code completions: Autocomplete for contract instances, globally available variables, built-in types, and import directives.
    • Navigation: Support for 'go to definition', 'go to type definition', and 'go to references'.
    • Symbol renames: Ability to rename identifiers across the entire codebase.
    • Hover help: Display of type and signature information when hovering over code.
    • Inline validation: Real-time compiler warnings and errors as you type.
    • Code actions: Quick fixes for visibility modifiers, data locations, interface function implementation, mutability constraints, and address checksums.
    • Formatting: Document formatting specifically for Solidity files.
  10. Overview of hardhat-toolbox-viem functionality and bundled plugins

    The @nomicfoundation/hardhat-toolbox-viem toolbox provides a comprehensive set of tools for Hardhat projects, including:

    • Network Interaction: Uses viem as the connection library.
    • Testing: Supports Solidity tests via Hardhat's built-in runner and TypeScript tests via the Node.js test runner and hardhat-viem-assertions.
    • Verification: Contract verification via hardhat-verify.
    • Deployment: Contract deployment via Hardhat Ignition.

    It automatically installs the following plugins as peer dependencies:

    • @nomicfoundation/hardhat-ignition
    • @nomicfoundation/hardhat-ignition-viem
    • @nomicfoundation/hardhat-keystore
    • @nomicfoundation/hardhat-network-helpers
    • @nomicfoundation/hardhat-node-test-runner
    • @nomicfoundation/hardhat-viem
    • @nomicfoundation/hardhat-viem-assertions
    • @nomicfoundation/hardhat-verify
  11. Overview of Hardhat 3 development environment

    Hardhat 3 is a development environment for Ethereum and EVM-compatible blockchains designed to help developers compile, deploy, test, and debug Solidity smart contracts. Key features of version 3 include a Rust-powered runtime for improved performance, comprehensive testing support for both Solidity and TypeScript, multi-chain support (including Base and OP Stack simulation), and a robust plugin ecosystem.
  12. Overview of Hardhat 3 Build Profiles

    Build Profiles allow developers to define multiple Solidity compiler configurations for different use cases within a single project. This enables optimization for specific workflows, such as using a fast configuration for local testing and a highly optimized configuration for mainnet deployment.