Hardhat Integration with Remix

Aniket
Remix Project
Published in
3 min readJun 18, 2021

In our quest to make Remix better for your workflow, we have integrated some Hardhat features and configurations so you can go between the two platforms!

Note: The integration is new as of Remix IDE v0.12.0 and Remixd v0.3.6

Remixd and Hardhat

Remixd is a way to connect your local file system with Remix IDE and now you can use Remixd to share a Hardhat project with Remix IDE. A Remix web-socket plugin that listens specifically for Hardhat actions will be used for the communication of Remix with Hardhat.

Hardhat will be listening on port 65522.

Enable Hardhat Compilation using Remix IDE

In the File Explorers, once you connect to localhost from Remix IDE, a shared Hardhat project will be loaded under the workspace localhost.

Select a file to compile. Move to Solidity Compiler plugin. Right above the Compile button, there will be an additional checkbox saying Enable Hardhat Compilation .

Check this box and click on Compile .

Now the contracts will be compiled on Remix. Along with that, Hardhat’s compilation will also be performed with the compiler configuration defined in Solidity Compiler plugin. A file named remix-compiler.config.js will be created in the root directory of the project. This file holds the compiler configuration from Remix IDE.

Result of hardhat compilation will be shown in Remix IDE’s terminal

Hardhat compilation result

and also on remixd console.

Deploy on Hardhat network using Remix IDE

Remix has introduced a plugin called Hardhat Provider to ease the deployment to a hardhat localhost network. The plugin can be activated from Remix plugin manager.

activate Hardhat Provider plugin

Once it is activated, just go to Deploy and Run Transactions plugin , open the ENVIRONMENT dropdown, there will be a new option called Hardhat provider .

Hardhat Provider Environment

Just select Hardhat Provider and a modal will be opened with title Hardhat node request showing the info about hardhat node and asking for a JSON-RPC endpoint.

Make sure a hardhat node is running.

Provide the correct endpoint in modal, default one will be already filled there.

Once you click on OK , accounts from hardhat node will be loaded in ACCOUNT dropdown and network id will also be shown.

Further, you can continue to compile and deploy the contract to hardhat network in the usual way.

Feedback Time !!

We strive to make the IDE more convenient and easy to use. Please share your feedback, suggestions or feature request on any of Remix channels on Twitter, Gitter and via email (remix@ethereum.org).

--

--