Connect a Game
How-To Guid: Connect Your Educational Game with LearnCard GameFlow
Want to enable your educational game to securely issue verifiable badges, track learning progress, and respect user privacy with robust guardian consent? This guide will walk you through integrating your game with LearnCard using GameFlow.
Our Example Use Case: "Math Adventures" Game
Imagine "Math Adventures," an online game designed to teach elementary school students fundamental math concepts. As students complete levels or master specific skills (e.g., "Addition Master," "Fraction Whiz"), Math Adventures wants to:
Allow parents/guardians to connect their child's LearnCard account.
Securely issue digital badges for these achievements directly to the child's LearnCard wallet, with guardian oversight.
Optionally, track in-game learning progress using xAPI statements linked to the student's LearnCard identity.
What you'll accomplish in this Guide:
Set up your game's backend as a LearnCard Issuer.
Create a "GameFlow Contract" with specific settings for guardian consent and data permissions.
Implement a "Connect with LearnCard" flow in your game for players/guardians.
Handle the consent callback to securely link a player's game account with their LearnCard DID (and capture delegate credentials for xAPI).
Automatically issue a "Level Completion" badge when a player achieves a milestone in your game.
Prerequisites
LearnCard SDK Initialized (for your Game's Backend): Your game's backend server will need an active
learnCardinstance.Service Profile for Your Game: Your game will need its own identity on the LearnCard Network.
Basic Understanding: Familiarity with DIDs, Verifiable Credentials (VCs), Boosts, and the general ConsentFlow Tutorial is highly recommended. Understanding xAPI Concepts will be useful if you plan to use that feature.
Web Development Setup:
A backend environment for your game (e.g., Node.js with Express).
A frontend for your game (HTML/JS, or your game engine's web interface).
Part 1: Setting Up Your Game's Backend as an Issuer
Similar to other services, your game's backend needs a LearnCard identity to issue credentials.
Step 1.1: Initialize LearnCard SDK on Your Backend
Step 1.2: Ensure Your Game Has a Service Profile
Action: Integrate this setup into your game server's initialization process.
Part 2: Creating the GameFlow Contract
A GameFlow Contract is a specialized ConsentFlow Contract. It tells LearnCard what permissions your game needs and, crucially, enables guardian consent features.
Step 2.1: Define Your GameFlow Contract Terms
Key GameFlow Configurations:
needsGuardianConsent: true: Activates the guardian consent flow. The LearnCard App will guide an adult to verify their presence, select the child playing, and then grant consent.redirectUrl: Where the user (or guardian) is sent after the consent process. It will receive the consenting user's DID (which could be the child's or guardian's, depending on the flow) and potentially a Verifiable Presentation (vp) containing a Delegate Credential for xAPI.reasonForAccessing: A parent-friendly message explaining why your game needs access.
Action: Have your game server create this contract (e.g., on startup or via an admin function) and securely store the returned gameFlowContractUriCache.
Part 3: Frontend - "Connect with LearnCard" in Your Game
In your game's UI (e.g., settings menu, start screen, or when a significant achievement is reached for the first time), provide a button for players/guardians to connect their LearnCard.
Action: Implement this button. It redirects to learncard.app for the GameFlow consent process (which includes guardian steps).
Part 4: Handling the GameFlow Callback
After the consent process on learncard.app (which might involve guardian verification and child selection), the user is redirected back to your game's redirectUrl (e.g., https://mathadventures.example.com/learncard/callback).
This callback will include query parameters:
did: The DID of the consenting user (this might be the child's DID if selected by a guardian, or the guardian's DID if they are consenting for themselves or if the child selection step wasn't needed/used).vp(Optional): A Verifiable Presentation (as a JWT string) containing a "Delegate Credential." This is crucial if you plan to send xAPI statements on behalf of the user.
Step 4.1: Backend - Create a Callback Endpoint
Action: Implement this callback endpoint. Securely store the userDid (and delegateVpJwt) associated with the player in your game.
Part 5: Issuing a Game Achievement Badge
When a player completes a level or masters a skill in Math Adventures:
Step 5.1: Create a Boost for Your Game Badge (One-time Setup)
Similar to the "Issue Badges from a Website" tutorial, create a Boost for each type of badge (e.g., "Addition Level 1 Complete").
Action: Create Boosts for all your game's achievements. Store their URIs.
Step 5.2: Backend Logic - Issue Badge on Achievement
Action: Integrate this logic into your game's achievement system.
Part 6: (Optional) Sending xAPI Statements
If you captured the delegateVpJwt in Part 4, your game server can now send xAPI statements on behalf of the user.
This allows rich tracking of in-game learning, authenticated as the user via the delegate credential.
Summary & Next Steps
You've now learned how to integrate your educational game with LearnCard using GameFlow! This includes: β Setting up your game as an Issuer. β Creating a GameFlow Contract with guardian consent. β Enabling players/guardians to connect their LearnCard accounts. β Handling the callback to link game accounts with LearnCard DIDs (and capture delegate VPs for xAPI). β Automatically issuing achievement badges to players via the GameFlow contract. β (Optionally) Sending authenticated xAPI statements.
This robust integration enhances your game by providing verifiable recognition for players and valuable, secure data tracking capabilities, all while prioritizing user control and safety.
Explore further:
Dive deeper into the ConsentFlow Core Concepts that power GameFlow.
Learn more about xAPI and its integration with LearnCard.
Design various Boosts for all the unique achievements and skills in your game.
Last updated
Was this helpful?