Enabling DIP for user accounts on the KILT blockchain
For an account to take advantage of DIP it needs a decentralized identity (DID) and to create a transaction on the provider chain to generate a cross-chain identity commitment.
For an account to be able to do this, a Dapp developer needs to build the functionality into their app for a user using the DIP SDK.
The implementation of this transaction is per-chain and this documentation provides an example of how to do this on the KILT blockchain.
Using the KILT DIP SDK
Add the SDK as a dependency:
- npm
- Yarn
- pnpm
npm install @kiltprotocol/dip-sdk
yarn add @kiltprotocol/dip-sdk
pnpm add @kiltprotocol/dip-sdk
Include the following imports in your code:
import { generateDipAuthorizedTxForSibling } from '@kiltprotocol/dip-sdk'
The generateDipAuthorizedTxForSibling method returns a submittable extrinsic promise for the provided call which includes a complete DIP proof according to the parameters provided. You can then use this on a consumer chain as the submitterAddress parameter of which the provider chain is a sibling.
A valid call is a HEX-encoded call of the parent relaychain with the right key re-generated from the provided seedling information, i.e., either with the provided mnemonic or with the provided combination of base mnemonic and derivation path.
You can generate valid HEX-encoded calls at PolkadotJS Apps from the Developer > Extrinsics menu.
Copy the value from encoded call data and pass it as a parameter.
The command requires the following variables:
callTheCallon the consumer chain that requires a DIP origin.consumerApiTheApiPromiseinstance for the consumer chain.didUriThe DID URI of the DIP subject performing the cross-chain operation.keyIdsThe verification method IDs of the DID are revealed in the cross-chain operation.proofVersionThe version of the DIP proof to generate.providerApiTheApiPromiseinstance for the provider chain.relayApiTheApiPromiseinstance for the parent relay chain.signerThe signing callback to sign the cross-chain transaction.submitterAddressThe address of the transaction submitter on the consumer chain.keyRelationshipTheVerificationKeyRelationshiprequired for the DIP operation authorized on the relay chain.
And the following optional environment variables:
blockHeightThe block number on the consumer chain to use for the DID signature. Uses the latest best block number, if not provided.genesisHashThe genesis hash of the consumer chain to use for the DID signature. Retrieved at runtime from the consumer chain If not provided.providerBlockHeightThe block number of the provider to use for the generation of the DIP proof. Uses the latest finalized block number if not provided.accountIdRuntimeTypeThe runtime type definition for anAccountIdon the consumer chain. Uses theAccountIdtype if not provided.blockNumberRuntimeTypeThe runtime type definition for aBlockNumberon the consumer chain. Uses theu64type if not provided.identityDetailsRuntimeTypeThe runtime type definition for theIdentityDetailson the consumer chain. Uses theOption<u128>type, representing a simple nonce if not provided.includeWeb3NameFlag indicating whether the generated DIP proof should include the web3name of the DID subject. If not provided, the web3name is not revealed.linkedAccountsThe list of linked accounts to revealed in the generated DIP proof. No account is revealed if not provided.