Welcome to your first LearnCard integration! In just a few lines of code, you'll create a verifiable, claimable digital badge—what we call a Boost .
No experience required. Just code, coffee, and a terminal.
Copy # Using npm
npm install @learncard/init @learncard/claimable-boosts-plugin @learncard/simple-signing-plugin
# Using yarn
yarn add @learncard/init @learncard/claimable-boosts-plugin @learncard/simple-signing-plugin
# Using pnpm
pnpm add @learncard/init @learncard/claimable-boosts-plugin @learncard/simple-signing-plugin
Copy import { initLearnCard } from '@learncard/init';
import { getClaimableBoostsPlugin } from '@learncard/claimable-boosts-plugin';
import { getSimpleSigningPlugin } from '@learncard/simple-signing-plugin';
const seed = process.env.SECURE_SEED;
const profileId = 'my-awesome-org-profile';
const profileName = 'My Awesome Org';
if (!seed) {
console.error('Error: SECURE_SEED environment variable is not set.');
process.exit(1);
}
async function quickstartBoost() {
try {
console.log('Initializing LearnCard...');
const learnCard = await initLearnCard({
seed: seed,
network: true,
allowRemoteContexts: true
});
const signingLearnCard = await learnCard.addPlugin(
await getSimpleSigningPlugin(learnCard, 'https://api.learncard.app/trpc')
);
const claimableLearnCard = await signingLearnCard.addPlugin(
await getClaimableBoostsPlugin(signingLearnCard)
);
console.log('LearnCard initialized with plugins.');
try {
console.log(`Creating profile "${profileId}"...`);
await claimableLearnCard.invoke.createProfile({
profileId: profileId,
displayName: profileName,
description: 'Issuing awesome credentials.',
});
console.log(`Profile "${profileId}" created successfully.`);
} catch (error) {
if (error.message?.includes('Profile ID already exists')) {
console.log(`Profile "${profileId}" already exists, continuing.`);
} else {
throw new Error(`Failed to create profile: ${error.message}`);
}
}
console.log('Creating boost template...');
const boostTemplate = await claimableLearnCard.invoke.newCredential({
type: 'boost',
boostName: 'Quickstart Achievement',
boostImage: 'https://placehold.co/400x400?text=Quickstart',
achievementType: 'Influencer',
achievementName:'Quickstart Achievement',
achievementDescription: 'Completed the quickstart guide!',
achievementNarrative: 'User successfully ran the quickstart script.',
achievementImage: 'https://placehold.co/400x400?text=Quickstart'
});
console.log('Boost template created.');
console.log('Creating boost on the network...');
const boostUri = await claimableLearnCard.invoke.createBoost(
boostTemplate,
{
name: boostTemplate.name,
description: boostTemplate.achievementDescription,
}
);
console.log(`Boost created with URI: ${boostUri}`);
console.log('Generating claim link...');
const claimLink = await claimableLearnCard.invoke.generateBoostClaimLink(boostUri);
console.log('\n✅ Success! Your Claimable Boost link is ready:');
console.log(claimLink);
return claimLink;
} catch (error) {
console.error('\n❌ Error during quickstart process:', error);
process.exit(1);
}
}
quickstartBoost();
Copy export SECURE_SEED="your-very-secret-seed-phrase-here"
Copy ✅ Success! Your Claimable Boost link is ready:
https://claim.learncard.app/boost/abc123...
Anyone with that link can scan or click to claim their badge. It’s a live verifiable credential issued by your script.
We’re glad you’re here. Ready to build something great?