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
When prompted, select:Create an empty hardhat.config.js
Create project folders:
Step 2: Install Dependencies
Step 3: Add Environment Variables
Create a .env file in the project root:
Security note:
- Never commit
.env - Add
.envto.gitignore
Step 4: Write the SimpleStorage Contract
Create contracts/SimpleStorage.sol:
Step 5: Configure Hardhat
Replace hardhat.config.js with:
Chain IDs differ across Shardeum networks (testnet vs mainnet). Use the chain ID for the specific network you’re deploying to
Step 6: Compile
Step 7: Create a Deploy Script
Create scripts/deploy.js:
Step 8: Deploy to Shardeum
Copy the deployed contract address and view it on Shardeum explorers
(Optional) Interact Quickly
You can interact via Hardhat console:
Then: