Hardhat or Truffle? As a beginner blockchain developer, which one do I pick
Published: 2022-06-02 13:40:32

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d7u0vqbwd7cysni1074a.jpeg)
 

In a blockchain developer’s life, one of the major pain point is to find the best-suited framework or tool for him/her. People spend days or weeks finding the right tool for them.  

Similarly, in the Blockchain world, one of the major debate is on choosing between Hardhat or Truffle. 

These development environments help developers to manage many of the tasks that are inherent to developing decentralized applications and smart contracts. 

If you just starting out your career in the blockchain world and, just like us, albeit sometime back, are wondering which one to choose: Hardhat or Truffle, then you’re at the right place!! 🥳🥳   In the below paragraphs, we have discussed both these frameworks and have proceeded further to do a small comparison of sorts.

### Hardhat Tool

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s9cx0vx00rc40xmqy22y.png)
 

Hardhat is an *Ethereum development environment* for developers that allows performing frequent tasks. 

Other than just deploying and running tests, Hardhat also provides some more features that make it more powerful and unique. 

Let's consider these features one by one.

- **Hardhat Network** 

Hardhat comes built-in with **Hardhat Network**, a local Ethereum network node designed for development providing multiple features like automated error messages, mainnet forking, and, mining modes. 

So if you’re using Hardhat, then by default you’re already using Hardhat Network. It mines a block with each transaction that it receives, in order and with no delay.

 

- **Plugins**

Next up is Plugins. 

*Plugins,* in simpler words, are extensions that can be loaded on a program to improve its functionality. 

There are **30+ plugins** used in development with Hardhat which is why it is considered the *backbone of Hardhat.* 

We have listed some of the popular plugins below with their functionalities:

- **[@nomiclabs/hardhat-ethers](https://hardhat.org/plugins/nomiclabs-hardhat-ethers.html):** It allows developers to inject ethers.js into the *Hardhat Runtime Environment.*
- **[@nomiclabs/hardhat-waffle](https://hardhat.org/plugins/nomiclabs-hardhat-waffle.html):** It allows you to add a Waffle-compatible provider to the Hardhat Runtime Environment.
- **[@nomiclabs/hardhat-etherscan](https://hardhat.org/plugins/nomiclabs-hardhat-etherscan.html):** It automatically verifies contracts on Etherscan
- **[hardhat-gas-reporter](https://www.npmjs.com/package/hardhat-gas-reporter):** Gas reporter helps to acknowledge the gas usage per unit test and average gas usage per method.

- **Testing**

Hardhat provides a very simple procedure for testing smart contracts, providing developers to write automated tests when building smart contracts. 

Hardhat provides great [documentation](https://hardhat.org/tutorial/testing-contracts.html) for understanding testing methods with Hardhat.

If you’re new to Hardhat Testing, try our *previous [article](https://medium.com/uv-labs/creating-and-deploying-your-first-smart-contract-466b4d4784e2)* to get a better understanding of Hardhat Testing. 

### The Universe of Truffle Tools

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bhvcio3fwqxiswf6peyp.png)
 

Like Hardhat, Truffle is also a development environment dedicated to Ethereum blockchain. 

Truffle is a highly popular development framework and provides a large community behind the tool.

For decentralized applications development, the developer uses *Truffle Suite*.

The Truffle Suite is an **ecosystem** for Web3 development that consists of three different tools: **Truffle, Ganache,** and **Drizzle**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jwpt3apxumwqw5ukdtjh.png)
 
- **Truffle:** It is a development environment that uses the EVM for smart contract development.
- **Ganache:** Ganache is a tool used to set up your own local Ethereum blockchain that you can use to deploy and test your smart contracts.

Other than that, Ganache enables developers to avoid paying unnecessary gas fees during the developing process. 

- **Drizzle:** Drizzle is a collection of frontend libraries with a Redux store as its basis.

With this, the frontend development becomes a lot easier for the developers. 

Truffle offers several different features like: 

- **Smart Contract Management:** 

Truffle helps you manage the artifacts of the smart contracts so that you can focus on the other parts of the development process and spend less time on the file organization.

- **Scriptable Migration and Deployment:** 

With Truffle, you can write deployment scripts that allow you to account for the fact that your Dapps will change over time. 

- **Powerful Interactive Console:**

Truffle provides 2 different consoles to choose the best tool for your needs. 

(A) Truffle Console: A basic interactive console connecting to any Ethereum client.  To launch the console, use the `truffle console` command.  When you load the console, you'll immediately see the following prompt:
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a3rx693qksvnj2bn0cyk.png)
 

Truffle console will let you connect with the contracts deployed on the EVM client and interact with the contracts in a manner similar to the one that you would use through javascript.

(B) Truffle Develop: An interactive console that also spawns a development blockchain. It serves the same purpose as the `hardhat node`

You can simply launch the Truffle Develop by using the `truffle develop` command

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k6bq19l4a7mme6ghc8oe.png)
 

- **Truffle Dashboard**: 

Recently, Truffle has introduced *Truffle Dashboard,* providing an easier way to use your existing Metamask wallet for your deployments and transactions.  Using Truffle Dashboard is not only easy but is a plug and play.  You can use the Truffle Dashboard inside any Hardhat projects also. Truffle has provided great [documentation](https://trufflesuite.com/docs/truffle/getting-started/using-the-truffle-dashboard/) to follow along and use Truffle Dashboard in your project.

# Which one is more powerful?

Let us compare some of their features and get a final answer to our question!! 💪

### 1. Debugging

Solidity is hard to debug. You just get an error message when something breaks and more often than not, it is painful to debug what exactly went wrong. 

Thankfully, **Hardhat** introduced something known as the [console.log](https://hardhat.org/tutorial/debugging-with-hardhat-network.html#solidity-console-log) feature for Solidity. 

So you can simply import the console plugin and can use it inside your functions. 

This is what it looks like:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pg0hxkthq9yfhxp3z387.png)
 
Add some `console.log` inside the function

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o3kmlhcv2d46n7u41qfb.png)
 

The logging output will show when you run your tests:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w3mw0afhw46l1idsgpra.png)
  

The EVM created by hardhat specifically supports this feature and hence is native to Hardhat Node. This feature alone is a heavy pro for Hardhat.

On the other hand, Truffle has been improving its [debugger](https://trufflesuite.com/docs/truffle/getting-started/using-the-truffle-debugger/#using-the-truffle-debugger) and it also has some plugins for it but Hardhat is considered a more easier and powerful tool used for debugging. 

### 2. Libraries (Ethers and Web3)

Hardhat uses ethersjs by default but can be easily modified to use [Web3](https://hardhat.org/plugins/nomiclabs-hardhat-web3.html#hardhat-web3). Whereas, Truffle uses Web3 as default plugin for development. 

You can also use Etherjs with Truffle but it is considered to be trickier and hard to implement. 

While ethers-js and web3-js are similar, there is a very high uptick in the number of developers using ethers-js as default; this should presumably give you some hint on what you could / should consider for developing.

### 3. Local Ethereum Network node

Hardhat comes inbuilt with [Hardhat Node](https://www.notion.so/local-Ethereum-network-node-7f385e90d47f4911aee1fcc90aee32d5). However, it does not have a GUI for developers to see account info in real-time. 

Truffle, on the other hand, uses [Ganache](https://trufflesuite.com/ganache/) which has to be set up separately. However, it comes with both a CLI and a GUI version allowing flexibility for the developer.

If you prefer the GUI you should choose Ganache.

### 4. Deployment

For deploying a contract, Hardhat uses basic javascript scripts to [deploy](https://hardhat.org/guides/deploying.html#deploying-your-contracts), so it’s easier to get started with it and is relatively simple to use.

Whereas, Truffle uses a [*migration-based*](https://trufflesuite.com/docs/truffle/getting-started/running-migrations/#running-migrations) deployment procedure (*which are js files themselves, but have a sequential order of execution)* which is a bit more complicated for a beginner, but can be helpful in the long term keeping in mind that your deployment needs might change in the future.

But for ease of getting started with deployment, hardhat definitely takes the prize.

### 5. Testing

To perform various tests, both Truffle and Hardhat use the Chai assertion library and Mocha as their testing framework but hardhat also includes [waffle](https://getwaffle.io/).  They’re both strong when it comes to testing.

### 6. Statistics

Before Hardhat was launched, Web3 was the most popular framework for testing out smart contracts. 

Later on, now you can see that the trend changes over time, and Hardhat has gained more popularity as compared Truffle. 

According to the NPMJS Statistics, Truffle has almost 30k weekly downloads. Whereas, Hardhat has around 86k weekly downloads, which is twice as compared Truffle’s. 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zojv9o2xkir9sr3l9rup.png)
 

### 7. Community

Truffle’s [Github](https://github.com/orgs/trufflesuite/discussions) community is quite active and helpful, whereas Hardhat provides a [Discord server](https://discord.com/invite/TETZs2KK4k) for their community support.  It must be noted that the entire Truffle offering is supported by Consensys and hence you can expect a “support helpdesk” treatment.  Hardhat too is developed and managed through an organization: the Nomic Foundation and has an amazing and equally good support system through its discord server.

## Conclusion

It is really hard to say which is the best. The choice of Truffle vs Hardhat comes down to one’s own preferences and use cases, as they both are two powerful tools.

If you’re absolutely new to both frameworks, then you should definitely explore both of them and decide which one is the best for ‘you’.

However, we hope this article was able to give you an insight into the differences between them and was able to help you to find which one to use. 

Tell us which framework do you prefer over the other by tagging us on Twitter at [@uv_labs](https://twitter.com/uv_labs)

Give us a clap if you liked our work.

Authors (open to feedback): 👇

[Pari Tomar](https://medium.com/u/130345445971?source=post_page-----5311a13d173-----------------------------------), [Mayon Francis](https://medium.com/@mayonfrancis) and [Amateur-Dev](https://medium.com/u/9cd26cbd96b9?source=post_page-----5311a13d173-----------------------------------)