A comprehensive example project showcasing Coinbase Developer Platform (CDP) capabilities through a challenge-based escrow system. This platform enables users to create any kind of challenges with reward pools, receive submissions, and distribute prizes in a decentralized manner.
Demo available at: https://cdp-escrow.wakeuplabs.link/
This project showcases key CDP features:
- Embedded Wallets: Seamless wallet creation and recovery using email/SMS authentication
- Gas sponsorship: Sponsor gas for users with coinbase smart wallets.
- Onramps: Fund users wallets with usdc using the onramp feature.
- Smart Contract Integration: Deployed on Base Sepolia, interact using Coinbase wallets and it's user operations bundler.
The project consists of three main components:
cdp-escrow/
βββ apps/
β βββ contracts/ # Smart contracts (Hardhat)
β βββ www/ # Next.js frontend with CDP integration
βββ packages/
βββ common/ # Shared utilities and type definitions
-
CDP Project Setup:
- Sign up at CDP Portal
- Create a new project and copy your Project ID
- Generate API credentials for the onramp
- Configure CORS origins for your domain for embedded wallets
- Adjust gas sponsorships limits as desired
-
Environment Setup:
# Clone and install dependencies git clone https://github.com/wakeuplabs-io/cdp-escrow cd cdp-escrow pnpm install
-
Configure Environment Variables:
- In both
apps/wwwandapps/contractscopy.env.exampleto.envand configure with your values.
- In both
# Start the web interface
cd apps/www
pnpm devVisit http://localhost:3000 to interact with the application.
- Create Challenges: Set up challenges with token reward pools
- Browse Challenges: Discover active challenges from the community
- Submit Solutions: Upload your work and compete for rewards
- Resolve & Award: Challenge creators can evaluate and distribute prizes, winners split 70% of the pool, the rest is for valid submissions.
- Zero-Friction Onboarding: Users sign up with just email/phone
- Embedded Wallet: CDP handles wallet creation and management
- Trustful Onramp: Provide your users with a onramp they can trust.
The project includes a comprehensive test suite and a CLI for interacting with deployed contracts:
cd apps/contracts
# Deploy mock ERC20 token
pnpm run deploy-erc20:base-sepolia
# Deploy escrow contract
pnpm run deploy:base-sepolia# Set your challenger profile
tsx ./scripts/index.ts set-profile \
--network base-sepolia \
--name "Acme Corp" \
--description "We build amazing software"
# View any user's profile
tsx ./scripts/index.ts find-profile \
--network base-sepolia \
--address 0x1234...# Create a new challenge
tsx ./scripts/index.ts create-challenge \
--network base-sepolia \
--title "Build a DeFi Protocol" \
--description "Create an innovative lending protocol" \
--pool-size 1000 \
--end-date '2025-08-30T23:50:00.000Z'
# Browse active challenges
tsx ./scripts/index.ts find-challenges \
--network base-sepolia \
--start-index 0 \
--count 10
# Resolve challenge and award prizes
tsx ./scripts/index.ts resolve-challenge \
--network base-sepolia \
--challenge-id 0 \
--winners 0,1 \
--invalid 2,3# Submit to a challenge
tsx ./scripts/index.ts create-submission \
--network base-sepolia \
--challenge-id 1 \
--contact user@example.com \
--body "Link to my solution..."
# View challenge submissions
tsx ./scripts/index.ts find-submissions \
--network base-sepolia \
--challenge-id 0 \
--start-index 0 \
--count 5
# Check your rewards
tsx ./scripts/index.ts get-claimable \
--network base-sepolia \
--challenge-id 0 \
--address 0x1234...
# Claim your earnings
tsx ./scripts/index.ts claim \
--network base-sepolia \
--challenge-id 0# Mint test tokens
tsx ./scripts/index.ts mint \
--network base-sepolia \
--to 0x634A6c396D72e03C5a919Df40d12158770f08e06 \
--amount 1000Base Sepolia Testnet:
- Escrow:
0x046FF7b1a9662893d43E0934C126aA07e1625c4e - Mock ERC20:
0xa44e1a19B9334d7FfF8AF0D0783041a83aEb5a49
Current website deployment is also using the MockERC20 contract. The
mintmethod is public so you can mint yourself some tokens from the explorer itself
The escrow system consists of:
- Escrow.sol: Main contract managing challenges, submissions, and token distribution
- Modular Interfaces: Separated concerns with dedicated interfaces for events, errors, and structs
- ERC-20 Integration: Compatible with any ERC-20 token for rewards
- Profile System: On-chain challenger profiles with verification capabilities
- Authentication: Email/SMS login creates embedded wallets automatically. We took leverage of ui provided by coinbase to get this running in no time. The related code can be found between AccountManager and the CdpProvider
- Gas Sponsorship: Sponsor transaction fees for users using Coinbase Smart Wallets. You can see how to send transactions with sponsored gas in any hook at
hooksthat sends transactions like for challenges or with withdraw - Onramp Integration: Enable users to fund wallets directly with fiat currency. Generating an onramp url consists in creating a session token and opening the corresponding url. You can see how to do the former here and the latter here
- Awarded Submissions: Receive 70% of the total pool (split equally)
- Accepted Submissions: Share 30% of the pool (split equally)
- Ineligible Submissions: Receive no rewards
- No Submissions: Pool returns to challenge creator
Currently project is set to work in base sepolia. If you wish to deploy it all to mainnet these are some things you may need to do:
- Deploy contracts on mainnet, adjusting the token in the constructor to be a mainnet available token.
- Maybe implement some proxy for the contracts to allow for future updates and fixes.
- On the web adjust env variables, particularly contract addresses, network, rpc urls and onramp base url.
- You may need to get authorization from Coinbase to enable onramps on mainnet. And that should be it, test and go live!
This project serves as a foundation for building CDP-powered applications. Key areas for extension:
- Custom Token Standards: Implement NFT rewards or custom token mechanics
- Advanced Voting: Add community voting for submission evaluation
- Cross-Chain: Extend to other CDP-supported networks
- Enhanced Profiles: Add reputation systems and achievement badges
- Integration APIs: Connect with GitHub, portfolio sites, or other developer tools
- Live Demo
- Marketing Video (A video showcasing the app)
- Technical Video (Walkthrough of the technical decisions and open-source repo)
- CDP Documentation
- Base Network
- Hardhat Documentation
- Next.js Documentation
This is an example project to demonstrate CDP capabilities. Feel free to fork, modify, and build upon it for your own use cases.
This project is provided as-is for educational and demonstration purposes.