DID Registry Model (Authdid)

How to use DID registry contract model using SDK.

Authdid is a DID registry model primarily used for account abstraction in ImFACT network. Users can create DIDs and manage DID documents by creating or updating them.

  1. Create a contract-account first using function of contract class. The account must be deployed on the blockchain network. (Create an operation with contract.createWallet(), and use operation.sign() and operation.send(), or use contract.touch() to sign and send at once.)

  2. Create a register model operation using function registerModel() of authdid class with did method name parameter.

  3. Sign and send the operation to blockchain network. (You can check whether the model information has been properly registered using the getModelInfo() function.)

  4. Every user account can create their own did to the contract. When creating an operation using the create() function, a DID document of the default template is created.

  5. Sign and send the operation to blockchain network. (Check the did using getDID() method, did document using getDocument())

  6. The owner of a DID can update their DID document by creating an update-did-document operation using updateDocument(). It requires a Document instance, which must be constructed using writeDocument().

The authentications and verificationMethods parameters of the writeDocument() function must be arrays containing the following contents:

  • AsymKeyAuth instances, created by writeAsymkeyAuth()or LinkedAuth instances, created by writeLinkedAuth(). These authentication objects define the verification methods included in the DID document.

You can also update a DID document using a JSON object via: updateDocumentByDocumentJson() All SDK objects (AsymKeyAuth, LinkedAuth, Document, etc.) provide a .toHintedObject() method, which converts them into the JSON format required by the chain.

This makes it possible to:

  1. Fetch an existing document : const docInfo = await getDocument(contract, did);

  2. Modify the returned JSON

  3. Submit it back using : updateDocumentByDocumentJson(...)

Task
Method

Create authentication method

writeAsymkeyAuth(), writeLinkedAuth()

Create DID Document instance

writeDocument()

Convert SDK objects to JSON

.toHintedObject()

Update using instance

updateDocument()

Update using JSON

updateDocumentByDocumentJson()

Last updated