This concept has been absorbed into peaqOS. See peaqID for the current identity model.
create(name, address, seed, customDocumentFields)
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. |
| address | string | Required | Optional | Wallet address that is used to create the DID Document. If seed set for substrate, defaults to public address for that seed. |
| seed | string | N/A | Optional | Mnemonic phrase used in Substrate instances to execute write transactions on behalf of the wallet. Not necessary when seed set at instance creation. |
| customDocumentFields | CustomDocumentFields | Optional | Optional | Used to set specific fields of the DID Document. If none is set, an empty document will be generated with id and controller set to the signer’s address. |
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
import { Sdk } from "@peaq-network/sdk";
const HTTPS_BASE_URL = "https://quicknode.peaq.xyz";
const EVM_ADDRESS = process.env["EVM_ADDRESS"];
const EVM_PRIVATE = process.env["EVM_PRIVATE"];
const sdk = await Sdk.createInstance({
baseUrl: HTTPS_BASE_URL,
chainType: Sdk.ChainType.EVM
});
const name = "DID_NAME";
// possible example of custom document fields a DePIN could create
const customFields = {
services: [{
id: "#ipfs",
type: "machineData",
serviceEndpoint: "https://ipfs.io/ipfs/QmYwAPJzv5CZsnAzt8auVTLv3jE9n1Tz8exzhTHtVMJd3t"
}]
};
const tx = await sdk.did.create({
name: name,
address: EVM_ADDRESS,
customDocumentFields: customFields
});
// Create DID using sendEvmTx() function
const receipt = await Sdk.sendEvmTx({
tx: tx,
baseUrl: HTTPS_BASE_URL,
seed: EVM_PRIVATE
});
// sdk.did.create({}) return object
{
to: '0x0000000000000000000000000000000000000800',
data: '0xcc4a70ca0000000000000000000000009eeab1accb1a701aefab00f3b8a275a39646641c000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000084449445f4e414d45000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000018a3061333336343639363433613730363536313731336133303738333934353635363136323331363134333633363233313431333733303331363134353636343134323330333034363333363233383631333233373335363133333339333633343336333633343331343331323333363436393634336137303635363137313361333037383339343536353631363233313631343336333632333134313337333033313631343536363431343233303330343633333632333836313332333733353631333333393336333433363336333433313433326135393061303532333639373036363733313230623664363136333638363936653635343436313734363131613433363837343734373037333361326632663639373036363733326536393666326636393730363637333266353136643539373734313530346137613736333534333561373336653431376137343338363137353536353434633736333336613435333936653331353437613338363537383761363835343438373435363464346136343333373400000000000000000000000000000000000000000000'
}
// sendEvmTx({}) return object
TransactionReceipt {
provider: JsonRpcProvider {},
to: '0x0000000000000000000000000000000000000800',
from: '0x9Eeab1aCcb1A701aEfAB00F3b8a275a39646641C',
contractAddress: null,
hash: '0x81d2c889f5563ff840ac05f5198a7bca7177aee11eb1dd6429cb53f171c42046',
index: 0,
blockHash: '0x800e6705226991336ccfc83207487567db7a3657a8f0ce3307221c6a4cf611cb',
blockNumber: 4486798,
logsBloom: '0x00000040000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
gasUsed: 55057n,
blobGasUsed: null,
cumulativeGasUsed: 55057n,
gasPrice: 100000000000n,
blobGasPrice: null,
type: 2,
status: 1,
root: undefined
}
import { Sdk } from "@peaq-network/sdk";
const WSS_BASE_URL = "wss://quicknode.peaq.xyz";
const SUBSTRATE_SEED = process.env["SUBSTRATE_SEED"];
const sdk = await Sdk.createInstance({
baseUrl: WSS_BASE_URL,
chainType: Sdk.ChainType.SUBSTRATE,
seed: SUBSTRATE_SEED
});
const name = "DID_NAME";
// possible example of custom document fields a DePIN could create
const customFields = {
services: [{
id: "#ipfs",
type: "machineData",
serviceEndpoint: "https://ipfs.io/ipfs/QmYwAPJzv5CZsnAzt8auVTLv3jE9n1Tz8exzhTHtVMJd3t"
}]
};
const response = await sdk.did.create({
name: name,
customDocumentFields: customFields
});
// disconnect when finished
await sdk.disconnect();
// sdk.did.create({}) return object
{
block_hash: '0x47bc5172ac83ac9088cb301e3072e114b0da174ac902afb5595422d2074f0376',
unsubscribe: [Function (anonymous)]
}
read(name, address, wssBaseUrl)
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 | Optional | Address of the wallet that created the DID Document. Reading from an EVM tx requires an address to be explicitly set. If a seed has been set for Substrate, the address tied to that phrase will be used. |
| wssBaseUrl | string | Required | Optional | WSS URL must be used to read DID Document. EVM must explicitly set WSS (Substrate has it stored during instance creation). |
Read DID Code Examples
import { Sdk } from "@peaq-network/sdk";
const HTTPS_BASE_URL = "https://quicknode.peaq.xyz";
const WSS_BASE_URL = "wss://quicknode.peaq.xyz";
const EVM_ADDRESS = process.env["EVM_ADDRESS"];
const sdk = await Sdk.createInstance({
baseUrl: HTTPS_BASE_URL,
chainType: Sdk.ChainType.EVM
});
const name = "DID_NAME";
const document = await sdk.did.read({
name: name,
address: EVM_ADDRESS,
wssBaseUrl: WSS_BASE_URL
});
// sdk.did.read({}) return object
{
name: 'DID_NAME',
value: '0a336469643a706561713a30783945656162316143636231413730316145664142303046336238613237356133393634363634314312336469643a706561713a3078394565616231614363623141373031614566414230304633623861323735613339363436363431432a590a052369706673120b6d616368696e65446174611a4368747470733a2f2f697066732e696f2f697066732f516d597741504a7a7635435a736e417a7438617556544c76336a45396e31547a3865787a68544874564d4a643374',
validity: '4,294,967,295',
created: '1,742,919,588,000',
document: {
id: 'did:peaq:0x9Eeab1aCcb1A701aEfAB00F3b8a275a39646641C',
controller: 'did:peaq:0x9Eeab1aCcb1A701aEfAB00F3b8a275a39646641C',
verificationMethods: [],
signature: undefined,
services: [ [Object] ],
authentications: []
}
}
import { Sdk } from "@peaq-network/sdk";
const WSS_BASE_URL = "wss://quicknode.peaq.xyz";
const SUBSTRATE_ADDRESS = process.env["SUBSTRATE_ADDRESS"];
// can use read only or a read/write instance to read
const sdk = await Sdk.createInstance({
baseUrl: WSS_BASE_URL,
chainType: Sdk.ChainType.SUBSTRATE
});
const name = "DID_NAME";
// when using read only an address must be defined
const document = await sdk.did.read({
name: name,
address: SUBSTRATE_ADDRESS
});
// disconnect when finished
await sdk.disconnect();
// sdk.did.read({}) return object
{
name: 'DID_NAME',
value: '0a396469643a706561713a35446634326d6b7a744c746b6b736751754c7934595636686d687a646a5976446b6e6f7848763151426b61593132506712396469643a706561713a35446634326d6b7a744c746b6b736751754c7934595636686d687a646a5976446b6e6f7848763151426b6159313250672a590a052369706673120b6d616368696e65446174611a4368747470733a2f2f697066732e696f2f697066732f516d597741504a7a7635435a736e417a7438617556544c76336a45396e31547a3865787a68544874564d4a643374',
validity: '4,294,967,295',
created: '1,742,920,026,000',
document: {
id: 'did:peaq:5Df42mkztLtkksgQuLy4YV6hmhzdjYvDknoxHv1QBkaY12Pg',
controller: 'did:peaq:5Df42mkztLtkksgQuLy4YV6hmhzdjYvDknoxHv1QBkaY12Pg',
verificationMethods: [],
signature: undefined,
services: [ [Object] ],
authentications: []
}
}
update(name, address, seed, customDocumentFields)
Allows the owner of the DID Document to update a previously created one. Uses the same parameters as createDid() function above for the Custom Document Fields.| Parameter | Type | EVM | Substrate | Description |
|---|---|---|---|---|
| name | string | Required | Required | Name of the DID to be updated. |
| address | string | Required | Optional | Wallet address that has the authority to update the DID Document. If Substrate seed at initialization, will default to the public address for that seed. |
| wssBaseUrl | string | Required | N/A | WSS URL must be used to read a DID Document. Used to read the previous DID Document at that location when updating a DID Document. |
| seed | string | N/A | Optional | If not set at instance creation, allows user to define who sends the Substrate Transactions. |
| customDocumentFields | CustomDocumentFields | Optional | Optional | Used to update specific fields of the DID Document. Overwrites the previous DID Document so make sure you keep track of data previously stored. |
Update DID Code Examples
import { Sdk } from "@peaq-network/sdk";
const HTTPS_BASE_URL = "https://quicknode.peaq.xyz";
const WSS_BASE_URL = "wss://quicknode.peaq.xyz";
const EVM_ADDRESS = process.env["EVM_ADDRESS"];
const EVM_PRIVATE = process.env["EVM_PRIVATE"];
const sdk = await Sdk.createInstance({
baseUrl: HTTPS_BASE_URL,
chainType: Sdk.ChainType.EVM
});
const name = "DID_NAME";
// add a verification method and include the previosly set service
const customFields = {
verificationMethods: [{
type: "EcdsaSecp256k1RecoveryMethod2020"
}],
services: [{
id: "#ipfs",
type: "machineData",
serviceEndpoint: "https://ipfs.io/ipfs/QmYwAPJzv5CZsnAzt8auVTLv3jE9n1Tz8exzhTHtVMJd3t"
}]
};
const tx = await sdk.did.update({
name: name,
address: EVM_ADDRESS,
wssBaseUrl: WSS_BASE_URL,
customDocumentFields: customFields
});
// send using Sdk function
const receipt = await Sdk.sendEvmTx({
tx: tx,
baseUrl: HTTPS_BASE_URL,
seed: EVM_PRIVATE
});
// read to see the updated document
const document = await sdk.did.read({
name: name,
address: EVM_ADDRESS,
wssBaseUrl: WSS_BASE_URL
});
// sdk.did.update({}) return object
{
to: '0x0000000000000000000000000000000000000800',
data: '0x68b4b2c10000000000000000000000009eeab1accb1a701aefab00f3b8a275a39646641c000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000084449445f4e414d45000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000038630613333363436393634336137303635363137313361333037383339343536353631363233313631343336333632333134313337333033313631343536363431343233303330343633333632333836313332333733353631333333393336333433363336333433313433313233333634363936343361373036353631373133613330373833393435363536313632333136313433363336323331343133373330333136313435363634313432333033303436333336323338363133323337333536313333333933363334333633363334333134333161626630313061336136343639363433613730363536313731336133303738333934353635363136323331363134333633363233313431333733303331363134353636343134323330333034363333363233383631333233373335363133333339333633343336333633343331343332333662363537393733326433313132323034353633363437333631353336353633373033323335333636623331353236353633366637363635373237393464363537343638366636343332333033323330316133333634363936343361373036353631373133613330373833393435363536313632333136313433363336323331343133373330333136313435363634313432333033303436333336323338363133323337333536313333333933363334333633363334333134333232326133303738333934353635363136323331363134333633363233313431333733303331363134353636343134323330333034363333363233383631333233373335363133333339333633343336333633343331343332613539306130353233363937303636373331323062366436313633363836393665363534343631373436313161343336383734373437303733336132663266363937303636373332653639366632663639373036363733326635313664353937373431353034613761373633353433356137333665343137613734333836313735353635343463373633333661343533393665333135343761333836353738376136383534343837343536346434613634333337343332336136343639363433613730363536313731336133303738333934353635363136323331363134333633363233313431333733303331363134353636343134323330333034363333363233383631333233373335363133333339333633343336333633343331343332333662363537393733326433310000000000000000000000000000000000000000000000000000'
}
// sendEvmTx({}) return object
TransactionReceipt {
provider: JsonRpcProvider {},
to: '0x0000000000000000000000000000000000000800',
from: '0x9Eeab1aCcb1A701aEfAB00F3b8a275a39646641C',
contractAddress: null,
hash: '0xc6a36b8a0b9be9bd5326b3f0c31c3d04450c92a50cce0582ee362d94cf914aba',
index: 0,
blockHash: '0x3c94593083019c0d586c09df6cc55453f71b1bf544e0b85ef2ba6882c3878bf6',
blockNumber: 4487165,
logsBloom: '0x00000040000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000004000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000',
gasUsed: 48529n,
blobGasUsed: null,
cumulativeGasUsed: 48529n,
gasPrice: 100000000000n,
blobGasPrice: null,
type: 2,
status: 1,
root: undefined
}
import { Sdk } from "@peaq-network/sdk";
const WSS_BASE_URL = "wss://quicknode.peaq.xyz";
const SUBSTRATE_SEED = process.env["SUBSTRATE_SEED"];
const sdk = await Sdk.createInstance({
baseUrl: WSS_BASE_URL,
chainType: Sdk.ChainType.SUBSTRATE,
seed: SUBSTRATE_SEED
});
const name = "DID_NAME";
// add a verification method and include the previosly set service
const customFields = {
verificationMethods: [{
type: "Ed25519VerificationKey2020"
}],
services: [{
id: "#ipfs",
type: "machineData",
serviceEndpoint: "https://ipfs.io/ipfs/QmYwAPJzv5CZsnAzt8auVTLv3jE9n1Tz8exzhTHtVMJd3t"
}]
};
const response = await sdk.did.update({
name: name,
customDocumentFields: customFields
});
// read to see the updated document
const document = await sdk.did.read({
name: name
});
// disconnect when finished
await sdk.disconnect();
// sdk.did.update({}) return object
{
log: 'Successfully updated the DID Document of name DID_NAME at address 5Df42mkztLtkksgQuLy4YV6hmhzdjYvDknoxHv1QBkaY12Pg',
block_hash: '0x0586bf5d7cf76f75cde30f35a213ffaa4d3ec6ccc1e94d63c3353f92f95fb019',
unsubscribe: [Function (anonymous)]
}
remove(name, address, seed)
Deletes a previously created DID Document from the chain.| Parameter | Type | EVM | Substrate | Description |
|---|---|---|---|---|
| name | string | Required | Required | Name of the DID to be deleted. |
| address | string | Required | Optional | Wallet address that has the authority to delete the DID Document. |
| seed | string | N/A | Optional | If not set at instance creation, allows user to define who sends the Substrate Transactions. |
Remove DID Code Examples
import { Sdk } from "@peaq-network/sdk";
const HTTPS_BASE_URL = "https://quicknode.peaq.xyz";
const EVM_ADDRESS = process.env["EVM_ADDRESS"];
const EVM_PRIVATE = process.env["EVM_PRIVATE"];
const sdk = await Sdk.createInstance({
baseUrl: HTTPS_BASE_URL,
chainType: Sdk.ChainType.EVM
});
const name = "DID_NAME";
const tx = await sdk.did.remove({
name: name,
address: EVM_ADDRESS
});
// Send using Sdk function
const receipt = await Sdk.sendEvmTx({
tx: tx,
baseUrl: HTTPS_BASE_URL,
seed: EVM_PRIVATE
});
// sdk.did.remove({}) return object
{
to: '0x0000000000000000000000000000000000000800',
data: '0xe8a816900000000000000000000000009eeab1accb1a701aefab00f3b8a275a39646641c000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000084449445f4e414d45000000000000000000000000000000000000000000000000'
}
// sendEvmTx({}) return object
TransactionReceipt {
provider: JsonRpcProvider {},
to: '0x0000000000000000000000000000000000000800',
from: '0x9Eeab1aCcb1A701aEfAB00F3b8a275a39646641C',
contractAddress: null,
hash: '0xd5c548f2e5ded77441ba494eac7da77717ba24b4ee0a62fbd34baf5f2db34e56',
index: 0,
blockHash: '0x9d3c9356102d84ff7350104d5286c34f0db7f2a5e3e9356e98362dc96902475a',
blockNumber: 4488660,
logsBloom: '0x00000040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000',
gasUsed: 44223n,
blobGasUsed: null,
cumulativeGasUsed: 44223n,
gasPrice: 100000000000n,
blobGasPrice: null,
type: 2,
status: 1,
root: undefined
}
import { Sdk } from "@peaq-network/sdk";
const WSS_BASE_URL = "wss://quicknode.peaq.xyz";
const SUBSTRATE_SEED = process.env["SUBSTRATE_SEED"];
const sdk = await Sdk.createInstance({
baseUrl: WSS_BASE_URL,
chainType: Sdk.ChainType.SUBSTRATE,
seed: SUBSTRATE_SEED
});
const name = "DID_NAME";
const response = await sdk.did.remove({
name: name
});
// disconnect when finished
await sdk.disconnect();
// sdk.did.remove({}) return object
{
log: 'Successfully removed the DID of name DID_NAME from address 5Df42mkztLtkksgQuLy4YV6hmhzdjYvDknoxHv1QBkaY12Pg',
block_hash: '0x3a1e33a2bbee8e73fc405910bc56693b0d65ce5077456f2afd60f55250318cfa',
unsubscribe: [Function (anonymous)]
}

