Hardhat

Hardhat is a powerful Ethereum development environment that supports editing, compiling, deploying, and verifying smart contracts. This guide walks you through deploying smart contracts to the Neura Testnet using Hardhat in a TypeScript project setup.

Tooling Requirements

Before getting started, ensure your system has the following items:

  • Node.js version v24.2.0 or later

  • A modern package manager (npm or yarn)


Project Setup

Follow the steps below to create a TypeScript Hardhat project configured for Neura.

  1. Create and initialize the project:

mkdir neura-hardhat-template
cd neura-hardhat-template
npm init -y
npm install --save-dev hardhat
npx hardhat init
  1. Install required dependencies:

npm install --save-dev @nomicfoundation/hardhat-toolbox
npm install --save-dev @nomicfoundation/hardhat-verify
npm install dotenv

Environment Configuration

Create a .env file in the root directory and add your deployer private key:

⚠️ Security Warning:

  • Never commit your .env file to version control. Make sure .env is listed in .gitignore.

  • Do not expose your private key in any frontend or client-side code.

  • Use dedicated accounts and rotate keys regularly for test deployments.


Hardhat Configuration for Neura

Configure hardhat.config.ts with the Neura testnet settings:


Example Smart Contract

You can use either of the following sample contracts:

  • contracts/SimpleStorage.sol

  • contracts/Lock.sol (optional) — use this contract for parameterized deployment examples.

Smart Contract Deployment

Supported Deployment Methods:

  • Hardhat scripts (manual)

  • Hardhat Ignition (modular, preferred for parameterized setups)

Deploy to Local Hardhat Node

  1. Start the local node:

  1. In a separate terminal, deploy using Hardhat Ignition:

Or deploy manually via a script:

Deploy to Neura Testnet

  • Script-based deployment:

  • Ignition-based deployment:

  • Redeploy with a new address:

  • Deploy with constructor parameters:


Deployment Scripts

Deploy Using a Hardhat Script

  1. Create scripts/deploy.ts:

  1. Deploy with the following command:

Deploy Using Hardhat Ignition

  1. Create ignition/modules/SimpleStorageModule.ts:

  1. Deploy with the following command:


Testnet Faucet

To deploy contracts on the Neura Testnet, you'll need testnet ANKR tokens for gas.

Claim testnet funds from the faucet:

Neura Testnet Faucet


Deployment Output Examples

Here’s what successful deployments look like using both Hardhat scripts and Hardhat Ignition:

Script-Based Deployment

  • Deployment:

  • Output:

Ignition-Based Deployment

  • Deployment:

  • When prompted:

  • Output:


Last updated