Inspiration

"You'll get your cut after I recoup."

Every creative collaboration starts with this promise. A producer fronts $3,000 for studio time. A photographer covers equipment rental. A course creator pays for hosting and ads. They tell their collaborators: "Trust me, once I break even, we'll split everything fairly."

But trust is fragile. Without transparency, collaborators wonder: Did we really only sell 50 copies? Are you sure you hit the recoup target? Why does your math say I'm owed $180 when I calculated $220?

We saw this problem everywhere: Music producers arguing with artists. YouTubers disputing revenue with editors. Indie game devs fighting over Steam sales splits. The root cause? Manual accounting in an age that demands automation.

When we discovered the MNEE Hackathon, we realized we could build something nobody else had: a payment system with programmable recoup logic. Not "send money and hope for the best," but "the contract enforces the agreement automatically."

Hydra isn't just a payment tool, it's a trust machine for creators. You set the recoup target, define your splits, and share a checkout link. The blockchain handles the rest: tracking payments, flipping modes when the target hits, and letting everyone withdraw their exact share, verified on-chain.

No more spreadsheets. No more disputes. Just code keeping promises.

Building Hydra taught us something powerful: the best blockchain applications don't ask users to change their behavior—they take what people already do (recoup-first agreements) and make it impossible to mess up. This isn't blockchain for blockchain's sake. It's financial infrastructure that creators actually need, powered by MNEE tokens that make it all seamless.

What it does

Hydra is a collaborative checkout system with programmable payment splits. Creators set up deals where one collaborator recoups their investment first (getting 100% of payments), then the contract automatically flips to percentage-based splits for everyone else. All payments use MNEE tokens, all splits are transparent on-chain, and all withdrawals are self-service.

How it works

Create a Deal - Set up collaborators with wallet addresses, define post-recoup splits (e.g., 70% / 20% / 10%), choose who recoups first, set the target amount, and add product pricing.

Optionally, you can use the Negotiator Agent to create fair deal terms if you don't know where to start. No more awkward conversations about money! (Future updates will use back-and-forth email negotiations to loop in all parties)

Share Checkout Link - Get a shareable payment link. Buyers connect their wallet and pay with MNEE tokens. Optional content URLs are revealed after payment for digital goods delivery.

Automatic Mode Flip - Payments go 100% to the recoup recipient until the target is hit. When the threshold is crossed, the contract automatically switches to split mode and divides future payments according to percentages. Everything happens on-chain with zero manual intervention.

Withdraw Anytime - Each collaborator sees their owed balance in real-time and can withdraw MNEE directly to their wallet with one click.

Transparency Built-In - Public ledger page shows all payments and splits. Anyone can verify the math on Etherscan without needing a wallet.

Hydra is built entirely on the MNEE ERC-20 token contract (0x8ccedbAe4916b79da7F3F612EfB2EB93A2bFD6cF). Our deployed CollabDealFactory (0xB4DF502B0b964a481253B034Ad3d2b25cCeF2869) accepts MNEE as its sole payment token, hardcoded in the constructor. Every payment, split, and withdrawal in Hydra directly calls functions on the MNEE token contract (approve, transferFrom, transfer). The integration is verifiable on-chain via Etherscan: https://etherscan.io/address/0xB4DF502B0b964a481253B034Ad3d2b25cCeF2869#code

How we built it

Smart Contracts (Solidity)

We built two core contracts deployed on Ethereum mainnet:

  • CollabDealFactory (0xB4DF502B0b964a481253B034Ad3d2b25cCeF2869) - Factory pattern for creating deals, with the MNEE token address (0x8ccedbAe4916b79da7F3F612EfB2EB93A2bFD6cF) hardcoded in the constructor
  • CollabDeal - Individual deal contracts with immutable collaborators, splits, and recoup logic

Key architectural decisions:

  • Enum-based mode switching - RECOUP vs POST_RECOUP modes enable automatic payment logic changes
  • Pull-over-push withdrawals - Recipients call withdraw() themselves (prevents reentrancy attacks)
  • Basis points (bps) for precision - Store percentages as integers (7000 = 70%) to avoid floating-point rounding errors
  • Deterministic dust handling - Rounding errors always go to the first recipient (no lost funds)

MNEE Token Integration: Every payment flow calls the MNEE contract directly: mneeToken.transferFrom(buyer, address(this), amount); // Payment mneeToken.transfer(recipient, owed[recipient]); // Withdrawal

Frontend (Next.js 16 + Web3)

  • Next.js 16 with Turbopack for blazing fast builds
  • wagmi v2 + viem for type-safe Ethereum interactions
  • RainbowKit for seamless wallet connections
  • TanStack Query for smart caching of on-chain data
  • IPFS (Pinata) for decentralized metadata storage (content URLs for digital goods)

Smart Features:

  • Dynamic checkout links with automatic origin detection
  • Pay-to-reveal content URLs stored in IPFS metadata
  • Real-time mode flip detection from transaction logs
  • Public ledger pages (no wallet required) for transparency

Development & Testing:

  • Foundry for smart contract development (26 comprehensive tests)
  • Tested on Sepolia with MockMNEE before mainnet deployment
  • Full contract verification on Etherscan for transparency

Challenges we ran into

The Rounding Problem: Where Does the Dust Go?

When splitting payments by percentages, Solidity's integer math creates "dust"—tiny amounts that don't divide evenly. Splitting 11 MNEE by 70/20/10 should yield 7.7, 2.2, 1.1, but integers round to 7, 2, 1—leaving 1 MNEE unaccounted for. We implemented deterministic dust handling where all rounding errors go to the first recipient, ensuring no funds lock in the contract while maintaining fairness.

The Mode Flip Timing: Race Conditions

When a payment crosses the recoup threshold mid-transaction, how much goes to recoup vs splits? If recouped = 28 MNEE and payment = 15 MNEE, we calculate overage: send 2 MNEE to finish recoup, then split the remaining 13 MNEE. The mode flip happens atomically within the transaction—no race conditions possible.

Stack Too Deep Errors in Solidity

Complex functions with many local variables hit Solidity's 16-variable stack limit. We enabled via_ir = true in Foundry config to use the intermediate representation compiler, which optimizes stack usage automatically.

wagmi v2 Type System

wagmi v2's hooks return union types like bigint | undefined | {}, breaking TypeScript comparisons. We added explicit type guards everywhere to ensure runtime safety.

Hydration Mismatch with window.location.origin

Next.js server-side rendering couldn't access window.location.origin, causing hydration errors. We created a custom useAppUrl() hook that returns empty string on server, actual origin after client hydration, and supports NEXT_PUBLIC_APP_URL for production deployments.

IPFS Upload Failures

Network issues could break deal creation if Pinata uploads failed. We implemented graceful fallback to localStorage—metadata uploads to IPFS first, but stores locally if it fails, ensuring demo resilience.

Testing Edge Cases

We wrote 26 comprehensive Foundry tests covering exact recoup boundaries, overages, rounding, and all edge cases. This caught 3 critical bugs before mainnet deployment.

Accomplishments that we're proud of

We Built the First Recoup-First Payment System for MNEE

As far as we can tell, this is the first smart contract that implements automatic recoup-first logic with mode switching. Plenty of platforms do 50/50 splits or multi-sig treasuries, but none flip payment logic mid-stream based on cumulative totals. We turned a common real-world agreement ("you recoup first, then we split") into executable code.

Zero Manual Intervention, Ever

The mode flip isn't triggered by an admin button or off-chain oracle—it's pure on-chain math. When recouped >= recoupTarget, payments switch from 100% to percentage splits automatically. No human in the loop, no trust required, no way to cheat the system.

Production-Ready on Day One

We didn't build a hackathon demo; we built infrastructure. Our contracts are deployed to Ethereum mainnet (0xB4DF502B0b964a481253B034Ad3d2b25cCeF2869), verified on Etherscan, covered by 26 comprehensive tests, using security best practices (ReentrancyGuard, pull-over-push, pausable), and gas-optimized. Real creators could use this today.

Transparent by Design

Every deal has a public ledger page—no wallet required. Anyone can see who the collaborators are, what percentage each person gets, how much has been recouped, every payment ever made, and exact balances owed. All verifiable on Etherscan. Trust isn't required when the math is public.

IPFS Integration for Content Delivery

We solved the "what are they buying?" problem. Creators can attach content URLs that only reveal after payment. Metadata stored on IPFS (decentralized, tamper-proof), with the hash on-chain. Pay-to-access digital goods, web3-native.

It Just Works

We built one-click checkout links, automatic wallet detection, real-time balance updates, clear error handling, and mobile-responsive UI. The hardest part of web3 UX is making it not feel like web3.

Solved the Rounding Problem

When you split 11 tokens by 70/20/10%, you get fractional amounts Solidity can't handle. We implemented deterministic dust handling so no funds ever get locked, and the behavior is predictable and documented. Every wei is accounted for.

What we learned

Smart Contracts Are Compilers for Agreements

We started thinking of smart contracts as "code that moves money." By the end, we realized they're something deeper: executable agreements. When you write if (recouped >= recoupTarget), you're encoding a promise that can't be broken. This changed how we approached the entire architecture. Every function became a question: "What promise are we making, and how do we make it impossible to break?"

On-Chain Transparency Is a Feature, Not a Bug

We almost made the ledger page wallet-gated because that's what most web3 apps do. Then we realized: why? The whole point is transparency. Making the ledger publicly readable without a wallet turned out to be the feature users loved most. Lesson learned: embrace blockchain's strengths instead of hiding them to feel more "web2."

Integer Math Is Harder Than It Looks

Solidity's "no decimals" constraint sounds simple until you split 11 tokens by 70/20/10%. We learned to use basis points for precision, handle rounding deterministically, test every edge case, and document behavior clearly. This applies beyond Solidity—any financial system needs this level of rigor.

Pull Over Push Isn't Just About Reentrancy

We implemented pull-over-push withdrawals to prevent reentrancy attacks. But we discovered another benefit: users control their own timing. No batch payouts, no waiting for admin approval. Recipients withdraw when they want. The security pattern became a UX feature.

IPFS Isn't Optional for Web3 Apps

Storing URLs on-chain is expensive. Storing them in a database defeats the purpose. IPFS gives you decentralized storage with on-chain verification. We learned to plan for IPFS from day one, not as a feature add-on.

Gas Optimization vs Security: Security Wins

We could've micro-optimized with inline assembly. We chose readable, auditable Solidity instead. A bug costs infinitely more than saved gas. The "cheapest" code isn't always the best code.

What Users Care the Most About

They care about: "Can I share this link? Will my collaborators get paid correctly?" Technical excellence enables simplicity, but simplicity is what users see.

The MNEE Ecosystem Is Ready

Working with an established ERC-20 token taught us the value of standards. We didn't need to convince anyone to trust our token, MNEE already exists. Building on existing infrastructure is easier than building from scratch.

What's next for Hydra

AI-Powered Fair Splits (Already Live!)

We built something unique: the Negotiator Agent. Creators describe their collaboration in plain English—"I produced this album for $500, my friend mixed it, another designed the artwork"—and GPT analyzes it to suggest fair percentage splits, who should recoup first, realistic recoup targets, and fair market pricing. The AI output auto-fills the entire deal form. One paragraph becomes a complete, fair agreement. This isn't just a time-saver—it's a fairness engine that helps collaborators avoid awkward money conversations while ensuring everyone gets treated equitably.

Next Evolution: Train on real deal data, add dispute resolution, enable multi-round negotiation, and create industry-specific templates.

Subscription & Recurring Revenue

Add monthly subscriptions, streaming royalties, and milestone-based payouts. The recoup logic stays, but payment models expand.

DAO Integration

Turn every deal into a micro-DAO. Collaborators vote on licensing deals, hold governance tokens, and make decisions with revenue-weighted voting power.

Enhanced Content Delivery

Token-gated access, streaming integration, time-limited rentals, and unlock tiers. Make Hydra a full web3 content platform.

Analytics Dashboard

Revenue charts, geographic data, conversion metrics, recoup timeline projections, and collaborator performance tracking.

Social Proof & Discovery

Trending deals homepage, verified creator badges, deal templates marketplace, and success stories. Turn checkout links into a creator network.

White-Label for Platforms

Hydra SDK for platforms like Bandcamp or Patreon. License as infrastructure, scale 100x.

The Vision: Hydra becomes the infrastructure layer for fair collaboration. No lawyers, no spreadsheets, just code keeping promises. Recoup-first splits are just the beginning.

Built With

  • foundry
  • next.js
  • openai
  • pinata
Share this project:

Updates