Skip to main content

Hardhat plugin usage

=nil; provides an example repository containing a Hardhat project that is already configured to support all essential cluster features.

To install the project generator:

npm i @nilfoundation/create-nil-hardhat-project -g

Create a new project:

create-nil-hardhat-template

When inside the project, create an .env file and add the following information inside it:

NIL_RPC_ENDPOINT=NIL_ENDPOINT
SMART_ACCOUNT_ADDR=SMART_ACCOUNT_ADDR
PRIVATE_KEY=PRIVATE_KEY
COMETA_ENDPOINT=COMETA_ENDPOINT
tip

Read this tutorial to learn how to create a smart account.

If possible, link the .env file to the config file for the =nil; CLI:

NIL_CONFIG_INI: path/to/config.ini

In this case, the Hardhat plugin will automatically use the smart account and private key specified in the CLI config file. Whenever the CLI creates a new smart account. the Hardhat plugin will start using said smart account.

It is also possible to create a new smart account directly via the Hardhat plugin by running this task:

smart-account update

To see the smart account details:

smart-account info
Fee credit

The Hardhat plugin has a hardcoded default fee credit that should be enough for most messages. To override this value, specify the feeCredit property in hardhat.config.ts:

feeCredit: 500000