Inspiration

The idea for Divvy came from watching a friend struggle with something that should be simple: splitting podcast revenue with her co-hosts. Every single month, she'd spend 30+ minutes calculating percentages, sending individual PayPal transfers (each with fees), and maintaining spreadsheets to ensure everyone received their correct payment. When one co-host questioned if the math was right, it created tension in a relationship built on trust. I realized this wasn't just her problem—it's a fundamental flaw in how digital payments work today. Whether you're a podcast team splitting sponsorships, freelance developers sharing project payments, content creators paying editors, or small businesses managing partner distributions, the process is always the same broken pattern: manual calculations, multiple transfers, compound fees, and a requirement that everyone trust whoever's doing the distribution. The question struck me: In an era where we can program money, why are we still manually splitting payments, as if it were 1995? That's when I discovered MNEE stablecoin and realized I could solve this with smart contracts. Divvy was born: a system where payments split themselves, instantly, with mathematical certainty, and zero trust is required.

What it does

Divvy automates revenue sharing through smart contracts. When a customer makes a payment using MNEE tokens, the platform instantly splits the funds to multiple recipients according to predefined percentages, all in a single blockchain transaction.

Key capabilities:

  • Instant Distribution: Payments are split and distributed atomically in one transaction
  • Transparent Records: All transactions are recorded on-chain and publicly verifiable
  • Zero Manual Work: Once configured, splitting happens automatically with no intervention needed
  • Flexible Configuration: Support for any number of recipients with custom percentage allocations
  • Control Features: Contract creators can pause/resume splits as needed

The platform serves content creators, teams, businesses, and anyone who needs to split revenue automatically and transparently.

How we built it

The project follows a clean separation between smart contracts and frontend:

Smart Contracts (Hardhat + Solidity):

  1. SplitPayment Contract: The core contract that handles individual revenue splits

    • Validates recipient addresses and percentage sums (must equal 100%)
    • Uses basis points (10000 = 100%) for precise percentage calculations
    • Implements rounding error handling by giving the last recipient any remainder
    • Includes pause/resume functionality for contract creators
    • Tracks total received and individual recipient earnings
  2. SplitPaymentFactory Contract: Factory pattern for creating split contracts

    • Allows users to create unlimited split configurations
    • Maintains a registry of all created contracts
    • Emits events for easy frontend indexing

The contracts use OpenZeppelin's SafeERC20 for secure token transfers and ReentrancyGuard to prevent reentrancy attacks. All state changes emit events for efficient off-chain querying.

Frontend (React + Vite + Tailwind CSS):

  • Built with React Router for navigation between pages (Home, Create, Dashboard, Pay, Split Details)
  • Integrated Web3 wallet connection using Context API for global state management
  • Created reusable components for wallet modals, transaction tracking, and user feedback
  • Implemented responsive design with mobile-first approach
  • Used ethers.js for all blockchain interactions

Development Workflow:

  • Used Hardhat for local development, testing, and deployment
  • Wrote comprehensive tests for smart contracts
  • Deployed to Sepolia testnet for testing before mainnet
  • Configured environment variables for secure key management

Challenges we ran into

1. Rounding Errors in Percentage Calculations When splitting payments, integer division can lead to rounding errors. For example, splitting 100 tokens with percentages [33.33%, 33.33%, 33.34%] could result in 33 + 33 + 33 = 99 tokens distributed, leaving 1 token unaccounted for.

Solution: I implemented a "last recipient gets remainder" approach. The formula ensures: $$\sum_{i=0}^{n-2} \left\lfloor \frac{amount \times percentage_i}{10000} \right\rfloor + remainder = amount$$

This guarantees that 100% of the payment is always distributed, with any rounding differences going to the last recipient.

2. Gas Optimization Creating a new contract for each split configuration can be expensive. I needed to balance functionality with gas costs.

Solution: Used the factory pattern to minimize deployment costs. Each split contract is lightweight, containing only essential state variables. The factory maintains the registry, allowing efficient querying without storing all data in a single contract.

3. User Experience with Web3 Blockchain interactions are inherently complex for non-technical users. Transaction confirmations, gas fees, and network switching can be confusing.

Solution: Built a comprehensive UI feedback:

  • Clear transaction status modals showing pending, success, and error states
  • Network detection with automatic prompts to switch networks
  • Tooltips and help text explaining each step
  • Loading states and skeleton screens for better perceived performance
  • Error messages that translate technical blockchain errors into user-friendly language

4. Handling Failed Transactions Transactions can fail for various reasons: insufficient gas, user rejection, network issues, or contract errors.

Solution: Implemented robust error handling:

  • Try-catch blocks around all contract interactions
  • User-friendly error messages categorized by error type
  • Transaction retry mechanisms where appropriate
  • Clear feedback when users need to approve token spending

5. State Management Across Wallet Disconnections When users disconnect their wallet or switch accounts, the application state needs to update accordingly.

Solution: Used React Context API with event listeners for wallet state changes. The WalletContext listens to MetaMask's accountsChanged and chainChanged events, automatically updating the UI when users switch accounts or networks.

6. Testing Smart Contracts Ensuring contract security and correctness required comprehensive testing, especially for edge cases.

Solution: Wrote extensive test suites covering:

  • Normal payment splitting scenarios
  • Edge cases (single recipient, many recipients, very small amounts)
  • Security scenarios (reentrancy attempts, unauthorized access)
  • Percentage validation (invalid sums, zero addresses)
  • Pause/resume functionality

Accomplishments that we're proud of

  • Zero-loss Payment Splitting: Successfully implemented a rounding error solution that guarantees 100% of payments are always distributed, with mathematical precision
  • Gas-Efficient Architecture: Designed a factory pattern that allows unlimited split contracts while keeping individual deployment costs low
  • User-Friendly Web3 Experience: Created an intuitive interface that makes blockchain interactions accessible to non-technical users, with comprehensive error handling and clear feedback
  • Security-First Design: Implemented industry best practices, including reentrancy guards, safe token transfers, and comprehensive input validation
  • Full-Stack Integration: Successfully integrated smart contracts with a modern React frontend, handling complex state management and real-time transaction tracking
  • Comprehensive Testing: Built extensive test coverage for both normal operations and edge cases, ensuring contract reliability and security
  • Production-Ready Deployment: Successfully deployed to Sepolia testnet (mainnet-ready), with proper environment configuration and deployment scripts

What we learned

Building Divvy was a comprehensive journey through full-stack Web3 development:

Smart Contract Development:

  • Deepened my understanding of Solidity patterns, particularly the factory contract pattern for creating multiple instances
  • Learned to handle edge cases like rounding errors in percentage calculations (using basis points and giving the last recipient the remainder)
  • Implemented security best practices: reentrancy guards, input validation, and proper error handling using custom errors
  • Gained experience with OpenZeppelin's battle-tested contracts (SafeERC20, ReentrancyGuard)

Frontend Development:

  • Built a modern React application with Web3 integration using ethers.js
  • Created a responsive, user-friendly interface with Tailwind CSS
  • Implemented wallet connection handling (MetaMask and other Web3 wallets)
  • Developed real-time transaction status tracking and user feedback systems
  • Learned to handle network switching and provide clear user guidance

Blockchain Integration:

  • Understood the complexities of gas estimation and transaction lifecycle
  • Implemented proper error handling for failed transactions and network issues
  • Learned to work with ERC20 token approvals and transfers
  • Gained experience with testnet deployment and mainnet considerations

Architecture:

  • Designed a factory pattern that allows unlimited split contracts while keeping gas costs reasonable
  • Implemented event-driven architecture for efficient frontend updates
  • Created a modular codebase separating concerns between contracts, frontend, and utilities

These experiences taught me the importance of defensive programming, user experience design, and thorough testing in blockchain development. The result is a platform that makes complex blockchain functionality accessible to users who may have never interacted with smart contracts before.

What's next for Divvy

  • Multi-Token Support: Extend beyond MNEE to support multiple ERC20 tokens, giving users flexibility in their payment methods
  • Recurring Payments: Implement subscription-based revenue splitting for ongoing revenue streams
  • Analytics Dashboard: Add detailed analytics showing payment history, recipient performance, and revenue trends
  • Mobile App: Develop a native mobile application for easier access on the go
  • Layer 2 Integration: Deploy on Layer 2 solutions (Arbitrum, Optimism, Polygon) to reduce gas costs and improve scalability
  • Multi-Signature Support: Add multi-sig functionality for split contracts requiring multiple approvals
  • API Integration: Create a REST API for programmatic access and integration with other platforms
  • Advanced Split Rules: Support for conditional splits, time-based distributions, and milestone-based payments
  • Social Features: Add sharing capabilities, split templates, and community-contributed configurations
  • Audit and Security: Conduct professional smart contract audits and implement additional security measures

Built With

Share this project:

Updates

Submission history