humanity-counter-contract is a demonstration project for deploying and verifying smart contracts on the Humanity Protocol testnet. This repository showcases the complete development workflow using Hardhat, from writing and testing a simple Counter contract to deploying and verifying it on-chain.
- Hardhat 2.22.17 - Ethereum development environment
- Ethers.js 6.14.4 - Blockchain interaction library
- Solidity 0.8.20 - Smart contract language
- Hardhat Toolbox 5.0.0 - Testing, verification, and development plugins
- dotenv - Environment variable management
git clone git@github.com:humanity-org/humanity-counter-contract.git
cd humanity-counter-contractnpm installCopy the .env.example file to .env:
cp .env.example .env
rm .env.exampleThen update the .env file with your credentials:
PRIVATE_KEY=<your-wallet-private-key>
HUMANITY_TESTNET=https://humanity-testnet.g.alchemy.com/v2/<your-alchemy-api-key>
HUMANITY_API_URL=https://humanity-testnet.explorer.alchemy.com/api
HUMANITY_BROWSER_URL=https://humanity-testnet.explorer.alchemy.comNote: You can use
https://humanity-testnet.g.alchemy.com/publicif you don't have an Alchemy account. Warning: Always use a dedicated test wallet. Never commit your.envfile.
npx hardhat compilenpx hardhat testnpx hardhat run scripts/deploy-counter.js --network humanity-testnetSave the deployed contract address from the output.
npx hardhat verify --network humanity-testnet <DEPLOYED_CONTRACT_ADDRESS>View your verified contract on the Humanity Protocol Testnet Explorer.
humanity-counter-contract/
├── contracts/
│ └── Counter.sol # Counter smart contract
├── scripts/
│ └── deploy-counter.js # Deployment script
├── test/
│ └── Counter.test.js # Contract tests
├── hardhat.config.js # Network configuration
└── .env # Environment variables (gitignored)
The Counter.sol contract demonstrates:
- increment() - Increases counter by 1
- decrement() - Decreases counter by 1 (with bounds checking)
- reset() - Resets to 0 (owner only)
- getCount() - Returns current value
- Network: Humanity Protocol Testnet
- Chain ID: 7080969
- RPC: https://humanity-testnet.g.alchemy.com/v2/
- Explorer: https://humanity-testnet.explorer.alchemy.com
- Node.js 22.14+ (required for Hardhat 2.22+ and Ethers v6 compatibility)
- Web3 wallet (MetaMask recommended)
- Testnet tokens from the Humanity faucet