Skip to main content

Attest a Claim (Issue a Credential)

Once an Attester has received a to-be-attested Credential from a Claimer, they will typically verify the information in the claim. If the claims correspond to truth, the Attester will proceed by attesting the root hash of the credential on the KILT blockchain, timestamping the attestation operation. A deposit is reserved from the balance of the KILT account submitting the creation transaction, which is returned if and when the attestation is removed from the chain.

info

An Attester is required to have a full DID with an attestation key. To see how to manage DIDs, please refer to the DID section.

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

export async function createAttestation(
attester: Kilt.DidUri,
submitterAccount: Kilt.KiltKeyringPair,
signCallback: Kilt.SignExtrinsicCallback,
credential: Kilt.ICredential
): Promise<void> {
const api = Kilt.ConfigService.get('api')

// Create an attestation object and write its root hash on the chain
// using the provided attester's full DID.
const { cTypeHash, claimHash, delegationId } =
Kilt.Attestation.fromCredentialAndDid(credential, attester)

// Write the attestation info on the chain.
const attestationTx = api.tx.attestation.add(
claimHash,
cTypeHash,
delegationId
)
const authorizedAttestationTx = await Kilt.Did.authorizeTx(
attester,
attestationTx,
signCallback,
submitterAccount.address
)
await Kilt.Blockchain.signAndSubmitTx(
authorizedAttestationTx,
submitterAccount
)
}