What is Hardhat | Ethereum Truffle Replacement

Hardhat for Ethereum dApp Development

by Alexandra Kropova from Mammoth Interactive

Must-know if you’ve been using Truffle. Introduction to Hardhat for NFT and dApp development with Solidity smart contracts. Learn about Hardhat Network and more!

Want to learn more? Enroll in Hello Coding 4.0. Free in the Mammoth Unlimited Membership. Get 300+ courses and 2,000 hours at a dirt-cheap price.


 What is Hardhat?

  • development environment to compile, deploy, test, and debug your Ethereum software
  • helps developers manage and automate the recurring tasks that are inherent to the process of building smart contracts and dApps

Hardhat vs Truffle

  • Run Solidity locally
    • local Ethereum network designed for development
  • Debugging-first
  • Fast iteration
  • TypeScript support – typed language
  • Preferred in community over Truffle
    • Can migrate projects from Truffle


  • designed as a library
  • stack trace
  • multiple Solidity compiler versions
  • robust Mainnet forking
  • contract verification in Etherescan
  • interactive JavaScript console

Deep Dive into Hardhat Features

Hardhat Network

  • built-in with Hardhat Network
  • local Ethereum network node designed for development
  • akin to Ganache
  • deploy your contracts, run your tests and debug your code.

Solidity stack traces

  • If a transaction or call fails, Hardhat Network will throw an exception.
    • will have a combined JavaScript and Solidity stack trace: stack traces that start in JavaScript/TypeScript up to your call to the contract, and continue with the full Solidity call stack.


  • print logging messages IN SOLIDITY

Mainnet forking

  • copy the state of the mainnet blockchain into your local environment, including all balances and deployed contracts

In a local environment forked from mainnet

    • can execute transactions to invoke mainnet-deployed contracts, or interact with the network in any other way that you would with mainnet.
    • In addition, you can do anything supported by a non-forked Hardhat Network: see console logs, get stack traces, or use the default accounts to deploy new contracts

Mining modes

  • Hardhat Network can be configured to automine blocks, immediately upon receiving each transaction, or it can be configured for interval mining, where a new block is mined periodically, incorporating as many pending transactions as possible.

Connecting a wallet or Dapp to Hardhat Network

  • Hardhat will always spin up an in-memory instance of Hardhat Network on startup by default.
  • possible to run Hardhat Network in a standalone fashion so that external clients can connect to it.
  • could be MetaMask, your Dapp front-end, or a script.


Ask a question in the comments below.

Want to learn more? Enroll in Hello Coding 4.0. Free in the Mammoth Unlimited Membership. Get 300+ courses and 2,000 hours at a dirt-cheap price.
Mammoth Interactive Favicon

Why you NEED to take this course :

Get in Touch.

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.