Skip to content

hihenluo/Critterholes

Repository files navigation

๐Ÿ•ณ๏ธ CritterHoles on Base

React TypeScript Vite TailwindCSS Celo Reown Wagmi Farcaster Cloudflare License: MIT


๐ŸŽฎ Overview

CritterHoles on Celo is a blockchain-based casual game built on Celo Mainnet, where players whack critters, earn points, and claim on-chain rewards.
The game uses React + TypeScript + Vite with Reown AppKit, wagmi, and a Cloudflare backend for claim verification.


๐Ÿงฉ Gameplay

๐ŸŽฏ Objective

  • Hit critters as they pop up before time runs out.
  • Each critter type gives different scores based on rarity:
Critter Image Points Rarity
๐Ÿน Mole mole 1 Common
๐Ÿฆจ Skunk skunk 2 Uncommon
๐Ÿ‡ Rabbit rabbit 3 Rare

๐Ÿช“ Requirement

You must own a Hammer NFT to play. Mint one on the Mint Page using the mint() function in the Celo contract.

๐Ÿ’ฐ Rewards

  • After the game ends, scores are converted into $CHP tokens.
  • Random rewards include $ETHIX or $GoodDollar.
  • Players have a daily claim limit, read from the contract.
  • Claims are verified through a Cloudflare Function at /api/claim.

๐Ÿช™ Game Economy

  • $CHP โ€” main in-game point token.
  • $ETHIX and $GoodDollar โ€” bonus tokens randomly distributed.
  • Smart contracts are managed in the Hardhat repository.

โš™๏ธ Architecture

Layer Description
Frontend React 19 + TypeScript + Vite 7
Blockchain Celo Mainnet
Wallet Integration Reown AppKit + wagmi + viem
Backend Cloudflare Functions (/functions/claim.ts)
UI Framework TailwindCSS + Framer Motion
MiniApp Farcaster integration

๐Ÿง‘โ€๐Ÿ’ป Setup & Development

1๏ธโƒฃ Clone the Repository

git clone https://github.com/hihenluo/Critterholes.git
cd Critterholes

2๏ธโƒฃ Install Dependencies

npm install

3๏ธโƒฃ Environment Variables

In the functions/ directory, create an .env file:

SIGNER_PRIVATE_KEY=your_private_key
ETHIX_TOKEN_ADDRESS=your_ethix_token_address
G_TOKEN_ADDRESS=your_gooddollar_token_address
CELO_RPC_URL=https://forno.celo.org

These variables are used by the Cloudflare Function /api/claim to sign reward claims and interact with Celo smart contracts.


๐Ÿš€ Run the Game

Start Development Server

npm run dev

Build for Production

npm run build

Preview Production Build

npm run preview

โ˜๏ธ Cloudflare Function

/functions/claim.ts

Handles reward claiming logic:

  • Validates connected wallet and score.
  • Generates and returns claim signature (v, r, s, databytes).
  • Interacts with Celo contracts to confirm reward eligibility.

Deploy to Cloudflare with:

npx wrangler deploy

๐Ÿง  Game Flow Summary

  1. Player connects wallet using Reown.
  2. System checks Hammer NFT ownership.
  3. If missing, mint one before playing.
  4. During the game, player earns points.
  5. After game ends, claim reward via /api/claim.
  6. Backend signs transaction and executes claim() on-chain.

๐Ÿ”— Useful Links


๐Ÿ“œ License

Licensed under the MIT License


๐Ÿ’ซ Built with โค๏ธ by the CritterHoles Team

on Celo Mainnet โ€ข Powered by Reown & Farcaster

About

Games Mini App on Farcaster

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors