Create a Credential

Tutorial: Create and Send Your First Digital Credential

Welcome! This tutorial will walk you through creating your very first digital Verifiable Credential (VC) and sending it to your LearnCard app. Think of a VC as a secure, digital certificate or badge that can prove something, like an achievement or a skill.

What you'll accomplish:

  1. Set up a simple "Issuer" environment using the LearnCard SDK.

  2. Design and create a "Workshop Completion" Verifiable Credential.

  3. Digitally sign (issue) the credential to make it official.

  4. Send this credential to your own LearnCard app using your Profile ID.

  5. View the received credential in your LearnCard app.

Why is this useful? Understanding this basic flow is the first step to building applications that can issue digital badges, certificates, or any other kind of verifiable proof to users, empowering them with portable and trustworthy records.

Prerequisites:

  1. Node Installed: Node.js installed on your computer.

  2. Basic Understanding: While this is a beginner tutorial, a quick read of our What is a Verifiable Credential? and What is a DID? Core Concept pages will be helpful.


Part 0: Project Setup

Part 1: Setting Up Your Issuer Environment

For this tutorial, your computer will act as the "Issuer" – the entity creating and sending the credential.

Step 1.1: Create an Issuer Script

Create a new file in your project folder: issueCredential.ts

Step 1.2: Initialize LearnCard SDK for the Issuer

This instance will represent your workshop organization.

This code initializes a LearnCard instance.

The seed is used to generate a unique Decentralized Identifier (DID) and cryptographic keys for your Issuer. In a real application, this seed must be kept extremely secure. Learn more.

Step 1.3: Ensure Issuer Has a Service Profile

To interact with the LearnCard Network effectively (like sending credentials), your Issuer's DID should be associated with a Service Profile.

Step 1.4: Generate Secure Seed and .env file

Create and save your seed to .env:

Run the following command in your terminal:

Add config variables to your .env:

You must create a unique profile ID for your organization. It must be 3-40 characters, lowercase, no spaces or special characters. E.g.: my-organization, acme, taffy-co-organization , etc.


Part 2: Designing Your "Workshop Completion" Credential

Now, let's define what information our "Workshop Completion" credential will hold.

Step 2.1: Retrieve Your LearnCard Profile ID

Login or Signup for LearnCard App, and grab your unique Profile ID:

How to Find:

Open your LearnCard app, navigate to your profile section by clicking it in the upper right corner. Click "My Account." Copy the Profile ID accurately; it's case-sensitive and usually looks something like @your-chosen-profile-id or a longer unique string.

Step 2.1: Define the Credential Content

A Verifiable Credential is a set of claims made by an Issuer about a Subject (the recipient).


Part 3: Creating and Signing the Credential (Issuance)

Let's take the content and make it an official, signed Verifiable Credential.

Step 3.1: "Issue" / "Sign" the Unsigned Credential

The LearnCard SDK helps you with this:

issueCredential adds the issuer's DID, issuance date, and a cryptographic signature, making it verifiable.


Part 4: Sending the Credential to Your LearnCard App

Now, let's send this official credential to your LearnCard app.

Step 4.1: Use sendCredential

This function from the LearnCard SDK (via the Network plugin) handles the delivery.


Part 5: Putting It All Together & Viewing in Your App

Let's create a main function to run these steps.

Step 5.1: Main Script Logic

Step 5.2: Run Your Script

  1. Replace Placeholders:

  2. Save the file.

  3. Open your terminal in your project directory and run:

    • npx tsx issueCredential.ts

Step 5.3: View in Your LearnCard App

After the script runs successfully, open your LearnCard app on your device. You should see the new "Workshop Completion Certificate" appear! It might take a few moments for you to get the notification.

Head to the "Alerts" section in LearnCard app to claim the credential you just sent! Ensure you are signed in as the recipient Profile ID.

Summary & What's Next

Congratulations! You've successfully: ✅ Set up a basic Issuer using the LearnCard SDK. ✅ Defined, created, and digitally signed a Verifiable Credential. ✅ Sent that credential to your own LearnCard app.

This tutorial covers the fundamental flow of issuing credentials. From here, you can explore:

  • Creating more complex credentials with different Schemas and Types.

  • Using ConsentFlows to manage data sharing before issuing credentials.

  • Integrating this issuance logic into your own applications and backend services.

Explore the rest of our documentation to learn more about the powerful features of LearnCard!

Last updated

Was this helpful?