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:
1
require('hardhat-ethernal');
Copied!
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).
By default, transactions will be traced using experimentalAddHardhatNetworkMessageTraceHook, showing CALLx and CREATEx operations in the dashboard. You can disable this feature with the ethernalTrace flag.
You can automatically reset your workspace by setting the ethernalResetOnStart property to the name of the workspace. Everytime the node starts, all accounts/blocks/transactions/contracts will be deleted.
1
extendEnvironment((hre) => {
2
hre.ethernalSync = true;
3
hre.ethernalWorkspace = 'Workspace';
4
hre.ethernalTrace = false;
5
hre.ethernalResetOnStart = 'Hardhat';
6
});
Copied!

Logging In

You can log in either by using
1
ethernal login
Copied!
Or by calling Hardhat commands with extra env variables:
1
ETHERNAL_EMAIL=[email protected] ETHERNAL_PASSWORD=yourpwd npx hardhat node
Copied!

Synchronize artifacts

Require the package in your deploy script:
1
require('hardhat-ethernal');
Copied!
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.
By default, the push function is not going to upload AST to Ethernal. If you want to use "Storage" tab on contracts pages, you'll need to activate it. To do so, set the hre.ethernalUploadAst = true flag in your Hardhat config file (this will upload the ast field, as well as the source field).

Example

1
const hre = require("hardhat");
2
3
async function main() {
4
5
const Greeter = await hre.ethers.getContractFactory("Greeter");
6
const greeter = await Greeter.deploy("Hello, Hardhat!");
7
8
await hre.ethernal.push({
9
name: 'Greeter',
10
address: greeter.address
11
})
12
13
console.log("Greeter deployed to:", greeter.address);
14
}
15
16
main()
17
.then(() => process.exit(0))
18
.catch(error => {
19
console.error(error);
20
process.exit(1);
21
});
22
Copied!

Reset a workspace

You can manually reset a workspace by calling: hre.ethernal.resetWorkspace(workspaceName) (async function). All accounts/blocks/transactions/contracts will be deleted;