Skip to content

humanity-org/humanity-counter-contract

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

humanity-counter-contract

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.


🛠 Tech Stack

  • 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

🚀 Getting Started

1. Clone the repository

git clone git@github.com:humanity-org/humanity-counter-contract.git
cd humanity-counter-contract

2. Install Dependencies

npm install

3. Configure Environment

Copy the .env.example file to .env:

cp .env.example .env
rm .env.example

Then 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.com

Note: You can use https://humanity-testnet.g.alchemy.com/public if you don't have an Alchemy account. Warning: Always use a dedicated test wallet. Never commit your .env file.

4. Compile the Contract

npx hardhat compile

5. Run Tests

npx hardhat test

6. Deploy to Humanity Protocol Testnet

npx hardhat run scripts/deploy-counter.js --network humanity-testnet

Save the deployed contract address from the output.

7. Verify the Contract

npx hardhat verify --network humanity-testnet <DEPLOYED_CONTRACT_ADDRESS>

View your verified contract on the Humanity Protocol Testnet Explorer.


📁 Project Structure

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)

📝 Contract Overview

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 Details


📚 Resources


⚙️ Prerequisites

  • Node.js 22.14+ (required for Hardhat 2.22+ and Ethers v6 compatibility)
  • Web3 wallet (MetaMask recommended)
  • Testnet tokens from the Humanity faucet

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors