This repository contains the Solidity smart contracts for the Critter Holes (CH) game ecosystem. It includes an ERC1155 Hammer NFT, an ERC20 Points token, and the main CHGame logic contract, designed for deployment on EVM-compatible chains like Celo.
Follow these steps to clone, configure, and deploy the contracts.
First, clone this repository to your local machine and navigate into the project directory.
git clone https://github.com/hihenluo/hardhat.git
cd your-repo-nameInstall all the required npm packages, including Hardhat and OpenZeppelin.
npm installThis is the most important step. You must configure your environment variables.
Create a new file named .env in the root of the project. Then, copy and paste the following template, filling in your own values.
# Your wallet's private key (do NOT share this)
PRIVATE_KEY="YOUR_DEPLOYER_PRIVATE_KEY"
# Your RPC URL for the network (e.g., Celo Mainnet or Alfajores Testnet)
CELO_RPC_URL="https://forno.celo.org"
# Your Celoscan API Key (for verification)
ETHERSCAN_API_KEY="YOUR_CELOSCAN_API_KEY"
# --------------------------------------------------------------------
# LEAVE THESE BLANK FOR NOW - You will fill them in after deployment.
# --------------------------------------------------------------------
# This address comes from Step 5
CHP_ADDRESS=""
# Address for your 2nd reward token (e.g., cUSD, WETH)
TOKEN2_ADDRESS="0x..."
# Address for your 3rd reward token
TOKEN3_ADDRESS="0x..."
# The wallet address your backend will use to sign claim messages
SUPER_SIGNER_ADDRESS="0x..."Deployment is a two-part process. You must run deploy.js first.
Compile all the contracts to make sure there are no errors.
npx hardhat compileThis script deploys CritterHolesPoints.sol and CritterHolesHammer.sol.
npx hardhat run scripts/deploy.js --network celoIMPORTANT: After this script finishes, copy the
CritterHolesPoints (CHP)contract address from your terminal.
Paste it into your.envfile for theCHP_ADDRESSvariable.
After updating your .env file with the CHP_ADDRESS, you can deploy the main CHGame.sol contract.
npx hardhat run scripts/deploy2.js --network celoYour deployment is now complete! The terminal will show the final CHGame contract address.
To verify your contracts on Celoscan, use the verify command.
(These both take 1 constructor argument: the deployer's address)
npx hardhat verify --network celo <YOUR_HAMMER_CONTRACT_ADDRESS> "<YOUR_DEPLOYER_WALLET_ADDRESS>"
npx hardhat verify --network celo <YOUR_POINTS_CONTRACT_ADDRESS> "<YOUR_DEPLOYER_WALLET_ADDRESS>"(This takes 5 constructor arguments, in order)
npx hardhat verify --network celo <YOUR_CHGAME_ADDRESS> "<DEPLOYER_ADDRESS>" "<CHP_ADDRESS>" "<TOKEN2_ADDRESS>" "<TOKEN3_ADDRESS>" "<SUPER_SIGNER_ADDRESS>"Pull requests are welcome!
If you'd like to contribute, please fork the repository and create a new pull request. For major changes, please open an issue first to discuss what you would like to change.
- Fork the project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature) - Commit your Changes (
git commit -m 'Add some AmazingFeature') - Push to the Branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License.
See the SPDX-License-Identifier in the contract files for more details.