Skip to main content

Configure Hardhat

Introduction

Hardhat is a development environment used to compile, deploy, test, and debug Ethereum software. It helps developers manage and automate the recurring tasks inherent to the process of building smart contracts and launching dApps, as well as supporting various add-on features that streamline this workflow.

The Hardhat framework isn't described here; find that in the Hardhat documentation.

Prerequisites

  • NodeJS

The Hardhat Configuration File

To deploy a contract to Neon EVM with Hardhat, some Neon-specific information must be configured. The configuration file is called hardhat.config.js and is located at the root of your project directory. This JavaScript file can execute any code necessary to create your configuration. Its file schema, variables, and other documentation can be found on the official Hardhat website.

The following config file provides a full example of the hardhat.config.js for connecting Hardhat to a Devnet Proxy using the one-way library on Node.js:

hardhat.config.js

require("@nomicfoundation/hardhat-toolbox");
require("dotenv").config();

/** @type import('hardhat/config').HardhatUserConfig */
module.exports = {
solidity: "0.8.21",
defaultNetwork: "neondevnet",
etherscan: {
apiKey: {
neonevm: "test"
},
customChains: [
{
network: "neonevm",
chainId: 245022926,
urls: {
apiURL: "https://devnet-api.neonscan.org/hardhat/verify",
browserURL: "https://devnet.neonscan.org"
}
},
{
network: "neonevm",
chainId: 245022934,
urls: {
apiURL: "https://api.neonscan.org/hardhat/verify",
browserURL: "https://neonscan.org"
}
}
]
},
networks: {
neondevnet: {
url: "https://devnet.neonevm.org",
accounts: [process.env.PRIVATE_KEY_OWNER],
chainId: 245022926
},
neonmainnet: {
url: "https://neon-proxy-mainnet.solana.p2p.org",
accounts: [process.env.PRIVATE_KEY_OWNER],
chainId: 245022934
}
}
};

The parameters for module.exports include:

  • solidity: version of Solidity used
  • defaultNetwork: default chain (for deploying or testing)
  • etherscan: settings used to verify contracts on-chain read more here
  • networks: the list of the supported networks
    • neondevnet:
      • url: RPC URL
      • accounts: an array of deployer's private keys; in the current example, PRIVATE_KEY_OWNER is stored inside .env file
      • chainId: the network's chain ID

Note that url and chainId can be retrieved from the RPC endpoints table and/or Chainlist.

What next?

See the tutorial on how to use Hardhat to deploy to Neon EVM.

Gotchas

info

Remember, the deployer wallet address needs to have enough tokens to cover the gas cost of a deployment.

Get NEON for Devnet.

Was this page helpful?