Requesting a Verifiable Credential
This document describes how to use the Litentry’s client-sdk to request a Verifiable Credential.
Last updated
This document describes how to use the Litentry’s client-sdk to request a Verifiable Credential.
Last updated
The IdentityHub issues Verifiable Credentials (VCs) based on available Assertions. Users store the resulting VCs which can be claimed based on the Credential Definition constraints dictated by the IdentityHub. The resulting VCs are downloadable by users and they can be uploaded to any 3rd party as a user deems fit.
Before continuing, make sure you have completed all the steps from the Installation section.
Assertion
structThe Assertion
struct holds the subject clauses that the IdentityHub evaluates. It consequently dictates the output clauses of the Verifiable Credential.
You can check all the available Litentry’s assertions and their parameters here.
For this example, we will use the TokenHoldingAmount
assertion and constrain it to LIT
. It will assert if the number of LIT tokens of the subject is greater than 0.
Tip: You can also use the Extrinsic builder in the Polkadot.js App to explore the assertions and their parameters.
Build a secure trusted request
The call
object has the following properties:
call.payloadToSign
: The hex-encoded trusted call.
call.txHash
: The hash
that will identify the request.
call.send
: A callback function to send the request to the Litentry Enclave.
The trusted call needs to be signed by the prime identity. This ensures the request is legit. The message to sign is found in call.payloadToSign
.
The signature should be a hex-encoded string. Optionally accepted formats are: base58-encoded string for Solana and base64-encoded for Bitcoin identities.
Once the call.payloadToSign
the message is signed by the prime identity, we can send the transaction.
The result
object has the following properties:
result.response
: The raw Enclave’s response. An array of WorkerRpcReturnValue
struct.
request.vcPayloads
: And array containing the Byte
representation of the VC or Error
.
Subscribing to the request is enabled for the requestBatchVc
method, as many assertions may be requested.
Here is an example of it: