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:

  • 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 learnCard instance 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.

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.

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.

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.

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.

Step 5.2: Backend Logic - Issue Badge on Course Completion

When your backend detects a user has completed the course:

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?