A minimal Hardhat project that deploys a Storage contract to Polkadot Hub, demonstrating the foundational workflow for EVM-compatible smart contract development on Polkadot.
This project shows how to write, compile, and deploy a simple storage contract using Hardhat and Hardhat Ignition. The Storage contract stores a single uint256 value on-chain and exposes two functions — store and retrieve — making it ideal as a first hands-on example.
The Storage contract implements:
store(uint256 num)— writes a number to contract stateretrieve()— reads and returns the stored number
basic-hardhat/
├── contracts/
│ └── Storage.sol # Core storage contract
├── ignition/
│ └── modules/
│ └── Storage.ts # Ignition deployment module
├── artifacts/ # Compiled contracts (auto-generated)
├── cache/ # Hardhat cache (auto-generated)
├── typechain-types/ # TypeScript types (auto-generated)
├── hardhat.config.ts # Hardhat configuration
├── package.json # Project dependencies
├── tsconfig.json # TypeScript configuration
└── README.md # This file
npm installnpx hardhat vars set PRIVATE_KEYnpx hardhat compilenpx hardhat ignition deploy ignition/modules/Storage.ts --network polkadotTestnetConfirm the network prompt when asked. The deployment output will include the deployed contract address.
Hardhat Configuration Variables provide secure, local storage for sensitive data.
| Variable | Required | Description |
|---|---|---|
PRIVATE_KEY |
Yes | Private key of a funded account (no 0x prefix) |
Useful commands:
# Set a variable (prompts for value)
npx hardhat vars set PRIVATE_KEY
# List all variables
npx hardhat vars list
# Read a variable
npx hardhat vars get PRIVATE_KEY
# Delete a variable
npx hardhat vars delete PRIVATE_KEY
# Show storage location
npx hardhat vars path- Node.js v22.13.1 or later
- npm
- A funded account on Polkadot Hub TestNet — get tokens from the Polkadot Faucet
| Component | Version |
|---|---|
| Hardhat | ^2.22.16 |
| Solidity | 0.8.28 |
| Node.js | v22.13.1+ |
- Deploy a Basic Contract with Hardhat — step-by-step guide on docs.polkadot.com
- Hardhat Documentation
- Hardhat Ignition
- Hardhat Configuration Variables