Deploying a Smart Contract
This recipe explains how to create, compile, deploy, and verify a simple smart contract on the Nero modular chain Testnet using Hardhat.
Hardhat
Hardhat is a toolset that allows you to compile, deploy, test, and verify your smart contracts.
Setting Up Your Workspace
- Node.js(https://nodejs.org)
Starting a New Project
To initiate a new project, run the following command:
npm init
To install Hardhat in your project, run the following command:
npm install --save-dev hardhat
- To create a Hardhat project by running npx hardhat in your project directory.
- Then, you will be presented with several options for project creation. Select the appropriate options.

Figure 1: npx hardhat
Create Smart Contract
You can create your own smart contract or use the Openzeppelin token smart contract template(https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/ERC20.sol), and place it in the contracts directory of your project.
Modify Hardhat for NERO
The updates to the <hardhat-config-file>
and ./ignition/module/<deploy-file>
files should resemble the following example (specific content should be adjusted according to requirements).
You’ll need a variables(https://hardhat.org/hardhat-runner/docs/guides/configuration-variables#configuration-variables) with the following contents:
NERO_TESTNET_PROVIDER_URL=https://rpc-testnet.nerochain.io
PRIVATE_KEY=add your own private key
API_KEY=add your own etherscan api key
You’ll need a hardhat.config.js and hardhat.config.ts with the following contents:
require("@nomicfoundation/hardhat-toolbox");
require("@nomicfoundation/hardhat-ignition-ethers");
const { vars } = require("hardhat/config");
const NERO_TESTNET_PROVIDER_URL = vars.get("NERO_TESTNET_PROVIDER_URL");
const PRIVATE_KEY = vars.get("PRIVATE_KEY");
module.exports = {
solidity: "0.8.24",
defaultNetwork: "nero_testnet",
networks: {
nero_testnet: {
url: NERO_TESTNET_PROVIDER_URL,
accounts: [PRIVATE_KEY],
},
},
etherscan: {
apiKey: API_KEY,
customChains: [
{
network: "nero_testnet",
chainId: 689,
urls: {
apiURL: "https://api-testnet.neroscan.io/api",
browserURL: "https://testnet.neroscan.io",
},
},
],
enabled: true
},
};
NOTE: You can obtain test coins from this faucet(https://app.testnet.nerochain.io/faucet)
Deploy Smart Contract on Nero Network
- Compile the contract by running npx hardhat compilein the terminal.
- Run
npx hardhat ignition deploy ./ignition/modules/<deploy-file> --network <select-network>
in the root of the project directory. - Visit the Testnet Explorer(https://testnet.neroscan.io/) to view the deployed contract.
Congratulations! You have successfully deployed your own Smart Contract.

Figure 2: NERO testnet scan
Conclusion
This recipe has walked you through creating and deploying a basic smart contract using Hardhat. Although the recipe used the testnet, you can follow the same process for the mainnet.​​