Unlink an Account From a KILT DID
Similar to the way a new account to DID link is created, removing a link can happen in one of three ways:
- The DID owner submits a transaction indicating which account to unlink:
- Typescript
- Javascript
import * as Kilt from '@kiltprotocol/sdk-js'
export async function unlinkAccountFromDid(
did: Kilt.DidUri,
submitterAccount: Kilt.KiltKeyringPair,
linkedAccountAddress: Kilt.KiltAddress,
signCallback: Kilt.SignExtrinsicCallback
): Promise<void> {
const api = Kilt.ConfigService.get('api')
// The DID owner removes the link between itself and the specified account.
const accountUnlinkTx = api.tx.didLookup.removeAccountAssociation({
AccountId32: linkedAccountAddress
})
const authorizedAccountUnlinkTx = await Kilt.Did.authorizeTx(
did,
accountUnlinkTx,
signCallback,
submitterAccount.address
)
await Kilt.Blockchain.signAndSubmitTx(
authorizedAccountUnlinkTx,
submitterAccount
)
}
# loading code...
- The linked account submits a transaction indicating that the link with the DID should be removed:
- Typescript
- Javascript
import * as Kilt from '@kiltprotocol/sdk-js'
export async function unlinkDidFromAccount(
linkOwnerAccount: Kilt.KeyringPair
): Promise<void> {
const api = Kilt.ConfigService.get('api')
// The tx does not need to be authorized by a DID, but the submitter account removes its own link.
const accountUnlinkTx = api.tx.didLookup.removeSenderAssociation()
await Kilt.Blockchain.signAndSubmitTx(accountUnlinkTx, linkOwnerAccount)
}
# loading code...
- The deposit payer submits a transaction indicating that they want to reclaim their deposit, which in turn removes the existing link between the specified account and DID:
- Typescript
- Javascript
import * as Kilt from '@kiltprotocol/sdk-js'
export async function reclaimLinkDeposit(
submitterAddress: Kilt.KeyringPair,
linkedAccountAddress: Kilt.KiltAddress
): Promise<void> {
const api = Kilt.ConfigService.get('api')
// The tx does not need to be authorized by a DID, but the deposit payer's account claims the deposit and removes the link.
const accountUnlinkTx = api.tx.didLookup.reclaimDeposit({
AccountId32: linkedAccountAddress
})
await Kilt.Blockchain.signAndSubmitTx(accountUnlinkTx, submitterAddress)
}
# loading code...