@trifle/stop-feeding-the-cat
v1.0.3
Published
Stop Feeding The Cat - A blockchain game where players compete to be the last one to feed the cat
Readme
Stop Feeding The Cat
A blockchain-based game where players compete to be the last one to feed the cat and win the prize pool.
Game Mechanics
- 13 different items can be fed to the cat (priced $1-$13 in USDC)
- When you feed the cat, a 24-hour timer starts
- If the timer reaches 0, you win the entire prize pool
- Other players can feed the cat to reset the timer and become the new potential winner
- If the same player feeds multiple items, the timer is reduced (max 23 hours reduction)
Contract Features
- EIP-1967 upgradeable smart contract
- ERC-1155 NFT items that are minted and burned when fed
- Configurable admin fee percentage
- Pausable for emergency situations
- Automatic round management
Setup
- Install dependencies:
npm install- Copy
.env.exampleto.envand fill in your values:
cp .env.example .env- Compile contracts:
npm run compileDeployment
Local Network
# Start local node
npm run chain
# Deploy in another terminal
npm run deploy:localBase Sepolia
npm run deploy:baseSepolia
npm run verify:baseSepoliaBase Mainnet
npm run deploy:base
npm run verify:baseTesting
Run the test suite:
npm testTest Coverage
Generate coverage reports:
# Full coverage report
npm run coverage
# V1 contract only
npm run coverage:v1
# V2 contract only
npm run coverage:v2Coverage reports are generated in multiple formats:
- HTML: Open
coverage/index.htmlin your browser - LCOV: For CI/CD integration (
coverage/lcov.info) - JSON: Machine-readable format (
coverage.json)
Current coverage:
- Statements: 96.81%
- Branches: 69.57%
- Functions: 100%
- Lines: 96.06%
Upgrading to V2
The contract supports safe upgrades using OpenZeppelin's UUPS pattern.
V2 Features
- Emergency Pause: Additional pause mechanism independent of regular pause/unpause
- Enhanced Safety: Owner can immediately halt all game operations if needed
- State Preservation: Emergency pause doesn't affect ongoing rounds, just blocks new actions
Upgrade Process
- Prepare the upgrade (validates compatibility):
# Check upgrade compatibility
npm run prepare-upgrade:baseSepolia 2- Perform the upgrade:
# Upgrade to V2
npm run upgrade:baseSepolia 2- Verify the upgrade:
npm run verify:baseSepoliaFuture Versions
To add new versions, follow the pattern in scripts/upgrade.ts and create new contracts like StopFeedingTheCatV3.sol. The upgrade system is designed to handle multiple versions automatically.
Using as NPM Package
After deployment, build the package:
npm run buildThen in another project:
import { StopFeedingTheCat } from '@trifle/stop-feeding-the-cat';
const contractAddress = StopFeedingTheCat.networks[chainId].address;
const abi = StopFeedingTheCat.abi;Network Information
- Base Sepolia: Chain ID 84532
- Base Mainnet: Chain ID 8453
USDC Addresses
- Base Sepolia:
0x036CbD53842c5426634e7929541eC2318f3dCF7e - Base Mainnet:
0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913
