ShardeumShardeum Logo
Connect to ShardeumDelegate NowGithubTestnet SHM
Shardeum Documentation
Shardeum Documentation
Shardeum Documentation
What is Shardeum?Network Endpoints & ExplorerEVM Overview
Supported Wallets
Developers
Testnet Quickstart
Deploy Smart Contracts
Using RemixUsing FoundryUsing Hardhat
Deploy dApps
JSON-RPC GuideNetwork Interfaces
Node TypesRun a Full NodeRun a Validator NodeAdvanced OperationsRun an RPC NodeDelegate SHM
Node Setup OverviewRun an RPC NodeRun a Full NodeRun a Validator Node
Ecosystem
Nordstern.Finance
DevelopersDeploy Smart Contracts

Using Hardhat

Overview

This guide is a step-by-step reference to create and deploy a SimpleStorage contract on Shardeum using Hardhat.

Deployment Guide

Prerequisites

  • Node.js and npm installed
  • A funded wallet. You can claim test SHM from the faucet
  • Access to a Shardeum RPC endpoint

Step 1: Initialize a Hardhat Project

mkdir shardeum-hardhat
cd shardeum-hardhat
npm init -y
npm install --save-dev hardhat
npx hardhat

When prompted, select:Create an empty hardhat.config.js

Create project folders:

mkdir contracts scripts

Step 2: Install Dependencies

npm install --save-dev @nomicfoundation/hardhat-ethers ethers dotenv

Step 3: Add Environment Variables

Create a .env file in the project root:

SHARDEUM_RPC=YOUR_SHARDEUM_RPC_URL
PRIVATE_KEY=YOUR_WALLET_PRIVATE_KEY

Security note:

  • Never commit .env
  • Add .env to .gitignore

Step 4: Write the SimpleStorage Contract

Create contracts/SimpleStorage.sol:

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
 
contract SimpleStorage {
    uint256 public value;
 
    event ValueUpdated(uint256 newValue);
 
    constructor(uint256 _value) {
        value = _value;
        emit ValueUpdated(_value);
    }
 
    function setValue(uint256 _value) external {
        value = _value;
        emit ValueUpdated(_value);
    }
}

Step 5: Configure Hardhat

Replace hardhat.config.js with:

require("dotenv").config();
require("@nomicfoundation/hardhat-ethers");
 
module.exports = {
  solidity: "0.8.20",
  networks: {
    shardeum: {
      url: process.env.SHARDEUM_RPC,
      accounts: [process.env.PRIVATE_KEY],
      // chainId: <YOUR_CHAIN_ID>
    },
  },
};

Chain IDs differ across Shardeum networks (testnet vs mainnet). Use the chain ID for the specific network you’re deploying to

Step 6: Compile

npx hardhat compile

Step 7: Create a Deploy Script

Create scripts/deploy.js:

const hre = require("hardhat");
 
async function main() {
  const SimpleStorage = await hre.ethers.getContractFactory("SimpleStorage");
 
  // constructor arg for SimpleStorage(uint256 _value)
  const contract = await SimpleStorage.deploy(1);
 
  await contract.waitForDeployment();
 
  console.log("SimpleStorage deployed to:", await contract.getAddress());
}
 
main().catch((error) => {
  console.error(error);
  process.exitCode = 1;
});

Step 8: Deploy to Shardeum

npx hardhat run scripts/deploy.js --network shardeum

Copy the deployed contract address and view it on Shardeum explorers

(Optional) Interact Quickly

You can interact via Hardhat console:

npx hardhat console --network shardeum

Then:

const c = await ethers.getContractAt("SimpleStorage", "<CONTRACT_ADDRESS>");
await c.value();
await c.setValue(42);
await c.value();

Previous

Using Foundry

Next

Deploy dApps

On this page

OverviewDeployment GuidePrerequisitesStep 1: Initialize a Hardhat ProjectStep 2: Install DependenciesStep 3: Add Environment VariablesStep 4: Write the SimpleStorage ContractStep 5: Configure HardhatStep 6: CompileStep 7: Create a Deploy ScriptStep 8: Deploy to Shardeum

Footer

Company name

India's EVM Compatible Layer 1 Blockchain

© 2026 Shardeum, Inc. All rights reserved.

XGitHubYouTube

General

  • Home
  • Roadmap
  • Testnet SHM
  • Ambassador Program
  • Blog

Community

  • Telegram
  • Discord
  • Twitter
  • GitHub

Resources

  • Explorer
  • Whitepaper
  • FAQs
  • Brand Assets
  • Public Drive

Contact

  • General Enquiries
  • Partnership Enquiries