NickelJoke - Pay a Nickel to Get a Joke Using x402 Micropayments
NickelJoke is a web application that generates personalized jokes on any topic using AI, powered by the x402 payment protocol. Pay small amounts of USDC to get custom jokes, demonstrating the future of micropayments for AI services.
Built with Next.js, x402, and Coinbase CDP, this app showcases how easy it is to monetize AI services with cryptocurrency payments in a fun, engaging way.
This project was built using the x402 AI Starter Kit - a Next.js template that demonstrates how to integrate x402 payments with AI services.
โจ Features
- ๐ญ AI-Powered Jokes - Generate custom jokes on any topic using advanced AI
- ๐ฐ Micropayments - Pay small amounts of USDC using the x402 protocol
- ๐ฒ Smart Suggestions - Get random topic ideas for instant inspiration
- ๐ฑ Mobile-First - Beautiful, responsive design with smooth animations
- ๐จ Interactive Experience - Scratch-to-reveal joke cards with satisfying animations
- ๐ค Social Sharing - Share your favorite jokes with unique, shareable links
- ๐ Delightful UX - Confetti animations and engaging visual feedback
- ๐ Easy Wallet Connection - Seamless Base network integration
๐ ๏ธ Tech Stack
- Next.js 15 - React framework with App Router
- x402 - Payment protocol for HTTP
- Coinbase CDP - Wallet and payment infrastructure
- Wagmi - React hooks for Ethereum
- Tailwind CSS - Utility-first CSS framework
- Framer Motion - Animation library
- Radix UI - Accessible component primitives
- TypeScript - Type safety
๐ Getting Started
git clone https://github.com/btahir/nickeljoke
cd nickeljoke
pnpm install๐โโ๏ธ Running Locally
-
Set up Coinbase CDP credentials
Sign into the Coinbase CDP portal and create API keys.
-
Configure environment variables
Copy
.env.exampleto.env.localand set:CDP_API_KEY_ID- Your CDP API key IDCDP_API_KEY_SECRET- Your CDP API secretCDP_WALLET_SECRET- Your wallet secret phrase
-
Start the development server
-
Open the app
Visit http://localhost:3000 in your browser.
๐ฏ How to Use
- Connect your wallet using the header button
- Switch to Base Sepolia (testnet) if prompted
- Enter a joke topic or click "Random Topic" for suggestions
- Generate a joke - this will cost a small amount of USDC
- Scratch to reveal your personalized joke
- Share your joke with the share button
๐งช Testing Payments
The app uses Base Sepolia (testnet) by default, so you can test with fake money. Get free testnet USDC from the Coinbase CDP faucet.
๐ Deployment
Deploy to Vercel
- Push your code to GitHub
- Connect to Vercel and deploy
- Add environment variables in your Vercel project settings:
CDP_API_KEY_IDCDP_API_KEY_SECRETCDP_WALLET_SECRET
Production Setup
To use mainnet (real money):
- Set
NETWORK=basein your environment variables - Ensure your CDP wallet has sufficient USDC for joke generation costs
- Monitor usage through the Coinbase CDP dashboard
๐ Project Structure
src/
โโโ app/ # Next.js App Router
โ โโโ api/joke/ # Joke generation API endpoint
โ โโโ share/[id]/ # Shared joke pages
โโโ components/ # React components
โ โโโ ui/ # Reusable UI components
โ โโโ rough-components/ # Hand-drawn style components
โ โโโ joke-*.tsx # Joke-specific components
โโโ lib/ # Utilities and configuration
๐ค Contributing
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
๐ License
This project is open source and available under the MIT License.
