Hardhat Project Setup

Install and use the Hardhat plugin

The Hardhat plugin extends Hardhat network by listening to incoming blocks and synchronizing them directly with the dashboard. Once installed and included, you won't need to run the CLI as it will be able to listen and synchronize blocks directly.

Installation

Add hardhat-ethernal to your package.json, and run npm install or yarn

Synchronize blocks & transactions

In your hardhat-config.jsfile, require the plugin:

require('hardhat-ethernal');

That's it! Blocks and transactions will now be synchronized.

Options

It's possible to disable the synchronization by setting ethernalSync to false on the hre object.

You can also specify which workspace you want to synchronize blocks & transactions to (default to the last one used in the dashboard).

extendEnvironment((hre) => {
hre.ethernalSync = true;
hre.ethernalWorkspace = 'Workspace';
});

Synchronize artifacts

Require the package in your deploy script:

const ethernal = require('hardhat-ethernal');

The plugin will add an ethernal object with a push function on the hre object. This function takes two parameters:

  • name: name of the contract (case sensitive). It needs to match exactly the name of the deployed contract

  • address: address of the contract

You should call this function anytime after the contract has been successfully deployed.

This function returns an empty promise.

Example

const hre = require("hardhat");
const ethernal = require('hardhat-ethernal');
async function main() {
const Greeter = await hre.ethers.getContractFactory("Greeter");
const greeter = await Greeter.deploy("Hello, Hardhat!");
await hre.ethernal.push({
name: 'Greeter',
address: greeter.address
})
console.log("Greeter deployed to:", greeter.address);
}
main()
.then(() => process.exit(0))
.catch(error => {
console.error(error);
process.exit(1);
});