Skip to content

CodeByNikolas/Base-Hackathon---BasedBills

Repository files navigation

BasedBills πŸ’°

A decentralized bill splitting application built on Base network with on-chain USDC settlements. Split expenses with friends and settle them transparently on-chain.

πŸ“Ή Demo Videos

Watch this Loom video

Watch this YouTube video

🌟 Features

Core Functionality

  • Decentralized Groups: Create expense groups with multiple members
  • Smart Bill Splitting: Equal or custom split amounts per person
  • On-chain Settlement: Settle balances using USDC on Base network
  • Transparent Process: All transactions verified on BaseScan
  • Mobile-First Design: Optimized for mobile wallet interactions

Advanced Features

  • 🎲 Gamble Mode: All-or-nothing settlement where one random member pays all debts
  • ❌ Settlement Rejection: Cancel settlements before approval/deposit (bills remain unsettled)
  • πŸ“Š Enhanced Balance Views: Real-time creditor/debtor breakdown
  • πŸ“‹ Complete Bill History: Track all expenses with timestamps and settlement IDs
  • πŸ” Settlement Tracking: Audit trail for every completed settlement
  • ⚑ Custom Bill Splitting: Specify exact amounts per participant
  • 🏭 Gas-Efficient Groups: EIP-1167 minimal proxy pattern for cheap group creation

πŸ“Έ Screenshots

Main Dashboard

Main Page

Fund USDC Modal

Fund Page

Group Management

Group Page

πŸš€ Quick Start

Frontend Development

# Install dependencies
npm install

# Run development server
npm run dev

Open http://localhost:3000 to view the app.

Smart Contracts

The smart contracts are deployed and verified on Base Sepolia:

cd hardhat
npm install
npm run deploy  # Deploy new contracts

See hardhat/README.md for detailed contract documentation.

πŸ—οΈ Architecture

Frontend Stack

  • Next.js 15 - React framework
  • OnchainKit - Coinbase's Web3 toolkit
  • wagmi - React hooks for Ethereum
  • viem - TypeScript interface for Ethereum

Smart Contract Stack

  • Solidity 0.8.28 - Smart contract language
  • Hardhat - Development environment
  • OpenZeppelin - Security-audited contract libraries
  • EIP-1167 - Minimal proxy pattern for gas efficiency

πŸ“± How It Works

  1. Connect Wallet: Users connect their Base-compatible wallet
  2. Create Group: Start a new expense group with friends
  3. Add Bills: Record shared expenses and split them
  4. Track Balances: See who owes what in real-time
  5. Settle On-Chain: Approve and fund settlements with USDC
  6. Automatic Distribution: Smart contracts handle the payouts

πŸ”— Deployed Contracts

Base Mainnet (Production) - Verified & Ready

Contract Address BaseScan
GroupFactory 0x97191494e97a71a2366e459f49e2c15b61fb4055 Read Contract
Registry 0x071164b35b896bc429d5f518c498695ffc69fe10 Read Contract
Group Logic 0xb2a71877fbd3ea1a21ae894c7299b6f0b625a8aa Read Contract
USDC 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913 Read Contract

Base Sepolia (Testnet) - Latest Deployment

Contract Address BaseScan
GroupFactory 0x759dead21af026b4718635bee60487f3a71d25f9 Read Contract
Registry 0x071164b35b896bc429d5f518c498695ffc69fe10 Read Contract
Group Logic 0xb2a71877fbd3ea1a21ae894c7299b6f0b625a8aa Read Contract
MockUSDC 0x97191494e97a71a2366e459f49e2c15b61fb4055 Read Contract

πŸ†• New Test Feature: The MockUSDC contract now includes a mintForTest() function that anyone can call to mint 100 USDC for testing purposes!

βœ… All contracts are verified and open source on BaseScan. The app defaults to Base Sepolia (Testnet) for development but users can switch to Base Mainnet for production use.

🟠 Smart Network Guidance: The app shows helpful orange messages guiding users:

  • On Base Mainnet: Suggests switching to Base Sepolia for easier testing without funds
  • On Base Sepolia: Encourages using the mintForTest() function to get 100 USDC instantly

The messages are displayed in attractive orange boxes with proper line breaks for better readability.

πŸ“š For detailed smart contract documentation, API reference, and deployment guides, see hardhat/README.md

πŸ› οΈ Development

Environment Setup

Create a .env file:

NEXT_PUBLIC_ONCHAINKIT_API_KEY=your_coinbase_api_key
PRIVATE_KEY=your_wallet_private_key
ETHERSCAN_API_KEY=your_etherscan_api_key

Project Structure

β”œβ”€β”€ app/                    # Next.js app directory
β”‚   β”œβ”€β”€ components/        # React components
β”‚   β”œβ”€β”€ tutorial/          # OnchainKit tutorial page
β”‚   └── page.tsx          # Main application
β”œβ”€β”€ hardhat/              # Smart contracts
β”‚   β”œβ”€β”€ contracts/        # Solidity contracts
β”‚   β”œβ”€β”€ scripts/          # Deployment scripts
β”‚   └── ignition/         # Hardhat Ignition modules
└── public/               # Static assets

πŸ§ͺ Testing

The smart contracts have been extensively tested with:

  • Multi-account group creation
  • Complex bill splitting scenarios
  • Settlement process validation
  • USDC integration testing

πŸ†• Test USDC Minting

For testing purposes, the MockUSDC contract includes a mintForTest() function:

  • Anyone can call this function to get 100 USDC
  • Perfect for testing bill splitting and settlement flows
  • No authentication required - just connect your wallet and call the function
// In your wallet or frontend:
mockUSDC.mintForTest() // Mints 100 USDC to your wallet

πŸ” Security

  • Uses OpenZeppelin's audited contract libraries
  • All contracts verified on BaseScan
  • Implements proper access controls
  • Follows Solidity best practices

πŸ“„ License

MIT License - Built for the Base hackathon

🀝 Contributing

This project was built for the Base hackathon. Feel free to fork and improve!


Built with ❀️ on Base using OnchainKit