LearnCard Developer Docs
  • 🚀Get Started
    • 👋Welcome
    • ⭐Who are you?
      • Learners & Employees
      • Traditional Educator
      • Non-Traditional Educator
      • Assessment Provider
      • Employer
      • App Developer & EdTech
      • DAO & Communities
      • Content Creators
      • Research Institutions
      • NGOs & Governments
      • Plugfest Partner
        • Guide for Interop Issuers
          • 🤽Creating an Interop Issuer
        • Guide for Interop Wallets
    • Protocol Overview
      • The Internet of Education
      • The Learning Economy
      • Learner & Employee Privacy
      • 22nd Century Education
      • The Open Credential Network
      • PVCs
  • 🔰LearnCard SDK
    • What is LearnCard?
      • Why a Universal Wallet?
      • Architectural Patterns
      • Production Deployment Guide
      • Troubleshooting Guide
    • LearnCard Core
      • Quick Start
        • Create New Credentials
          • Creating Verifiable Credentials for LearnCard
          • Achievement Types and Categories
          • Custom Types
          • Understanding Boosts
          • Creating Boost Credentials
        • Sign & Send Credentials
        • Accept & Verify Credentials
        • Share & Present Credentials
      • Construction
        • Managing Seed Phrases
        • initLearnCard
        • DIDKit
        • learnCardFromSeed
        • emptyLearnCard
        • IDX Config
      • Control Planes
        • ID
        • Read
        • Store
        • Index
        • Cache
        • Context
      • Plugins
        • Adding Plugins
        • Official Plugins
          • Dynamic Loader
          • Crypto
          • DIDKit
          • DID Key
          • VC
            • Expiration Sub-Plugin
          • VC Resolution
          • VC-Templates
          • VC-API
          • Ceramic
          • IDX
          • VPQR
          • Ethereum
          • CHAPI
          • LearnCard Network
          • LearnCloud
          • LearnCard
          • Claimable Boosts
        • Writing Plugins
          • The Simplest Plugin
          • The Plugin Type
          • The LearnCard Type
          • Implementing Control Planes
          • Implementing Methods
          • The Implicit LearnCard
          • Depending on Plugins
          • Private Fields
          • Publishing a Plugin to NPM
      • URIs
      • CHAPI
        • ⭐CHAPI Wallet Setup Guide
        • ↔️Translating to CHAPI documentation
        • 🖥️Demo Application
        • 🔰Using LearnCard to Interact with a CHAPI Wallet
        • 📝Cheat Sheets
          • Issuers
          • Wallets
      • LearnCard UX
        • Quick Start
        • Components
          • Verifiable Credentials
            • VC Thumbnail
            • VC Thumbnail, Mini
          • LearnCards
            • LearnCard Front
            • LearnCard Back
        • API
      • LearnCard Bridge
      • API
      • Migration Guide
    • LearnCard Network
      • LearnCard Network API
        • Authentication
        • Auth Grants and API Tokens
        • Profile
        • Credentials
        • Boosts
        • Presentations
        • Storage
        • Signing Authorities
        • Notifications
        • API Docs
        • Launch Your Own Network
      • 🔌Connect Your Application
    • ConsentFlow
      • Setting Up ConsentFlow with an Independent Network
    • GameFlow
      • Sending xAPI Statements
        • xAPI URIs
      • Reading xAPI Statements
        • Advanced xAPI Statement Queries
      • Consentful "Claim Later" Flow
  • 🚀Applications
    • LearnCard
    • SuperSkills!
      • SuperSkills! SDK
        • Digital Wallets
        • Issuing into SuperSkills!
        • 🦸Creating a SuperSkills! Issuer
    • Metaversity
    • Admin Dashboard
  • 🔗Resources
    • Github
    • Community
    • 💅Custom Development
    • Contact Our Team
    • Learning Economy
  • 🤖LearnCard Services
    • LearnCard CLI
    • Discord Bot
    • Metamask Snap
  • 💸LearnBank SDK
    • Why LearnBank?
  • 📊LearnGraph SDK
    • Why LearnGraph?
Powered by GitBook
On this page
  • Overview
  • Instantiating a LearnCard
  • Generating a Credential
  • Option 1: Easy DID Auth
  • Reading the Result
  • Option 2: Skipping DID Auth
  • Signing a Credential
  • Generating/Signing a Presentation
  • Storing a Presentation with CHAPI

Was this helpful?

  1. LearnCard SDK
  2. LearnCard Core
  3. CHAPI

Using LearnCard to Interact with a CHAPI Wallet

Learn How to Store an Issued Verifiable Credential into a CHAPI compliant Wallet with LearnCard!

PreviousDemo ApplicationNextCheat Sheets

Last updated 1 year ago

Was this helpful?

Overview

Using , Wallet software can register itself for a user, allowing it to become easily discoverable by a third party that would like to send a credential into that Wallet software. The result is a shared interface where issuers can simply send a credential off to CHAPI and allow the wallet to take care of everything else. The wallet software can then report back to the issuer whether or not it successfully stored the credential.

Let's use LearnCard to build out the issuer side of this flow together!

Instantiating a LearnCard

As an issuer, we will need an identity in the form of a did. LearnCard allows us to determinstically create a did from a simple string. In a real application, you will want to use a true random source to generate one of these strings, and then store it somewhere very secure. However, for the purposes of this documentation, we will get by with the string 'a' 😉

import { initLearnCard } from '@learncard/init';

const learnCard = await initLearnCard({ seed: 'a' });

Generating a Credential

Before we can ask a wallet to store a credential, we first need to generate a credential! There are many different ways to go about this, but LearnCard allows us to create a test credential rather easily!

const testVc = learnCard.invoke.newCredential();

Option 1: Easy DID Auth

Now that our credential is made, we can easily use CHAPI/DIDAuth to ask for the user's did, sign the credential, and store it all in one go!

const result = await learnCard.invoke.storeCredentialViaChapiDidAuth(testVc);

Reading the Result

The result object is a simple object with a success boolean, and a reason string. The four possible values it can hold, as well as what they represent are below:

Value
Explanation

{ success: true }

The credential was successfully stored

{ success: false, reason: 'did not auth' }

The user rejected the DIDAuth request

{ success: false, reason: 'auth failed verification' }

The user's wallet software failed the verification challenge

{ success: false, reason: 'did not store' }

The user passed DID Authentication, but did not store the credential

Option 2: Skipping DID Auth

Signing a Credential

With our credential generated, we will need to sign it, which will allow verifying parties to prove that this credential actually came from our did!

const vc = await learnCard.invoke.issueCredential(testVc);

Generating/Signing a Presentation

With our credential signed and generated, we will now need to create a presentation that we can send off via CHAPI. This presentation will store the credential inside of it, and we can easily create and sign one with LearnCard!

const unsignedVp = await learnCard.invoke.getTestVp(vc);
const vp = await learnCard.invoke.issuePresentation(unsignedVp);

Storing a Presentation with CHAPI

Now that we've got our presentation made, we can send it off to CHAPI and ask a wallet to store it!

const success = await learnCard.invoke.storePresentationViaChapi(vp);

if (success) console.log('Credential successfully stored!');
else console.log('Credential could not be stored');
🔰
🔰
CHAPI