Configure Hardhat for Rootstock


  1. Rootstock-compatible accounts/address.
  1. Wallet

Getting Started

Step 1: Set up Your Hardhat Environment

  • Install dotenv

To manage environment variables, install dotenv using the following command:

  npm install dotenv
  • Create a .env file
    • In the rootstock-quick-start-guide project root, create a .env file and add your private keys (do not share this file):

Note: Depending on your desired network, using a Testnet and Mainnet private key is optional, as you're not required to have separate private keys in your environment variable.

Replace "your_mainnet_private_key" and "your_testnet_private_key" with your private keys. For information on how to retrieve your private keys, see How to export an account's private key.

Step 2: Configure Private Keys

To configure your rskMainnet and rskTestnet private keys, you'll need to update your hardhat.config.js file in the root directory with your private keys.

  • Copy the code snippet below and replace the existing code in your hardhat.config.js file. See diff file for initial code.

<!-- Hardhat configuration -->
  module.exports = {
    solidity: "0.8.20",
    networks: {
      rskMainnet: {
        url: "",
        chainId: 30,
        gasPrice: 60000000,
        accounts: [process.env.ROOTSTOCK_MAINNET_PRIVATE_KEY]
      rskTestnet: {
        url: "",
        chainId: 31,
        gasPrice: 60000000,
        accounts: [process.env.ROOTSTOCK_TESTNET_PRIVATE_KEY]

Replace "API_KEY" with the api key that you have created for this App. For information on how to create an api key, see How to get started with RPC API.

Step 3: Fund Your Accounts


Receive updates

Get the latest updates from the Rootstock ecosystem