Documentation Index Fetch the complete documentation index at: https://docs.peaq.xyz/llms.txt
Use this file to discover all available pages before exploring further.
This concept has been absorbed into peaqOS. See peaqID for the current identity model.
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 stringRequired Required Name of the DID to be created. custom_document_fields CustomDocumentFieldsRequired Required Sets specific fields of the DID Document. address stringRequired* 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 SignatureOptional 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 stringOptional 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 stringOptional 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 stringRequired Required The algorithm used when generating a signature. issuer stringRequired Required Entity that issued the signature. hash stringRequired Required Hash value of the generated signature.
Services
Parameter Type EVM Substrate Description id stringRequired Required Identifier used to indicate what type of service is being used. type stringRequired Required Declares the type of service object being referenced. serviceEndpoint stringOptional Optional URI/URL that is used to point to another data storage location. data stringOptional Optional Data value that can be stored at this service.
Create DID Code Examples
EVM Unsigned Tx
EVM Unsigned Tx Response
EVM Write Tx
EVM Write Response
Substrate Unsigned Call
Substrate Unsigned Call Response
Substrate Write Call
Substrate Write Response
import os
from dotenv import load_dotenv
from peaq_sdk import Sdk
from peaq_sdk.types import ChainType, CustomDocumentFields, Verification, Service, Signature
load_dotenv()
HTTPS_PEAQ_URL = os.getenv( "HTTPS_PEAQ_URL" )
EVM_ADDRESS = os.getenv( "EVM_ADDRESS" )
sdk = Sdk.create_instance(
base_url = HTTPS_PEAQ_URL ,
chain_type = ChainType. EVM
)
name = 'DID_NAME_001'
response = sdk.did.create(
name = name,
custom_document_fields =
CustomDocumentFields(
verifications = [Verification( type = 'EcdsaSecp256k1RecoveryMethod2020' )],
signature = Signature( type = 'EcdsaSecp256k1RecoveryMethod2020' , issuer = '0x9Eeab1aCcb1A701aEfAB00F3b8a275a39646641C' , hash = '123' ),
services = [Service( id = '#ipfs' , type = 'peaqStorage' , data = '123' )]
),
address = EVM_ADDRESS
)
read(name, address)
Allows a user to read a previously created DID from the chain.
Parameter Type EVM Substrate Description name stringRequired Required Name of the DID stored. address stringRequired* Required* Address of the wallet that created the DID Document.
* The address is required when no seed is set.
Read DID Code Examples
EVM No Key Read
EVM No Key Response
EVM Key Read
EVM Key Response
Substrate No Key Read
Substrate No Key Response
Substrate Key Read
Substrate Key Response
import os
from dotenv import load_dotenv
from peaq_sdk import Sdk
from peaq_sdk.types import ChainType
load_dotenv()
HTTPS_PEAQ_URL = os.getenv( "HTTPS_PEAQ_URL" )
EVM_ADDRESS = os.getenv( "EVM_ADDRESS" )
sdk = Sdk.create_instance(
base_url = HTTPS_PEAQ_URL ,
chain_type = ChainType. EVM
)
name = 'DID_NAME_001'
document = sdk.did.read( name = name, address = EVM_ADDRESS )
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 stringRequired Required Name of the DID to be updated. custom_document_fields CustomDocumentFieldsRequired Required New fields to embed in the DID Document. These fully replace the prior document. address stringRequired* 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
EVM Unsigned Tx
EVM Unsigned Tx Response
EVM Write Tx
EVM Write Response
Substrate Unsigned Call
Substrate Unsigned Call Response
Substrate Write Call
Substrate Write Response
import os
from dotenv import load_dotenv
from peaq_sdk import Sdk
from peaq_sdk.types import ChainType, CustomDocumentFields, Verification, Service, Signature
load_dotenv()
HTTPS_PEAQ_URL = os.getenv( "HTTPS_PEAQ_URL" )
EVM_ADDRESS = os.getenv( "EVM_ADDRESS" )
sdk = Sdk.create_instance(
base_url = HTTPS_PEAQ_URL ,
chain_type = ChainType. EVM
)
name = 'DID_NAME_001'
response = sdk.did.update(
name = name,
custom_document_fields =
CustomDocumentFields(
verifications = [Verification( type = 'EcdsaSecp256k1RecoveryMethod2020' )],
signature = Signature( type = 'EcdsaSecp256k1RecoveryMethod2020' , issuer = '0x9Eeab1aCcb1A701aEfAB00F3b8a275a39646641C' , hash = '456' ),
services = [Service( id = '#updated-ipfs' , type = 'peaqStorage' , data = 'updated-data' )]
),
address = EVM_ADDRESS
)
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 stringRequired Required Name of the DID to be removed from the chain. address stringRequired* 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.
Remove DID Code Examples
EVM Unsigned Tx
EVM Unsigned Tx Response
EVM Write Tx
EVM Write Response
Substrate Unsigned Call
Substrate Unsigned Call Response
Substrate Write Call
Substrate Write Response
import os
from dotenv import load_dotenv
from peaq_sdk import Sdk
from peaq_sdk.types import ChainType
load_dotenv()
HTTPS_PEAQ_URL = os.getenv( "HTTPS_PEAQ_URL" )
EVM_ADDRESS = os.getenv( "EVM_ADDRESS" )
sdk = Sdk.create_instance(
base_url = HTTPS_PEAQ_URL ,
chain_type = ChainType. EVM
)
name = 'DID_NAME_001'
response = sdk.did.remove( name = name, address = EVM_ADDRESS )