ParkBnB
ParkBNB: A decentralized parking app. Book with a deposit, scan a QR . Fair payments on-chain.
Problem Statement
Of course. Here is a more detailed and comprehensive description of your "pay-per-use" ParkBNB project.ParkBNB: A Decentralized Peer-to-Peer Parking MarketplaceParkBNB is a decentralized application (dApp) built on the blockchain that reimagines the urban parking experience. It functions as a transparent, secure, and peer-to-peer marketplace where individuals can rent out their private parking spots to drivers in need. By leveraging the power of smart contracts, ParkBNB eliminates the intermediaries and inefficiencies of traditional parking systems, creating a more direct and trustworthy connection between hosts and renters.The core of the platform operates on a "pay-per-use" model, secured entirely on-chain to guarantee fairness and security for all participants. The process begins with a host listing their available parking spot, setting an hourly rate in cryptocurrency. When a driver wishes to book this spot, they interact with the dApp to pay an upfront, refundable deposit. This deposit, calculated as the hourly rate multiplied by the maximum number of hours they intend to park, is sent directly to the ParkingMarketplace smart contract, which acts as a transparent and automated escrow agent.The most innovative feature of ParkBNB is its seamless check-in and check-out mechanism. Each parking spot is associated with a unique, physical QR code generated by the host. This QR code contains a secret known only to the host's printed code and the dApp when scanned. The cryptographic hash of this secret is stored on the blockchain, ensuring it cannot be tampered with.Upon arriving at the spot, the renter uses the ParkBNB mobile interface to scan the QR code. This action triggers the checkIn function in the smart contract, which verifies the renter's identity and the secret's authenticity, officially starting the on-chain parking timer. When the renter is ready to leave, they scan the same QR code again to trigger the checkOut function.This is where the power of the smart contract becomes evident. Upon check-out, the contract automatically executes the final settlement with mathematical precision. It calculates the exact duration of the parking session, down to the second, and computes the final cost. The initial deposit is then instantly and autonomously distributed: the host receives their earned payment, a small protocol fee is collected by the platform, and the remaining balance is immediately refunded to the renter's wallet. This automated process eliminates any possibility of overcharging, ensures hosts are paid instantly, and removes the need for manual payment systems or dispute resolution, fostering a truly trustless marketplace for urban mobility.
Solution
How It's Made ParkBNB was built with a "first principles" approach to solving a real-world problem—inefficient parking—using the unique strengths of blockchain technology: transparency, security, and automation. Our goal was to create a trustless ecosystem where the smart contract, not a central company, acts as the escrow and arbiter.The Technology Stack We chose a modern, robust, and type-safe stack to ensure both developer efficiency and application reliability.Smart Contract (The Core Logic):Solidity: The contract was written in Solidity ^0.8.24, leveraging modern and secure language features.Foundry: We used the Foundry toolkit for all aspects of contract development. It provided an incredibly fast and efficient workflow for compiling, testing (with Forge), and deploying our contract.OpenZeppelin Contracts: To ensure security and follow best practices, we inherited from OpenZeppelin's battle-tested ReentrancyGuard and Ownable contracts.Frontend (The User Experience):Next.js (App Router): The frontend is a modern Next.js application, giving us a powerful React framework with server-side rendering for a fast initial load.TypeScript: The entire frontend is written in TypeScript to enforce type safety, which is critical when dealing with complex data structures from the blockchain.wagmi & viem: This powerful duo forms the core of our blockchain interaction layer. wagmi provides robust React hooks (useReadContract, useWriteContract, etc.) for a clean and declarative way to interact with the contract, while viem handles the lower-level tasks of encoding/decoding data and communicating with the Ethereum RPC.RainbowKit: To provide a seamless, multi-wallet connection experience for users, we integrated RainbowKit, which abstracts away the complexities of wallet management.Tailwind CSS: For styling, we used Tailwind CSS to rapidly build a clean, modern, and responsive user interface.How It's Pieced Together The architecture is a classic dApp model where the frontend acts as an interface to the on-chain logic.The Single Source of Truth: The ParkingMarketplace.sol smart contract is the heart of the application. It holds all the state, including the list of spots, active bookings, and the rules for interaction. All critical actions—creating a spot, booking, checking in, and checking out—are functions within this contract.The User Interface: The Next.js app provides the visual layer. When a user lands on the home page, a useReadContracts hook from wagmi fires, fetching the data for all active parking spots and displaying them as cards.The QR Code Mechanism: A key feature is our secure check-in/out process. When a host creates a spot, the frontend generates a unique secret (uuidv4). This raw secret is embedded into a QR code payload (JSON.stringify({ secret })). Simultaneously, the secret is hashed on the client-side using keccak256 from viem, and only this hash is sent to the createSpot function on the smart contract. This ensures the secret itself is never stored on-chain.The On-Chain Transaction Flow: When a renter scans the QR code, the app reads the raw secret. This secret, along with the booking ID, is passed to the checkIn or checkOut function via a useWriteContract hook. The smart contract then hashes the provided secret and compares it to the hash it has on record, verifying the scan's authenticity before proceeding with the time-stamping and fund settlement.
Hackathon
ETHGlobal New Delhi
2025
Contributors
- sunilswain7
17 contributions