Skip to main content

Delete a Full DID

Once a DID is no longer needed, it is recommended to deactivate it by removing it from the KILT blockchain. The following snippet shows how to do it:

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

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

// Create a DID deletion tx. We specify the number of endpoints currently stored under the DID because
// of the upper computation limit required by the blockchain runtime.
const didIdentifier = Kilt.Did.toChain(fullDid)
const endpointsCountForDid = await api.query.did.didEndpointsCount(
const didDeletionExtrinsic = api.tx.did.delete(endpointsCountForDid)

// Sign the DID deletion tx using the DID authentication key.
// This results in a DID-signed tx that can be then signed and submitted to the KILT blockchain by the account
// authorized in this operation, Alice in this case.
const didSignedDeletionExtrinsic = await Kilt.Did.authorizeTx(

await Kilt.Blockchain.signAndSubmitTx(

Please note that once deleted, a full DID becomes unusable and cannot be re-created anymore. This means that all credentials obtained with that DID are no longer valid and must be obtained with a different DID if needed.

Claim back a DID deposit

Claiming back the deposit of a DID is semantically equivalent to deactivating and deleting the DID, with the difference that the extrinsic to claim the deposit can only be called by the deposit owner and does not require a signature by the DID subject:

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

export async function reclaimFullDidDeposit(
submitterAddress: Kilt.KiltKeyringPair,
fullDid: Kilt.DidUri
): Promise<void> {
const api = Kilt.ConfigService.get('api')

// Generate the tx to claim the deposit back.
// It includes the DID identifier for which the deposit needs to be returned
// and the count of services to provide an upper bound to the computation of the tx execution.
const identifier = Kilt.Did.toChain(fullDid)
const endpointsCountForDid = await api.query.did.didEndpointsCount(identifier)
const depositClaimExtrinsic = api.tx.did.reclaimDeposit(

// The submission will fail if `submitterAddress` is not the owner of the deposit associated with the given DID identifier.
await Kilt.Blockchain.signAndSubmitTx(depositClaimExtrinsic, submitterAddress)