DID Operations
Using the initialized SDK instance, you can create a Decentralized Identifier (DID) on-chain, enabling identity-based operations within the peaq.
This operation generates a DID document and either:
- Returns an unsigned transaction or extrinsic (if no signer is available), or
- Submits the DID creation directly to the blockchain (if signing credentials are present).
create(name, custom_document_fields, address)
Enables the creation of a decentralized identity on-chain for your given entity.
Parameter | Type | EVM | Substrate | Description |
---|---|---|---|---|
name | string | Required | Required | Name of the DID to be created. |
custom_document_fields | CustomDocumentFields | Required | Required | Sets specific fields of the DID Document. |
address | string | Required* | Required* | Wallet address that is used to create the DID Document. If seed has been set, defaults to the corresponding public key address. |
* The address is required when no seed is set.
CustomDocumentFields
Parameter | Type | EVM | Substrate | Description |
---|---|---|---|---|
verifications | Verification[] | Optional | Optional | Stores the verification method that is tied to the wallet used to create this DID Document. |
signature | Signature | Optional | Optional | Used to store an issuer’s signature. |
services | Services[] | Optional | Optional | Links data, endpoints, or other metadata to the DID Document. |
Verification
Parameter | Type | EVM | Substrate | Description |
---|---|---|---|---|
type | string | Optional | Optional | Allows user to manually set the type of verification to be used with the public key tied to the DID Document. EVM Wallets: - EcdsaSecp256k1RecoveryMethod2020 Substrate Wallets: - Ed25519VerificationKey2020 - Sr25519VerificationKey2020 |
publicKeyMultibase | string | Optional | Optional | Allows user to manually set the public Key MultiBase they would like to use for their verification method. |
Signature
Parameter | Type | EVM | Substrate | Description |
---|---|---|---|---|
type | string | Required | Required | The algorithm used when generating a signature. |
issuer | string | Required | Required | Entity that issued the signature. |
hash | string | Required | Required | Hash value of the generated signature. |
Services
Parameter | Type | EVM | Substrate | Description |
---|---|---|---|---|
id | string | Required | Required | Identifier used to indicate what type of service is being used. |
type | string | Required | Required | Declares the type of service object being referenced. |
serviceEndpoint | string | Optional | Optional | URI/URL that is used to point to another data storage location. |
data | string | Optional | Optional | Data value that can be stored at this service. |
Create DID Code Examples
read(name, address)
Allows a user to read a previously created DID from the chain.
Parameter | Type | EVM | Substrate | Description |
---|---|---|---|---|
name | string | Required | Required | Name of the DID stored. |
address | string | Required* | Required* | Address of the wallet that created the DID Document. |
* The address is required when no seed is set.
Read DID Code Examples
update(name, custom_document_fields, address)
Updates an existing DID identified by name, overwriting the entire DID document with new custom_document_fields
. Use caution, as all existing data is replaced with the newly provided fields. Recommended to use the read
method to view the current DID document before updating.
Parameter | Type | EVM | Substrate | Description |
---|---|---|---|---|
name | string | Required | Required | Name of the DID to be updated. |
custom_document_fields | CustomDocumentFields | Required | Required | New fields to embed in the DID Document. These fully replace the prior document. |
address | string | Required* | Required* | Wallet address that owns the DID Document. If seed has been set, defaults to the corresponding public key address. |
* The address is required when no seed is set.
Update DID Code Examples
remove(name, address)
Removes an existing on-chain DID identified by name. Once removed, the DID data is no longer accessible via subsequent reads.
Parameter | Type | EVM | Substrate | Description |
---|---|---|---|---|
name | string | Required | Required | Name of the DID to be removed from the chain. |
address | string | Required* | Required* | Wallet address that owns the DID Document. If seed has been set, defaults to the corresponding public key address. |
* The address is required when no seed is set.