The CBG: Press button, reset timer, win prize. Blockchain game on Celo.
The CBG is a competitive blockchain game on Celo. Players press a button to reset a countdown timer - the last player to press before time expires wins the entire prize pool. Each press adds an entry fee to the pool, creating an ever-growing prize. Features include free daily plays, real-time activity feeds, player statistics, winner history, and a progressive jackpot. Built entirely on smart contracts for transparency and trustlessness.
Built as a Turborepo monorepo with Next.js 14 (App Router) and TypeScript. Frontend uses wagmi v2 + viem for blockchain interactions, RainbowKit for wallet connections, and Framer Motion for animations. Smart contracts are written in Solidity 0.8.28 with OpenZeppelin, deployed via Hardhat Ignition to Celo networks. Real-time game state syncs through wagmi's useWatchContractEvent hooks with 1-second polling fallback. Historical event fetching powers the "Last Plays" feed by querying ButtonPressed events from recent blocks. Client-side timer synchronization prevents race conditions by calculating time remaining from contract's timerEnd timestamp. Farcaster Mini App integration enables walletless gameplay through @farcaster/miniapp-wagmi-connector. Free play eligibility tracked on-chain with 24-hour cooldown mapping. ENS resolution displays player avatars and names. All game logic runs trustlessly on-chain - no backend required.

