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.
Credential

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.

In the following, we'll refer to it as <credentialJSONString>.

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:

import * as Kilt from '@kiltprotocol/sdk-js'

export async function main(credential: Kilt.Credential) {
// 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 Kilt 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 Kilt.disconnect()
console.log('Disconnected from KILT testnet')
}

Run

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

node verification.js

In your logs, you should see chain queries and successful verification (isValid: true).

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

Or... did you? ๐Ÿ˜ˆ