PI
piggydoughnut/booking-onchain
POC for a decentralized room/table booking system
Booking Onchain – Memberships, Listings, and Bookings
POC for a decentralized room/table booking system
This repository contains Solidity smart contracts and a Hardhat project that implement:
- MembershipManager: Users pay the chain native currency to become members for a period.
- ListingManager: Create coworking listings (desks, rooms) with IPFS CID metadata and availability tracking.
- BookingManager: Members can book available listings. Bookings are currently free (no payment collected).
- AccessNFT (optional): Non-transferable NFT granting temporary access aligned to booking expiry.
Payments use the chain native currency (no ERC-20). Booking is nonpayable (free) in the current setup.
Quickstart
- Install deps (pnpm)
pnpm install- One-command start (recommended)
chmod +x scripts/start.sh
./scripts/start.shThis will:
- Start a local Hardhat node (background)
- Compile and deploy contracts
- Generate
deployed.local.jsonandfrontend/.envwith RPC and deployed addresses - Seed mock listings with example IPFS CIDs
- Start the frontend dev server
- Start local Hardhat node (new terminal)
pnpm run nodeManual flow (alternative)
- Compile
pnpm run compile2 Deploy to local Hardhat (localhost network)
pnpm run deploy # deploys to localhost (http://127.0.0.1:8545)3 Frontend env
The deploy script writes frontend/.env automatically with values like:
VITE_RPC=http://127.0.0.1:8545
VITE_MEMBERSHIP_ADDRESS=0x...
VITE_LISTING_ADDRESS=0x...
VITE_BOOKING_ADDRESS=0x...
VITE_ACCESS_NFT_ADDRESS=0x...If you prefer, you can edit these manually.
Design Overview
- Memberships: Users acquire membership by paying the chain native currency; membership expiry is tracked on-chain.
- Listings:
createListing(cid, priceOrFree)stores owner, metadata CID, and active flag.isAvailable()checks for overlaps against stored booked intervals. OnlyBookingManagercanblockInterval. - Bookings:
book(listingId, startTs, endTs)validates membership, checks availability, stores booking withamount=0(free), blocks interval, and optionally mints anAccessNFTkeyed by bookingId with expiry =endTs.release()/refund()operate onamount(0 in current setup).
Notes
- Time resolution is seconds. Pricing is currently disabled for booking (free). If re-enabled, prefer deriving price fully on-chain.
- AccessNFT is non-transferable to model temporary access keys; ownership can be burned by holder or contract owner.
- Membership
becomeMember/renewMembershipare payable.bookis nonpayable in this repo’s current state.
References
- Polkadot smart contracts (Solidity/EVM compatibility and PolkaVM): docs.polkadot.com – Smart Contracts
- Asset Hub overview and smart contracts support: Polkadot Support – What is Asset Hub
Frontend (Pure Client-Side, IPFS/IPNS)
The UI is a static Vite + React SPA under frontend/ — no servers required.
Stack and conventions:
- React + Vite + TypeScript
- UI: shadcn/ui + Tailwind CSS
- Wallet: RainbowKit + wagmi
- Data: @tanstack/react-query
- Path alias:
@/*→src/* - Reads/writes live only in hooks in
src/hooks/; components do not hardcode addresses and import fromsrc/config/contracts.
Setup:
cd frontend
pnpm installCreate frontend/.env with:
VITE_RPC=http://127.0.0.1:8545
VITE_MEMBERSHIP_ADDRESS=0x...
VITE_LISTING_ADDRESS=0x...
VITE_BOOKING_ADDRESS=0x...
VITE_ACCESS_NFT_ADDRESS=0x...Build:
pnpm run buildThe static site is in frontend/dist. You can publish to IPFS and pin; then publish the latest CID to IPNS:
ipfs add -r frontend/dist
ipfs name publish <CID>On this page
Languages
TypeScript95.0%Solidity4.1%CSS0.5%Shell0.3%HTML0.1%JavaScript0.0%
Contributors
MIT License
Created October 30, 2025
Updated October 31, 2025