Inspiration

Traditional escrow services are broken. When two friends make a bet on a sports game, or when freelancers need payment protection, they face an impossible choice: trust a centralized platform that charges high fees and requires custody of funds, or skip escrow entirely and hope the other party honors the agreement. Smart contract escrows solve the custody problem but introduce a new one: the oracle problem. How does a blockchain know who won the game or whether a milestone was completed?

We were inspired by Polymarket's success as a decentralized truth-discovery mechanism. Thousands of participants stake real money on outcomes, creating a powerful consensus engine for determining what actually happened. We realized: what if we could use Polymarket as an oracle for escrow? Instead of relying on a single trusted party or expensive oracle networks, we could leverage the wisdom of the crowd to automatically settle conditional agreements. This would enable a new category of trustless payments: from casual bets between friends to formal business contracts that were previously impossible to implement efficiently.

What it does

Base Bets is a prediction-powered escrow platform that automatically releases USDC funds based on real-world outcomes verified through Polymarket's prediction markets. Here's how it works:

For Users:

  1. Create an escrow agreement linked to a specific Polymarket prediction (e.g., "Will the Lakers win tonight?")
  2. Deposit USDC into the smart contract
  3. When the Polymarket prediction resolves, funds automatically release to the winning party
  4. Zero manual dispute resolution, zero intermediaries, zero friction

Key Features:

  • Gasless Onboarding: Through Coinbase Smart Wallet and CDP Paymaster, users can create escrow agreements without holding any ETH
  • Trustless Settlement: Polymarket's crowd-verified outcomes trigger automatic fund releases
  • Transparent & Immutable: All escrow terms are visible on-chain with guaranteed execution
  • Low Cost: Base L2's efficient gas fees enable escrow for everyday transactions ($10-$10,000+)

Use Cases:

  • Peer-to-peer bets with automatic settlement
  • Freelance payments contingent on measurable outcomes
  • Conditional business agreements (e.g., payment upon milestone completion)
  • Charitable donations triggered by verified events

How we built it

Smart Contract Layer (Solidity 0.8.20):

  • Built core escrow contracts with security best practices: reentrancy guards, access control, safe token transfers
  • Leveraged OpenZeppelin's audited contracts for ERC-20 handling
  • Deployed to Base Sepolia testnet with contract verification on BaseScan
  • Developed and tested using Hardhat with comprehensive unit and integration tests

Backend Infrastructure (Node.js):

  • Integrated Polymarket's Gamma API to fetch real-time prediction market data and resolution states
  • Built API endpoints to bridge blockchain events with Polymarket outcomes
  • Implemented webhook listeners for escrow creation and resolution events

Frontend Application (Next.js 14):

  • Designed user interface for creating and managing escrow agreements
  • Integrated OnchainKit for seamless Base L2 interactions
  • Implemented wallet connection with support for Coinbase Smart Wallet

Account Abstraction (ERC-4337):

  • Integrated Coinbase Smart Wallet to provide users with ERC-4337 smart accounts
  • Configured CDP Paymaster to sponsor gas fees, enabling completely gasless escrow creation
  • This eliminated the traditional barrier where users need ETH before their first transaction

Development Workflow:

  • Used ethers.js v6 for all blockchain interactions
  • Implemented gas optimizations: minimal storage operations, efficient struct packing, event-based indexing

Challenges we ran into

Frontend-Backend-Blockchain Coordination: Synchronizing state across three layers proved more complex than anticipated. We struggled with ensuring the frontend accurately reflected on-chain escrow status while also displaying real-time Polymarket data. Race conditions between blockchain events and API updates created UX inconsistencies we're still debugging.

Account Abstraction Learning Curve: ERC-4337 and Coinbase Smart Wallet were completely new to our team. Understanding how UserOperations differ from regular transactions, how paymasters sponsor gas, and how to properly configure OnchainKit for Smart Wallet support took significant research and iteration.

Time Constraints: Building a system that bridges two complex protocols (Base L2 smart contracts + Polymarket prediction markets) in a hackathon timeline meant making hard trade-offs. We prioritized getting core contracts deployed and gas sponsorship working over polishing the full user flow.

Accomplishments that we're proud of

Successfully Deployed to Base L2: We got smart contracts deployed, verified, and functional on Base Sepolia. The core escrow logic works: users can create agreements, deposit USDC, and the contract properly manages funds. This was our first time deploying to an L2, and seeing our contracts live on BaseScan was incredibly rewarding.

Implemented Production-Grade Account Abstraction: We didn't just read about ERC-4337, we actually integrated Coinbase Smart Wallet and got gasless transactions working. New users can interact with our escrow contracts without needing ETH, which is a genuine UX breakthrough compared to traditional dapps.

Navigated Complex API Integration: Successfully integrating Polymarket's Gamma API to fetch prediction market states and resolution data demonstrated we can work with external data sources and handle real-world oracle problems, not just toy examples.

Comprehensive Documentation: We produced detailed technical documentation explaining our architecture, technology choices, and design decisions. Even though the project isn't 100% complete, we can clearly articulate what we built and why.

Learned 8+ New Technologies in 48 Hours: Between Base L2, Coinbase Smart Wallet, ERC-4337, CDP Paymaster, OnchainKit, Polymarket API, Hardhat, and Next.js integration—we went from zero to functional knowledge incredibly fast.

What we learned

Account Abstraction is the Future: Before this hackathon, we'd only read about ERC-4337 in theory. Actually implementing it showed us why it's revolutionary: gasless transactions completely change the onboarding experience. No more "you need ETH to do anything" barrier. This is how crypto goes mainstream.

L2s Make Real Applications Viable: On Ethereum mainnet, our escrow use case would be economically impractical: $20+ gas fees for a $50 bet makes no sense. Base's sub-$0.10 transactions unlock an entirely new category of applications. We learned firsthand why L2s aren't just "cheaper Ethereum" but fundamentally enable new use cases.

Integration is 80% of the Work: Writing individual components (smart contract, API client, frontend) wasn't the hard part. Making them all work together seamlessly like handling state synchronization, error cases, and edge conditions, was where we spent most of our time and still have work to do.

Team Communication is Critical: With three separate layers (contracts, backend, frontend), clear interfaces and constant communication were essential. We learned to define API contracts early, document assumptions, and over-communicate blockers.

What's next for Base Bets

Complete End-to-End Integration: Our immediate priority is completing the frontend-backend-blockchain connection. The pieces exist independently but we need to wire them together into a smooth user flow from escrow creation through resolution.

Enhanced Polymarket Integration:

  • Support for more complex market types (scalar markets, multiple outcomes)
  • Better handling of market edge cases (cancellations, disputes, delayed resolutions)
  • Real-time market price display alongside escrow terms

Social Features:

  • User profiles showing escrow history and reputation
  • Friend discovery and challenge system ("bet your friend $50 on tonight's game")
  • Leaderboard tracking most active bettors and largest escrows

Multi-Chain Expansion: While Base is our primary chain, we'd explore deploying to other L2s (Optimism, Arbitrum) and implementing cross-chain escrow for maximum liquidity and user reach.

Advanced Escrow Types:

  • Multi-party escrows (3+ participants with different conditions)
  • Time-locked escrows with automatic refunds
  • Partial releases based on milestone completion
  • Recurring conditional payments (subscription-style agreements)

Security Audit & Mainnet: Before handling real user funds, we'd get our contracts professionally audited. We'd also implement additional safeguards like emergency pause mechanisms and timelocks for critical functions.

Mobile Application: Build native iOS/Android apps leveraging Coinbase Wallet SDK for seamless mobile UX. Escrow creation should be as easy as sending a Venmo payment.

Analytics Dashboard: Real-time platform statistics: total value locked, number of active escrows, most popular prediction markets, average settlement time, etc.

Built With

  • base-l2
  • basescan
  • cdp-paymaster
  • coinbase-smart-wallet
  • erc-4337
  • ethers.js
  • etherscan
  • hardhat
  • next.js
  • node.js
  • onchainkit
  • openzeppelin
  • polymarket-gamma-api
  • rainbowkit
  • react
  • solidity
  • typescript
  • usdc
Share this project:

Updates