# LearnCard Wallet SDK

**LearnCard Wallet SDK** is the fundamental component of the LearnCard ecosystem, providing core functionality for working with verifiable credentials (VCs) and decentralized identifiers (DIDs). It serves as the foundation upon which the entire LearnCard system is built, offering a plugin system for extending functionality and standardized interfaces for common operations.

## Install the SDK

Install using the package manager of your choice:

{% tabs %}
{% tab title="pnpm" %}

```bash
pnpm i @learncard/init
```

{% endtab %}

{% tab title="yarn" %}

```bash
yarn add @learncard/init
```

{% endtab %}

{% tab title="npm" %}

```bash
npm i @learncard/init
```

{% endtab %}
{% endtabs %}

## Create, Issue, and Verify a Credential

To make your first wallet, import and call `initLearnCard` with a unique string that is 64 characters or less:

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

// Generate a random key for wallet seed
const seed = Array.from(crypto.getRandomValues(new Uint8Array(32)), dec =>
  dec.toString(16).padStart(2, "0")
).join("");

/** Or, if in node environment:
    const seed = crypto.randomBytes(32).toString('hex');
**/

// Initialize a new LearnCard wallet with a unique string that is 64 characters or less 
const learnCard = await initLearnCard({ seed });

// Returns an unsigned, achievement credential in the OBv3 spec.
const unsignedAchievementCredential = learnCard.invoke.newCredential({ type: 'achievement' });

// Sign the Credential with your LearnCard issuer DID
const signedVc = await learnCard.invoke.issueCredential(unsignedAchievementCredential);

// Verify the Credential
const result = await learnCard.invoke.verifyCredential(signedVc, {}, true);
console.log(result);
// [
//     { status: "Success", check: "proof", message: "Valid" },
//     {
//         status: "Success",
//         check: "expiration",
//         message: "Valid • Does Not Expire"
//     }
// ]
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.learncard.com/sdks/learncard-core.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
