Deploy using Hardhat

If you wish to deploy a smart contract using Hardhat, the first step would be to set up your environment.

Setting up your environment for Hardhat

To create, write and compile a contract in Hardhat, please refer to the following tutorials:

Using Hardhat

To deploy to the HPB network, you'll need to modify the Hardhat configuration file and create a secure file to store your private key in.

You can create a secrets.json file to store your private key by running:

touch secrets.json

Then add your private key to it:

    "privateKey": "YOUR-PRIVATE-KEY-HERE"

Make sure to add the file to your project's .gitignore, and to never reveal your private key.

Please always manage your private keys with a designated secret manager or similar service. Never save or commit your private keys inside your repositories.

Next you can take the following steps to modify the hardhat.config.js file and add HPB as a network:

  1. Import the Ethers plugin

  2. Import the secrets.json file

  3. Inside the module.exports, you need to provide the Solidity version (0.8.1 according to our contract file)

  4. Add the HPB network configuration

// 1. Import the ethers plugin required to interact with the contract 
// 2. Import your private key from your pre-funded HPB account 
const { privateKey } = require('./secrets.json');

module.exports = { 
// 3. Specify the Solidity version, e.g. 0.8.1
 solidity: "0.8.1",
   networks: { 
// 4. Add the HPB network specification 
     hpb: { 
      url: '', 
      chainId: 269, 
      accounts: [privateKey] 

Last updated