Our SDK offers the ability to generate a serialized DID Document. On the blockchain itself we do not store the entire DID Document Object representation, rather we store the serialized document in hexadecimal. This is useful if you would like to manually send the document on-chain. To get a better understand about what is being stored please refer to the DID Document Custom Document Fields section.

generateDidDocument(address, customDocumentFields)

ParameterTypeEVMSubstrateDescription
addressstringRequiredRequiredUsed for the id and controller fields in the generated DID Document.
chainTypeChainTypeRequiredRequiredDefines the expected type of address to be passed. H160 for EVM and SS58 for Substrate. Defaults expect SS58 address.
customDocumentFieldscustomDocumentFieldsOptionalOptionalUsed to set specific fields of the DID Document. If none is set, an empty document will be generated with id and controller set.
import { Sdk } from "@peaq-network/sdk";

// evm address example
const address = '0x9Eeab1aCcb1A701aEfAB00F3b8a275a39646641C';

// possible example of custom document fields a DePIN could create
const customFields = {
    services: [{
      id: "#ipfs",
      type: "machineData",
      serviceEndpoint: "https://ipfs.io/ipfs/QmYwAPJzv5CZsnAzt8auVTLv3jE9n1Tz8exzhTHtVMJd3t"
    }]
}

const result = await Sdk.generateDidDocument({
    address: address,
    chainType: Sdk.ChainType.EVM,
    customDocumentFields: customFields
});