Connect a Website
How-To Guide: Issue Digital Badges from Your Website
Want to award your users verifiable digital badges for their achievements on your website or platform? This tutorial will show you how! We'll explore two main approaches and then dive deep into a robust, integrated solution using LearnCard's ConsentFlow.
Our Example Use Case: EduPlatform Imagine "EduPlatform," an online learning site. When a student successfully completes the "JavaScript Fundamentals" course, EduPlatform wants to automatically issue them a digital badge they can store in their LearnCard wallet and share anywhere.
What you'll accomplish:
Understand two methods for issuing badges.
Set up your platform (EduPlatform) as a LearnCard Issuer.
Create a "ConsentFlow Contract" so users can connect their LearnCard accounts to EduPlatform.
Implement a "Connect LearnCard" button on your website.
Handle the user consent process and securely store their LearnCard DID.
Automatically issue a "Course Completion" badge (as a Verifiable Credential) to a user when they complete an activity on your site, using the established consent.
Choosing Your Badge Issuance Method
There are a couple of ways to get badges to your users:
Option 1: Quick & Simple - Claimable Links/QR Codes (via Boosts)
How it works: You create a "Boost" (a master template for your badge). From this Boost, you generate a unique claim link or QR code. You can display this QR code at the end of a workshop, email the link, etc. Users scan/click it to claim their badge.
Pros: Very easy to set up, no deep integration needed, great for one-off events or when users don't have accounts on your platform.
Cons: Less automated for ongoing achievements tied to user accounts on your site; relies on the user to actively claim.
β‘οΈ If this sounds like what you need, head over to our Quickstart: Create a Claimable Boost Tutorial for a step-by-step guide!
Option 2: Automated & Integrated - Connecting LearnCard Accounts (This Guide's Focus)
How it works: Users explicitly connect their LearnCard account to your website by consenting to a "ConsentFlow Contract." This contract gives your website permission to issue specific types of badges directly to their LearnCard wallet when they achieve something.
Pros: Fully automated issuance, badges are tied to their account activity on your platform, enables ongoing recognition, allows for personalized badge data.
Cons: Requires a bit more setup for the initial consent flow.
β‘οΈ If you want this deeper, automated integration, you're in the right place! Let's proceed.
Prerequisites for the Integrated Approach
LearnCard SDK Initialized (for your Backend): Your website's backend will need an active
learnCardinstance connected to the network.Service Profile for Your Website: Your website/platform will need its own identity on the LearnCard Network.
Basic Understanding: Familiarity with DIDs, Verifiable Credentials (VCs), Boosts, and the Create a ConsentFlow Tutorial will be very helpful.
Web Development Setup:
A backend environment (e.g., Node.js with Express) to handle API calls and user data.
A frontend (simple HTML/JS is fine for this guide) for the user interface.
You can skip Part 1 & 2 by configuring your issuer and creating your ConsentFlow contract using the built-in UI:
Part 1: Setting Up Your Platform (EduPlatform as Issuer)
Your website's backend needs to act as an Issuer.
Step 1.1: Initialize LearnCard SDK on Your Backend
This instance will represent EduPlatform.
Step 1.2: Ensure EduPlatform Has a Service Profile
Your EduPlatform needs an identity on the LearnCard Network.
Action: Integrate these into your backend's startup process.
Part 2: Creating a ConsentFlow Contract for Badge Issuance
This contract defines that EduPlatform requests permission from users to issue "Achievement" badges to them.
Step 2.1: Define the Contract Terms
Action: Ensure your backend can create this contract (perhaps on startup or via an admin function) and store the contractUri.
Part 3: Enabling Users to Connect Their LearnCard on Your Website
Step 3.1: Frontend - The "Connect LearnCard" Button
On EduPlatform's user profile page or settings page, add a button.
Action: Implement this button. When clicked, it redirects the user to learncard.app to approve the connection based on your contract.
Part 4: Handling the Consent Callback & Storing User DIDs
After the user consents on learncard.app, they are redirected back to the redirectUrl you specified in your contract (or the returnTo URL from the consent link).
Step 4.1: Backend - Create a Callback Endpoint
Your backend (e.g., EduPlatform's Node.js/Express server) needs an endpoint to handle this.
Action: Implement this callback endpoint on your backend. Securely associate the received userDid with the logged-in user on your platform.
Part 5: Issuing a Badge When a User Completes an Activity
Let's say a user completes the "JavaScript Fundamentals" course on EduPlatform.
Step 5.1: Create a Boost for Your Badge (One-time Setup)
It's best practice to create a "Boost" to act as the template for your "JavaScript Fundamentals Completion" badge. This makes managing and issuing it easier.
Action: Ensure this Boost is created and you store its jsFundamentalsBoostUri.
Step 5.2: Backend Logic - Issue Badge on Course Completion
When your backend detects a user has completed the course:
Action: Integrate this logic into your platform's course completion flow.
Part 6: User Experience - Viewing the Badge
Once EduPlatform issues the badge:
The user will receive a notification in their LearnCard app (if they have notifications enabled).
The "JavaScript Fundamentals Completion" badge will appear in their LearnCard alerts notification tray, ready to be claimed, viewed and shared.
Summary & Next Steps
Congratulations! You've now outlined a complete system for: β Setting up your website (EduPlatform) as a LearnCard Issuer. β Creating a ConsentFlow Contract to request permission to issue badges. β Allowing users to connect their LearnCard accounts via a button on your site. β Handling the consent callback to store user DIDs. β Automatically issuing a specific badge (as a Verifiable Credential instance of a Boost) to a user's LearnCard wallet when they complete an action on your site.
This integrated approach provides a seamless experience for your users and a powerful way for your platform to issue verifiable digital recognition.
From here, you can explore:
Creating a variety of Boosts for different badges and achievements.
Using Auto-Boosts within your ConsentFlow contract to issue an initial badge just for connecting.
Implementing more detailed error handling and user feedback throughout the process.
Last updated
Was this helpful?