put your web 3 knowledge to test, competing against AI and other ppl!
At its core, the project is an engaging quiz game where users answer multiple-choice questions. The game is enhanced with Web3 features such as authentication, payment, and verification using WorldCoin’s MiniKit. Users can sign in via a WorldCoin-based OAuth provider, participate in the game, and even perform blockchain-based payments or verifications—all within a responsive, dynamic interface.
layout.tsx
: Establishes the global structure of the app. It wraps children components with providers such as NextAuthProvider
, MiniKitProvider
, and conditionally, an Eruda debugging console.globals.css
: Contains base styles and Tailwind directives, along with CSS custom properties for theming (supporting dark mode)./api/auth/[...nextauth]/route.ts
, it integrates a WorldCoin OAuth provider and handles sign-in callbacks.SignIn
Component: Provides a simple UI to sign in (or sign out) using NextAuth. It listens for session changes to update the application state../Game/modules/Game.tsx
) randomly selects a set of questions from a JSON data file.
Question
: Displays the current question text.AnswerOptions
: Renders available answer buttons with visual feedback (e.g., correct/wrong highlights and icons).Timer
: A countdown component that has been enhanced to include a progress bar that visually shrinks as time runs out. When only a few seconds remain, the progress bar shakes and displays a bomb emoji to heighten urgency./api/initiate-payment/route.ts
endpoint generates a unique payment nonce, stored in cookies./api/confirm-payment/route.ts
endpoint verifies that the received transaction matches the initiated payment by comparing the nonce and checking the transaction status via WorldCoin’s API.PayBlock
): Invokes the MiniKit pay command and processes the response, displaying success or failure messages./api/verify/route.ts
endpoint accepts a payload from MiniKit’s verification command, verifies the cryptographic proof using WorldCoin’s verifyCloudProof
method, and returns a success or error status.VerifyBlock
component initiates the verification process and displays the result, enabling developers to handle user verification seamlessly.Next.js & React:
The project leverages Next.js for its powerful routing and server-side rendering capabilities. React functional components, along with hooks (like useState
and useEffect
), manage the dynamic UI and state.
Global Layout & Providers:
The RootLayout
component (in layout.tsx
) wraps all pages with multiple providers:
Styling:
Styling is achieved using Tailwind CSS along with custom global styles in globals.css
and component-specific styles in dedicated CSS files. The project supports dark mode by adjusting CSS custom properties.
Interactive Game UI:
The quiz game is composed of several modular components:
/api/auth/[...nextauth]/route.ts
):/api/initiate-payment/route.ts
):/api/confirm-payment/route.ts
):/api/verify/route.ts
):verifyCloudProof
function to validate the payload before confirming the verification status.VerifyBlock
initiates this process and sends the proof to the backend for confirmation.PayBlock
component triggers the MiniKit payment command, allowing the user to send tokens. The backend then verifies the transaction status to confirm payment success.State Management & Animations:
React state and side effects are used to handle game dynamics, such as tracking the time left on the timer and updating scores in real time. CSS animations (like the shaking effect on the timer when time is nearly up) add a layer of interactivity that enhances user engagement.
Responsive Design:
The combination of Tailwind CSS and custom styling ensures the application is responsive, providing an optimal experience across different devices and screen sizes.
Debugging Tools:
Tools like Eruda are integrated conditionally to help developers debug the application in development environments without affecting production.