Built with ❤️ by Rather Labs
CakePay is a decentralized bill-splitting dApp that makes group expense management as easy as slicing cake. Whether you're splitting rent with roommates, managing team dinners, or tracking shared subscriptions, CakePay provides a transparent, blockchain-powered solution that works seamlessly across Web3 wallets, Lemon Cash, and Farcaster Mini Apps.
- 🎂 Create "Cakes": Group multiple people together for ongoing shared expenses
- 🥧 Add "Ingredients": Track expenses with custom splits and multiple payers
- 🔪 Cut the Cake: Batch submit expenses on-chain to update balances
- 💰 Settle Up: Pay what you owe or claim what you're owed with transparent on-chain settlement
- 📊 Track Everything: Real-time balance updates with complete transaction history
- 🔐 Trustless & Transparent: All financial logic lives on the blockchain
- Standard Web3: Full Wagmi + RainbowKit integration
- Lemon Cash: Native integration with Lemon Cash Mini App SDK
- Farcaster: Seamless Warpcast Mini App experience
- One codebase, three wallet experiences
- Create groups (cakes) with 2+ members
- Weighted expense splitting (equal or custom ratios)
- Multiple payers per expense
- Configurable interest rates for late payments
- Democratic voting to disable groups
- On-Chain: Core financial data, balances, and settlements
- Off-Chain: Extended metadata, descriptions, and receipts
- User ID system for gas-efficient storage
- Batched transactions to minimize gas costs
- Pixel-art inspired design
- Real-time balance calculations
- Pending vs settled expense tracking
- Member leaderboards showing who's owed the most
- Mobile-first responsive design
CakePay follows a hybrid on-chain/off-chain architecture optimized for both security and user experience:
┌─────────────────────────────────────────────────────────────┐
│ CakePay Architecture │
├─────────────────────────────────────────────────────────────┤
│ │
│ ┌─────────────────────────────────────────────────────┐ │
│ │ Frontend Layer (Next.js 14) │ │
│ │ │ │
│ │ • Wagmi/RainbowKit (Standard Web3) │ │
│ │ • Lemon Cash Mini App SDK │ │
│ │ • Farcaster/Warpcast SDK │ │
│ │ • Server Components (Database APIs) │ │
│ │ • Client Components (Wallet Interactions) │ │
│ └────────────────────┬────────────────────────────────┘ │
│ │ │
│ ┌────────────────────┴──────────────────────────────────┐ │
│ │ Smart Contract Layer (Ethereum/L2s) │ │
│ │ │ │
│ │ CakeFactory.sol │ │
│ │ • User ID Mapping (address → uint64) │ │
│ │ • Cake Management (groups, members, weights) │ │
│ │ • Batched Ingredients (expenses with payers) │ │
│ │ • Balance Tracking (int256[] per cake) │ │
│ │ • Settlement System (pay/claim functions) │ │
│ │ • Interest Accrual (configurable rates) │ │
│ │ • Voting System (disable inactive cakes) │ │
│ └────────────────────┬──────────────────────────────────┘ │
│ │ │
│ ┌────────────────────┴──────────────────────────────────┐ │
│ │ Data Layer (Supabase) │ │
│ │ │ │
│ │ • User Profiles (username, avatar) │ │
│ │ • Cake Metadata (name, description, icon) │ │
│ │ • Ingredient Details (name, description, receipts) │ │
│ │ • Status Tracking (pending, submitted, settled) │ │
│ └────────────────────────────────────────────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────┘
Creating a Cake:
- User fills form with group details → Frontend
- Validates all members are registered on-chain → Smart Contract Query
- Submits transaction via wallet → Smart Contract Write
- Event emitted → Frontend listens
- Metadata saved → Database
Adding Expenses:
- User adds expense (off-chain) → Database (pending status)
- Multiple expenses accumulate → Database
- User clicks "Submit on-chain" → Smart Contract (batched)
- Balances updated → Smart Contract
- Status updated to "submitted" → Database
- Node.js 18+
- npm or yarn
- MetaMask or other Web3 wallet
- (Optional) Lemon Cash app for mini-app testing
- (Optional) Warpcast for Farcaster integration
# Clone the repository
git clone https://github.com/rather-labs/rather-cake-pay.git
cd rather-cake-pay
# Install smart contract dependencies
cd hardhat
npm install
# Install frontend dependencies
cd ../frontend
npm installcd hardhat
# Compile contracts
npm run compile
# Deploy to local network
npm run node # Terminal 1
npm run deploy:local # Terminal 2
# Deploy to Sepolia testnet
npm run deploy:sepolia
# Deploy to Base Sepolia
npm run deploy:base-sepoliacd frontend
# Configure environment variables
cp .env.example .env.local
# Edit .env.local with your values
# Run development server
npm run devVisit http://localhost:3000 to see the app!
- Solidity 0.8.24: Latest secure Solidity version
- Hardhat: Development framework
- Hardhat Ignition: Deployment system
- Slither: Security analysis (mandatory in CI)
- Next.js 14: App Router with Server Components
- React 18: Modern React with hooks
- TypeScript: Full type safety
- Wagmi: Ethereum interactions
- RainbowKit: Wallet connection UI
- Viem: Low-level Ethereum library
- Lemon Cash SDK: Mini-app integration
- Farcaster SDK: Warpcast mini-app support
- Tailwind CSS: Utility-first styling
- Supabase: PostgreSQL database
- Vercel: Frontend hosting (recommended)
- Tenderly: RPC provider + debugging
User connects wallet
→ Checks if registered on-chain
→ If not: Transaction to register (gets user ID)
→ Saves profile to database
→ Redirects to dashboard
User clicks "Create Group"
→ Fills form (name, members, interest rate)
→ System validates all members registered on-chain
→ Transaction sent to create cake
→ On-chain user IDs used (not wallet addresses)
→ Cake metadata saved to database
→ User redirected to cake page
User clicks "Add Expense"
→ Fills form (name, amount, payers, split)
→ Expense saved to database (status: pending)
→ User can add multiple expenses
→ When ready: "Submit on-chain" button
→ Batches all pending expenses
→ Single transaction updates balances
→ Status changes to "submitted"
User views their balance
→ If positive (owed): Click "Claim"
→ If negative (owes): Click "Pay"
→ Transaction sent with exact amount
→ Balance updated on-chain
→ UI reflects new balance
The core contract managing all financial logic.
Cake (Group)
struct Cake {
uint64 createdAt;
uint64 lastCutAt;
uint64 lastCutBatchedIngredientsId;
uint16 interestRate;
bool active;
address token; // 0x0 for ETH
bool[] votesToDisable;
uint64[] memberIds; // User IDs (not addresses)
uint16[] memberWeights; // BPS (sum = 10000)
int256[] currentBalances; // Positive = owes, negative = owed
}BatchedCakeIngredients (Expense)
struct BatchedCakeIngredients {
uint64 createdAt;
uint16[] weights; // Per-member split
uint64[] payerIds; // Who paid
uint256[] payedAmounts; // How much each paid
}| Function | Description | Gas Optimization |
|---|---|---|
registerUser(address) |
Register wallet and get user ID | One-time per user |
createCake(...) |
Create new group | User IDs instead of addresses |
addBatchedCakeIngredients(...) |
Add expenses batch | Multiple expenses in one tx |
cutCake(uint128) |
Update balances | Processes all pending ingredients |
payCakeSlice(uint128) |
Pay what you owe | Direct balance update |
claimCakeSlice(uint128) |
Claim what you're owed | Transfers funds to caller |
Frontend (frontend/.env.local)
# Contract Deployment
NEXT_PUBLIC_CONTRACT_ADDRESS_ETH_SEPOLIA=0x...
NEXT_PUBLIC_CHAIN_ID=11155111
# RPC
NEXT_PUBLIC_RPC_URL=https://sepolia.gateway.tenderly.co
# Database
NEXT_PUBLIC_SUPABASE_URL=https://...supabase.co
NEXT_PUBLIC_SUPABASE_ANON_KEY=eyJ...
# Wallets
NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID=...Contracts (hardhat/.env)
SEPOLIA_RPC_URL=https://sepolia.infura.io/v3/...
SEPOLIA_PRIVATE_KEY=0x...
ETHERSCAN_API_KEY=...cd hardhat
# Run tests
npm test
# Run with coverage
npm run coverage
# Security analysis (mandatory)
slither . --exclude-dependenciescd frontend
# Type check
npx tsc --noEmit
# Lint
npm run lint
# Format check
npm run format:check
# Build test
npm run build# Test everything locally before pushing
./scripts/test-ci.sh
# Test only contracts
./scripts/test-ci.sh contracts
# Test only frontend
./scripts/test-ci.sh frontend- Slither Analysis: Mandatory in CI pipeline
- OpenZeppelin Patterns: Used where applicable
- Reentrancy Protection: All external calls protected
- Integer Overflow: Built-in Solidity 0.8+ checks
- Access Control: Proper member validation
- Never commit private keys or secrets
- All contract changes require security review
- Slither must pass before merging
- Use established patterns (OpenZeppelin)
- Test edge cases thoroughly
We welcome contributions! Please see CONTRIBUTING.md for detailed guidelines.
- Fork the repository
- Create feature branch from
develop - Make your changes
- Run
./scripts/test-ci.shlocally - Submit PR to
developbranch - Wait for review and CI to pass
We follow Conventional Commits:
feat(contracts): add voting system
fix(frontend): correct balance calculation
docs(readme): update deployment steps
- Smart Contracts: See hardhat/README.md
- Contributing Guide: See CONTRIBUTING.md
- Frontend API: See frontend/lib/api/
- Database Schema: See Database Data Structures section
- Core smart contract implementation
- Multi-wallet support (Web3, Lemon, Farcaster)
- User registration system
- Cake creation and management
- Expense tracking and batching
- Balance calculation and settlement
- Receipt upload integration
- Token swaps for multi-currency payments
- Recurring expense automation
- Mobile app (React Native)
- Advanced analytics dashboard
- Social features (group chat, activity feed)
This project is licensed under the MIT License - see the LICENSE file for details.
Built by Rather Labs - A leading blockchain development studio specializing in Web3 applications, smart contracts, and decentralized systems.
Powered by:
- Lemon Cash - Crypto banking made simple
- Farcaster - Decentralized social protocol
- Ethereum - World computer