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.
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 useoperation.sign()andoperation.send(), or usecontract.touch()to sign and send at once.)Create a register model operation using function
registerModel()of authdid class with did method name parameter.Sign and send the operation to blockchain network. (You can check whether the model information has been properly registered using the
getModelInfo()function.)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.Sign and send the operation to blockchain network. (Check the did using
getDID()method, did document usinggetDocument())The owner of a DID can update their DID document by creating an update-did-document operation using
updateDocument(). It requires aDocumentinstance, which must be constructed usingwriteDocument().
The authentications and verificationMethods parameters of the writeDocument() function must be arrays containing the following contents:
AsymKeyAuthinstances, created bywriteAsymkeyAuth()orLinkedAuthinstances, created bywriteLinkedAuth(). 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:
Fetch an existing document :
const docInfo = await getDocument(contract, did);Modify the returned JSON
Submit it back using :
updateDocumentByDocumentJson(...)
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