LearnCard CLI is an easy to use node REPL that instantiates a Learn Card wallet for you and gives you all the tools you need to easily play around with the Learn Card SDK!
Usage
npx@learncard/cli# Optionally specify a deterministic seed to instantiate the wallet withnpx@learncard/cli1b498556081a298261313657c32d5d0a9ce8285dc4d659e6787392207e4a7ac2h
Getting Started
From within the CLI, you should be able to start playing around with a basic learn card wallet. When the CLI boots up, it creates a default LearnCard called wallet that you can interact with.
Basic Usage
View your wallet's DID
One of the easiest ways to interact with your wallet, is to get your wallet's DID:
Once the CLI has booted up, you can start issuing credentials. Try a basic Verifiable Credential issuance and verification flow, for example:
// Create a new, unsigned test Verifiable CredentialconstunsignedVerifiableCredential=wallet.getTestVc();/**{ '@context': [ 'https://www.w3.org/2018/credentials/v1' ], id: 'http://example.org/credentials/3731', type: [ 'VerifiableCredential' ], issuer: 'did:key:z6MkuWb1dvhvime3BZdiuRGi1Q41o4h4hS5ZUizwBiGw3SU6', issuanceDate: '2020-08-19T21:41:50Z', credentialSubject: { id: 'did:example:d23dd687a7dc6787646f2eb98d0' }}*/// Then, issue the credential to yourself (i.e. sign the credential to turn it into a verifiable credential)constsignedVerifiableCredential=awaitwallet.issueCredential(unsignedVerifiableCredential);/** { '@context': [ 'https://www.w3.org/2018/credentials/v1' ], id: 'http://example.org/credentials/3731', type: [ 'VerifiableCredential' ], credentialSubject: { id: 'did:example:d23dd687a7dc6787646f2eb98d0' }, issuer: 'did:key:z6MkuWb1dvhvime3BZdiuRGi1Q41o4h4hS5ZUizwBiGw3SU6', issuanceDate: '2020-08-19T21:41:50Z', proof: { type: 'Ed25519Signature2018', proofPurpose: 'assertionMethod', verificationMethod: 'did:key:z6MkuWb1dvhvime3BZdiuRGi1Q41o4h4hS5ZUizwBiGw3SU6#z6MkuWb1dvhvime3BZdiuRGi1Q41o4h4hS5ZUizwBiGw3SU6', created: '2022-09-30T15:33:51.015Z', jws: 'eyJhbGciOiJFZERTQSIsImNyaXQiOlsiYjY0Il0sImI2NCI6ZmFsc2V9..NkaBWEFT2JCU1ZjMSGmbL72EPhVsAsLykAHULee2uh8YdqBqJbti_FmplQQvGnPDy80pbrFRA-IYQQUx11ISCw' }}**/// Then, verify the credential! // The verifies that the credential is valid, has not been tampered with, and was issued by and to the correct DIDsawaitwallet.verifyCredential(signedVerifiableCredential);/**[ { status: 'Success', check: 'proof', message: 'Valid' }, { status: 'Success', check: 'expiration', message: 'Valid • Does Not Expire' }]**/
Now, take the signedVerifiableCredential you created in the VC issuance flow above, and try wrapping it into a Verifiable Presentation, and verifying it.
At any point, you can initialize additional wallets in the CLI, which can be helpful for testing cross-wallet flows:
// Initialize an empty wallet (can not sign credentials)constemptyWallet=awaitinitLearnCard();// Initializes a new wallet with deterministically seeded key material.constseededWallet=awaitinitLearnCard({ seed:'abc123' });