Skip to content


Hardhat Create Project


Hardhat is a popular development framework for compiling, testing, and deploying Solidity smart contracts. Since Moonbeam is Ethereum compatible, with a few lines of extra configuration, you can use Hardhat as you normally would to develop on Moonbeam.

Configure Hardhat to Connect to Moonbeam

To get started with Hardhat you must have an npm project. If you do not yet have one, to create one you can run:

npm init

Once you have a npm project, install Hardhat:

npm install hardhat

Then to create a Hardhat config file in your project, run:

npx hardhat

In your hardhat.config.js file, add network configurations for a Moonbeam development node and the Moonbase Alpha TestNet:

// Moonbeam Development Node Private Key
const privateKeyDev =
// Moonbase Alpha Private Key
const privateKeyMoonbase = "YOUR-PRIVATE-KEY-HERE";
// Moonriver Private Key - Note: This is for example purposes only. Never store your private keys in a JavaScript file.
const privateKeyMoonriver = "YOUR-PRIVATE-KEY-HERE";

module.exports = {
   networks: {
      // Moonbeam Development Node
      dev: {
        url: 'http://localhost:9933/',
        chainId: 1281,
        accounts: [privateKeyDev]
      // Moonbase Alpha TestNet
      moonbase: {
        url: ``,
        chainId: 1287,
        accounts: [privateKeyMoonbase]
      // Moonriver
      moonbase: {
        url: ``,
        chainId: 1285,
        accounts: [privateKeyMoonriver]


If you are interested in a more detailed step-by-step guide, check out our specific tutorial about using Hardhat with Moonbeam.