Fork This Project
For a quick start, you can fork the complete project here to get all the files and configurations in one place. This includes the advanced implementation, so you can modify it to suit your specific needs.Beginner: OnchainKit Setup & Simple Ticket Purchase
Create a ticketing app with wallet connection and crypto checkout.1. Setup the Project
Install OnchainKit by creating a new project with:providers.tsx
: Configures OnchainKit providers.page.tsx
: Main ticketing page and UI..env
: Stores API keys.
.env
:
2. Wallet UI & Ticket Product Setup
- Create a ticket product in Coinbase Commerce and save the
productId
. - Edit
page.tsx
:- Import wallet and checkout components.
- Replace
"YOUR_PRODUCT_ID"
with your actual product ID.
Intermediate: Metadata & Multi-Step Flow
Add user information fields, metadata, and a confirmation page for a two-step checkout.1. Add User Input Fields & Metadata
Inpage.tsx
, add inputs for name, email, and ticket count:
2. Confirmation Page
Add a new folder app/confirmation with page.tsx to review order details before payment. UseuseSearchParams
to get user data:
3. Backend Setup for Secure Charge Creation
Create a secure API endpoint to handle charge creation. Inapp/api/createCharge/route.ts
:
4. Connecting the Backend to Frontend
Inconfirmation/page.tsx
, add a handler to call the backend:
Advanced: Inventory Management with Airtable
Integrate Airtable to manage ticket inventory and dynamically display available tickets.1. Airtable Setup
- Create a Tickets Base with fields:
Name
: Ticket namePrice
: Price per ticketInventory
: Available quantity of ticketsImage
: Event or ticket imageDescription
: Brief description of the ticket or event
- API Keys: Get your Airtable API Key, Base ID, and Table ID. Save them in
.env.local
:
Fetch Tickets from Airtable
Createapp/api/fetchTickets/route.ts
:
3. Update Inventory after Purchase
Createapp/api/updateInventory/route.ts
to reduce inventory:
Display Tickets with Inventory in page.tsx
Fetch tickets inuseEffect
, displaying available tickets and marking sold-out items:
5. Confirmation & Payment
Inconfirmation/page.tsx
, after successful payment, reduce inventory: