Skip to main content

Verify a Claim

In this section, you'll play the role of a verifier:

  • You'll take an Credential object given to you by a claimer;
  • You'll verify that its data is correct;
  • You'll verify that the attestation is valid, i.e. its hash exists on-chain and the attestation has not been revoked.

A Credential object is also called an Attested Claim: It is what claimers present to verifiers upon request.

Get an Credential object

You can either:

  • Take the Credential object you've generated in the previous step as an attester;
  • Or if you're in a workshop, ask another participant to send you their Credential object.

Create a file

Create a new file verification.js.
All of the code for this step needs to go into this file.

Code: verify

Paste the following code in verification.js:

const ProofID = require('@proofid/pid-ts-lib')

async function verifyCredential(credential) {
await ProofID.connect()
// The `verify()` method does two things:
// 1. verifies that the data is valid for the given CTYPE
// 2. verifies that the attestation hash is present on the ProofID blockchain and that the attestation has not been revoked
const isValid = await credential.verify()
console.log('Is the credential valid?', isValid)

// disconnect from the chain
await ProofID.disconnect()
console.log('Disconnected from Alfheim testnet')

module.exports.verifyCredential = verifyCredential


Run the code by running this command in your terminal, still within your pid-app directory:

node index.js

In your logs, you should see all the previous steps and the new chain queries and successful verification (isValid: true).

That's it! You've successfully verified a claim as a verifier.

Or... did you? ๐Ÿ˜ˆ