Aleks Shenshin
Aleks Shenshin

Reputation: 2196

How can I configure Hardhat to connect to RSK Testnet?

To connect to an Ethereum Testnet, the configuration in hardhat.config.js is like this:

  networks: {
    ropsten: {
      url: `https://eth-ropsten.alchemyapi.io/v2/${ALCHEMY_API_KEY}`,
      accounts: [`${ROPSTEN_PRIVATE_KEY}`]
    }
  }

(taken from here: https://hardhat.org/tutorial/deploying-to-a-live-network.html )

How can I add a network config for the RSK Testnet?

(Note that I'm using a seed phrase instead of a raw private key)

Upvotes: 5

Views: 244

Answers (1)

bguiz
bguiz

Reputation: 28587

The network config in hardhat.config.js could be defined like so:

  networks: {
    rsktestnet: {
      chainId: 31,
      url: 'https://public-node.testnet.rsk.co/',
      gasPrice: Math.floor(minimumGasPriceTestnet * TESTNET_GAS_MULT),
      gasMultiplier: TESTNET_GAS_MULT,
      accounts: {
        mnemonic: mnemonic,
        initialIndex: 0,
        // if using RSK dPath
        // Ref: https://developers.rsk.co/rsk/architecture/account-based/#derivation-path-info
        path: "m/44'/37310'/0'/0",
        // if using Ethereum dPath (e.g. for Metamask compatibility)
        // path: "m/44'/60'/0'/0",
        count: 10,
      },
    },
  },

Where

  • mnemonic is your BIP-39 seed phrase.
  • TESTNET_GAS_MULT set to any value more than or equal to 1
  • minimumGasPriceTestnet see this answer or this answer

Upvotes: 7

Related Questions