Comment on page
Construction
Depending on your use-case and specific needs, constructing a LearnCard is likely as simple as the following code:
import { initLearnCard } from '@learncard/init';
const learnCard = await initLearnCard({ seed: 'abc123' });
For a full description of instantiating a LearnCard by configuration, check out the full documentation on the
initLearnCard
function:There be dragons here. 🐉
In production environments, take great care and caution when generating and storing key material. Insufficient entropy or insecure storage, among other vectors, can easily compromise your data and identities.
How to generate and store keys is left to you, the consumer. However, if you'd like to simply generate a random key, you can do so with the following code:
Browser
Node
const randomKey = Array.from(crypto.getRandomValues(new Uint8Array(32)), dec =>
dec.toString(16).padStart(2, "0")
).join("");
import crypto from 'node:crypto';
const randomKey = crypto.randomBytes(32).toString('hex');
Webpack 5
Vite
// Make sure you have the didkit plugin installed! pnpm i @learncard/didkit-plugin
import { initLearnCard } from '@learncard/init';
import didkit from '@learncard/didkit-plugin/dist/didkit/didkit_wasm_bg.wasm';
const learnCard = await initLearnCard({ seed: 'abc123', didkit });
// Make sure you have the didkit plugin installed! pnpm i @learncard/didkit-plugin
import { initLearnCard } from '@learncard/init';
import didkit from '@learncard/didkit-plugin/dist/didkit/didkit_wasm_bg.wasm?url';
const learnCard = await initLearnCard({ seed: 'abc123', didkit });
Next, refer to our documentation on Managing Seed Phrase:
Last modified 6mo ago