Hardhat Integration

(Supported since Remix IDE v0.12.0 and Remixd v0.3.6)

Remixd and Hardhat

Note: If you have not used remixd before, read more about it here

If remixd is running locally on your device and shared folder is a hardhat project, an additional websocket plugin will be listening on port 65522. According to its documentation,

Hardhat projects are npm projects with the hardhat package installed and a hardhat.config.js file.

The remixd hardhat listener is a websocket plugin similar to remixd and is used to perform Hardhat actions with Remix IDE.

It doesn’t need any extra installation as it is shipped with remixd NPM module.

_images/a-hardhat-remixd.png

Enable Hardhat Compilation

If a hardhat project is shared through remixd and localhost workspace is loaded in Remix IDE, there will be an extra checkbox shown in Solidity Compiler plugin with the label Enable Hardhat Compilation.

_images/a-hardhat-compilation.png

One can check this box to run the compilation for hardhat along with the Remix. The result of the compilation will be shown in the Remix IDE terminal

_images/a-hardhat-compilation-success.png

and also in the remixd terminal.

_images/a-hardhat-compilation-success-remixd.png

Hardhat Provider

In Hardhat, contracts are deployed by starting a local node. Read more about it in Hardhat documentation

Hardhat Provider is a plugin on Remix IDE which enables users to deploy the contract to the Hardhat ‘localhost’ network. This plugin can be activated from Remix IDE plugin manager.

_images/a-hardhat-provider.png

When activated, you will have an extra option in the ENVIRONMENT dropdown of Deploy and Run Transactions plugin with the label Hardhat Provider

_images/a-hardhat-provider-dropdown.png

As soon as you select Hardhat Provider, a modal is opened asking for the Hardhat JSON-RPC Endpoint.

_images/a-hardhat-provider-modal.png

If Hardhat node is running with default options, then the default endpoint value in modal will not need any change. In case, Hardhat node host and port are different, JSON-RPC endpoint should be updated in the modal text box.

Once the correct endpoint is filled in the modal, just click on OK and the accounts from the Hardhat node will be loaded in the ACCOUNT section. Network id will also be shown.

_images/a-hardhat-provider-connected.png

Now, one can start deploying the contract from Remix IDE to the Hardhat local node as usual.