Skip to main content

Issuing and Verifying Credentials

This tutorial walks through how to issue and verify Verifiable Credentials (VCs) using Veramo.

Step 1: Issue a Credential

To issue a credential, you need a DID for both the issuer and the subject (the person receiving the credential).

const credential = await agent.createVerifiableCredential({
credential: {
"@context": ["https://www.w3.org/2018/credentials/v1"],
type: ["VerifiableCredential"],
issuer: { id: "did:example:issuer" },
issuanceDate: "2024-01-01T00:00:00Z",
credentialSubject: {
id: "did:example:subject",
degree: { type: "BachelorDegree", name: "Computer Science" },
},
},
});
console.log("Issued Credential:", credential);

Step 2: Verify a Credential

Once a credential is issued, it can be presented to a verifier for validation:

const isValid = await agent.verifyCredential({
credential,
});
console.log("Is Credential Valid?", isValid);

With these steps, you’ve learned how to issue and verify a Verifiable Credential!