> ## 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.

# DID Operations

<Warning>
  This concept has been absorbed into peaqOS. See [peaqID](/peaqos/concepts/peaqid) for the current identity model.
</Warning>

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. <br /><br />**EVM Wallets:** <br />- `EcdsaSecp256k1RecoveryMethod2020` <br />**Substrate Wallets:** <br />- `Ed25519VerificationKey2020` <br />- `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

<CodeGroup>
  ```python EVM Unsigned Tx theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  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
      )
  ```

  ```python EVM Unsigned Tx Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  {
    "message": "Constructed DID create transaction for 0x9Eeab1aCcb1A701aEfAB00F3b8a275a39646641C of the name DID_NAME_001. You must sign and send it externally.",
    "tx": {
      "to": "0x0000000000000000000000000000000000000800",
      "data": "0xcc4a70ca00000000000000000..."
    }
  }
  ```

  ```python EVM Write Tx theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  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_PRIVATE_KEY = os.getenv("EVM_PRIVATE_KEY")

  sdk = Sdk.create_instance(
      base_url=HTTPS_PEAQ_URL,
      chain_type=ChainType.EVM,
      seed=EVM_PRIVATE_KEY
  )

  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')]
          )
      )
  ```

  ```python EVM Write Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  {
    "message": "Successfully added the DID under the name DID_NAME_001 for user 0x9Eeab1aCcb1A701aEfAB00F3b8a275a39646641C.",
    "receipt": {
      "transactionHash": "0xaf146b28b2e1d8dae3200cb8e0878c67ac8614f68fb68d43905fd84539b70175",
      "transactionIndex": 0,
      "blockHash": "0x9df027467fd945434ad7c5eb90e798f66b30650a203749c3cf0c2d021cadf009",
      "from": "0x9Eeab1aCcb1A701aEfAB00F3b8a275a39646641C",
      "to": "0x0000000000000000000000000000000000000800",
      "blockNumber": 5845831,
      "cumulativeGasUsed": 63881,
      "gasUsed": 63881,
      "contractAddress": null,
      "status": 1,
      "effectiveGasPrice": 102000000000,
      "type": 2,
      "logs": [
        {
          "address": "0x0000000000000000000000000000000000000800",
          "topics": [
            "0x13aef52bc4a99da04591533072e304017e3fb76f43e7fadd25eb7f514c5ef6e5"
          ],
          "data": "0x0000000000000000000000009eeab1accb1a701aefab00f3b8a275a39646641c...",
          "blockHash": "0x9df027467fd945434ad7c5eb90e798f66b30650a203749c3cf0c2d021cadf009",
          "blockNumber": 5845831,
          "transactionHash": "0xaf146b28b2e1d8dae3200cb8e0878c67ac8614f68fb68d43905fd84539b70175",
          "transactionIndex": 0,
          "logIndex": 0,
          "transactionLogIndex": "0x0",
          "removed": false
        }
      ],
      "logsBloom": "0x0000004000000000000000000000000000000000000000000000000000000400..."
    }
  }
  ```

  ```python Substrate Unsigned Call theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  import os
  from dotenv import load_dotenv
  from peaq_sdk import Sdk
  from peaq_sdk.types import ChainType, CustomDocumentFields, Verification, Service, Signature

  load_dotenv()

  WSS_PEAQ_URL = os.getenv("WSS_PEAQ_URL")
  SUBSTRATE_ADDRESS = os.getenv("SUBSTRATE_ADDRESS")

  sdk = Sdk.create_instance(
      base_url=WSS_PEAQ_URL,
      chain_type=ChainType.SUBSTRATE
  )

  name = 'DID_NAME_001'

  response = sdk.did.create(
      name=name, 
      custom_document_fields=
          CustomDocumentFields(
              verifications=[Verification(type='Sr25519VerificationKey2020')],
              signature=Signature(type='Sr25519VerificationKey2020', issuer=SUBSTRATE_ADDRESS, hash='123'),
              services=[Service(id='#ipfs', type='peaqStorage', data='123')]
          ),
      address=SUBSTRATE_ADDRESS
      )
  ```

  ```python Substrate Unsigned Call Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  {
    "message": "Constructed DID create call for 5Df42mkztLtkksgQuLy4YV6hmhzdjYvDknoxHv1QBkaY12Pg of the name DID_NAME_001. You must sign and send externally.",
    "call": {
      "call_module": "PeaqDid",
      "call_function": "add_attribute",
      "call_args": {
        "did_account": "5Df42mkztLtkksgQuLy4YV6hmhzdjYvDknoxHv1QBkaY12Pg",
        "name": "DID_NAME_001",
        "value": "0a396469643a70656171...",
        "valid_for": null
      }
    }
  }
  ```

  ```python Substrate Write Call theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  import os
  from dotenv import load_dotenv
  from peaq_sdk import Sdk
  from peaq_sdk.types import ChainType, CustomDocumentFields, Verification, Service, Signature

  load_dotenv()

  WSS_PEAQ_URL = os.getenv("WSS_PEAQ_URL")
  SUBSTRATE_SEED = os.getenv("SUBSTRATE_SEED")

  sdk = Sdk.create_instance(
      base_url=WSS_PEAQ_URL,
      chain_type=ChainType.SUBSTRATE,
      seed=SUBSTRATE_SEED
  )

  name = 'DID_NAME_001'

  response = sdk.did.create(
      name=name, 
      custom_document_fields=
          CustomDocumentFields(
              verifications=[Verification(type='Sr25519VerificationKey2020')],
              signature=Signature(type='Sr25519VerificationKey2020', issuer='5Df42mkztLtkksgQuLy4YV6hmhzdjYvDknoxHv1QBkaY12Pg', hash='123'),
              services=[Service(id='#ipfs', type='peaqStorage', data='123')]
          )
      )
  ```

  ```python Substrate Write Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  {
    "message": "Successfully added the DID under the name DID_NAME_001 for user 5Df42mkztLtkksgQuLy4YV6hmhzdjYvDknoxHv1QBkaY12Pg.",
    "receipt": {
      "extrinsic_hash": "0xf325d23c0c0531f41a22931c18b4d695956b1add7586ec2b76810fd0a7fdc80e",
      "block_hash": "0xd9ccec8fdb461e59d45beea52332e737a08bee268e1b29532651ad0ac1f53346",
      "finalized": false,
      "extrinsic_index": 2,
      "call": {
        "module": "PeaqDid",
        "function": "add_attribute",
        "args": {
          "did_account": "5Df42mkztLtkksgQuLy4YV6hmhzdjYvDknoxHv1QBkaY12Pg",
          "name": "DID_NAME_001",
          "value": "0a396469643a70656171..."  // Truncated hex blob
        }
      },
      "events": [...],
      "is_success": true,
      "total_fee_amount": 2528404367045865
    }
  }
  ```
</CodeGroup>

## 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

<CodeGroup>
  ```python EVM No Key Read theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  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)
  ```

  ```python EVM No Key Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  {
    "name": "DID_NAME_001",
    "value": "0a336469643a70656171...",
    "validity": "4294967295",
    "created": "1751392704000",
    "document": {
      "id": "did:peaq:0x9Eeab1aCcb1A701aEfAB00F3b8a275a39646641C",
      "controller": "did:peaq:0x9Eeab1aCcb1A701aEfAB00F3b8a275a39646641C",
      "verificationMethods": [
        {
          "id": "did:peaq:0x9Eeab1aCcb1A701aEfAB00F3b8a275a39646641C#keys-1",
          "type": "EcdsaSecp256k1RecoveryMethod2020",
          "controller": "did:peaq:0x9Eeab1aCcb1A701aEfAB00F3b8a275a39646641C",
          "publicKeyMultibase": "0x9Eeab1aCcb1A701aEfAB00F3b8a275a39646641C"
        }
      ],
      "signature": {
        "type": "EcdsaSecp256k1RecoveryMethod2020",
        "issuer": "0x9Eeab1aCcb1A701aEfAB00F3b8a275a39646641C",
        "hash": "123"
      },
      "services": [
        {
          "id": "#ipfs",
          "type": "peaqStorage",
          "data": "123"
        }
      ],
      "authentications": [
        "did:peaq:0x9Eeab1aCcb1A701aEfAB00F3b8a275a39646641C#keys-1"
      ]
    }
  }
  ```

  ```python EVM Key Read theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  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")
  WSS_PEAQ_URL = os.getenv("WSS_PEAQ_URL")
  EVM_PRIVATE_KEY = os.getenv("EVM_PRIVATE_KEY")

  sdk = Sdk.create_instance(
      base_url=HTTPS_PEAQ_URL,
      chain_type=ChainType.EVM,
      seed=EVM_PRIVATE_KEY
  )

  name = 'DID_NAME_001'

  document = sdk.did.read(name=name)
  ```

  ```python EVM Key Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  {
    "name": "DID_NAME_001",
    "value": "0a336469643a706561713a307...",
    "validity": "4294967295",
    "created": "1751392704000",
    "document": {
      "id": "did:peaq:0x9Eeab1aCcb1A701aEfAB00F3b8a275a39646641C",
      "controller": "did:peaq:0x9Eeab1aCcb1A701aEfAB00F3b8a275a39646641C",
      "verificationMethods": [
        {
          "id": "did:peaq:0x9Eeab1aCcb1A701aEfAB00F3b8a275a39646641C#keys-1",
          "type": "EcdsaSecp256k1RecoveryMethod2020",
          "controller": "did:peaq:0x9Eeab1aCcb1A701aEfAB00F3b8a275a39646641C",
          "publicKeyMultibase": "0x9Eeab1aCcb1A701aEfAB00F3b8a275a39646641C"
        }
      ],
      "signature": {
        "type": "EcdsaSecp256k1RecoveryMethod2020",
        "issuer": "0x9Eeab1aCcb1A701aEfAB00F3b8a275a39646641C",
        "hash": "123"
      },
      "services": [
        {
          "id": "#ipfs",
          "type": "peaqStorage",
          "data": "123"
        }
      ],
      "authentications": [
        "did:peaq:0x9Eeab1aCcb1A701aEfAB00F3b8a275a39646641C#keys-1"
      ]
    }
  }
  ```

  ```python Substrate No Key Read theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  import os
  from dotenv import load_dotenv
  from peaq_sdk import Sdk
  from peaq_sdk.types import ChainType

  load_dotenv()

  WSS_PEAQ_URL = os.getenv("WSS_PEAQ_URL")
  SUBSTRATE_ADDRESS = os.getenv("SUBSTRATE_ADDRESS")

  sdk = Sdk.create_instance(
      base_url=WSS_PEAQ_URL,
      chain_type=ChainType.SUBSTRATE
  )

  name = 'DID_NAME_001'

  document = sdk.did.read(name=name, address=SUBSTRATE_ADDRESS)
  ```

  ```python Substrate No Key Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  {
    "name": "DID_NAME_001",
    "value": "0a396469643a70656171...",
    "validity": "4294967295",
    "created": "1751394168000",
    "document": {
      "id": "did:peaq:5Df42mkztLtkksgQuLy4YV6hmhzdjYvDknoxHv1QBkaY12Pg",
      "controller": "did:peaq:5Df42mkztLtkksgQuLy4YV6hmhzdjYvDknoxHv1QBkaY12Pg",
      "verificationMethods": [
        {
          "id": "did:peaq:5Df42mkztLtkksgQuLy4YV6hmhzdjYvDknoxHv1QBkaY12Pg#keys-1",
          "type": "Sr25519VerificationKey2020",
          "controller": "did:peaq:5Df42mkztLtkksgQuLy4YV6hmhzdjYvDknoxHv1QBkaY12Pg",
          "publicKeyMultibase": "z6QNpkN4bjiLRd5wzb2jYKiaMNVVyPrw3SNkcpXX19LtTEUJ"
        }
      ],
      "signature": {
        "type": "Sr25519VerificationKey2020",
        "issuer": "5Df42mkztLtkksgQuLy4YV6hmhzdjYvDknoxHv1QBkaY12Pg",
        "hash": "123"
      },
      "services": [
        {
          "id": "#ipfs",
          "type": "peaqStorage",
          "data": "123"
        }
      ],
      "authentications": [
        "did:peaq:5Df42mkztLtkksgQuLy4YV6hmhzdjYvDknoxHv1QBkaY12Pg#keys-1"
      ]
    }
  }
  ```

  ```python Substrate Key Read theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  import os
  from dotenv import load_dotenv
  from peaq_sdk import Sdk
  from peaq_sdk.types import ChainType

  load_dotenv()

  WSS_PEAQ_URL = os.getenv("WSS_PEAQ_URL")
  SUBSTRATE_SEED = os.getenv("SUBSTRATE_SEED")

  sdk = Sdk.create_instance(
      base_url=WSS_PEAQ_URL,
      chain_type=ChainType.SUBSTRATE,
      seed=SUBSTRATE_SEED
  )

  name = 'DID_NAME_001'

  document = sdk.did.read(name=name)
  ```

  ```python Substrate Key Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  {
    "name": "DID_NAME_001",
    "value": "0a396469643a706561713a354...",
    "validity": "4294967295",
    "created": "1751394168000",
    "document": {
      "id": "did:peaq:5Df42mkztLtkksgQuLy4YV6hmhzdjYvDknoxHv1QBkaY12Pg",
      "controller": "did:peaq:5Df42mkztLtkksgQuLy4YV6hmhzdjYvDknoxHv1QBkaY12Pg",
      "verificationMethods": [
        {
          "id": "did:peaq:5Df42mkztLtkksgQuLy4YV6hmhzdjYvDknoxHv1QBkaY12Pg#keys-1",
          "type": "Sr25519VerificationKey2020",
          "controller": "did:peaq:5Df42mkztLtkksgQuLy4YV6hmhzdjYvDknoxHv1QBkaY12Pg",
          "publicKeyMultibase": "z6QNpkN4bjiLRd5wzb2jYKiaMNVVyPrw3SNkcpXX19LtTEUJ"
        }
      ],
      "signature": {
        "type": "Sr25519VerificationKey2020",
        "issuer": "5Df42mkztLtkksgQuLy4YV6hmhzdjYvDknoxHv1QBkaY12Pg",
        "hash": "123"
      },
      "services": [
        {
          "id": "#ipfs",
          "type": "peaqStorage",
          "data": "123"
        }
      ],
      "authentications": [
        "did:peaq:5Df42mkztLtkksgQuLy4YV6hmhzdjYvDknoxHv1QBkaY12Pg#keys-1"
      ]
    }
  }
  ```
</CodeGroup>

## 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

<CodeGroup>
  ```python EVM Unsigned Tx theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  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
      )
  ```

  ```python EVM Unsigned Tx Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  {
    "message": "Constructed DID update transaction for 0x9Eeab1aCcb1A701aEfAB00F3b8a275a39646641C of the name DID_NAME_001. You must sign and send it externally.",
    "tx": {
      "to": "0x0000000000000000000000000000000000000800",
      "data": "0x68b4b2c10000000000000000000000009eeab1accb1a701aefab00f3b8a275a39646641c000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c4449445f4e414d455f30303100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003d2306133333634363936343361373036353631373133613330373833393435363536313632333136313433363336323331343133373330333136313435363634313432333033303436333336323338363133323337333536313333333933363334333633363334333134333132333336343639363433613730363536313731336133303738333934353635363136323331363134333"
    }
  }
  ```

  ```python EVM Write Tx theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  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_PRIVATE_KEY = os.getenv("EVM_PRIVATE_KEY")

  sdk = Sdk.create_instance(
      base_url=HTTPS_PEAQ_URL,
      chain_type=ChainType.EVM,
      seed=EVM_PRIVATE_KEY
  )

  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')]
          )
      )
  ```

  ```python EVM Write Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  {
    "transactionHash": "0x115cbb93e693d23b45c36016d7035d96aef01964f71b857303b2a9ade23504d1",
    "transactionIndex": 1,
    "blockHash": "0xc8dfbf2325cad44c8f3132d8a49a4e364397507bca5e720edd05b8b64039c431",
    "from": "0x9Eeab1aCcb1A701aEfAB00F3b8a275a39646641C",
    "to": "0x0000000000000000000000000000000000000800",
    "blockNumber": 5846312,
    "cumulativeGasUsed": 309376,
    "gasUsed": 49745,
    "contractAddress": null,
    "logs": [
      {
        "address": "0x0000000000000000000000000000000000000800",
        "topics": [
          "0x018be4d5e2634aefdb51c4ddd186f33072cfb5f6baf685579c2e214995dc9e4f"
        ],
        "data": "0x0000000000000000...000000",
        "blockHash": "0xc8dfbf2325cad44c8f3132d8a49a4e364397507bca5e720edd05b8b64039c431",
        "blockNumber": 5846312,
        "transactionHash": "0x115cbb93e693d23b45c36016d7035d96aef01964f71b857303b2a9ade23504d1",
        "transactionIndex": 1,
        "logIndex": 4,
        "removed": false
      }
    ],
    "logsBloom": "0x0000004000000000...000000",
    "status": 1,
    "effectiveGasPrice": 102000000000,
    "type": 2
  }
  ```

  ```python Substrate Unsigned Call theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  import os
  from dotenv import load_dotenv
  from peaq_sdk import Sdk
  from peaq_sdk.types import ChainType, CustomDocumentFields, Verification, Service, Signature

  load_dotenv()

  WSS_PEAQ_URL = os.getenv("WSS_PEAQ_URL")
  SUBSTRATE_ADDRESS = os.getenv("SUBSTRATE_ADDRESS")

  sdk = Sdk.create_instance(
      base_url=WSS_PEAQ_URL,
      chain_type=ChainType.SUBSTRATE
  )

  name = 'DID_NAME_001'

  response = sdk.did.update(
      name=name, 
      custom_document_fields=
          CustomDocumentFields(
              verifications=[Verification(type='Ed25519VerificationKey2020')],
              signature=Signature(type='Ed25519VerificationKey2020', issuer=SUBSTRATE_ADDRESS, hash='456'),
              services=[Service(id='#updated-ipfs', type='peaqStorage', data='updated-data')]
          ),
      address=SUBSTRATE_ADDRESS
      )
  ```

  ```python Substrate Unsigned Call Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  {
    "call_module": "PeaqDid",
    "call_function": "update_attribute",
    "call_args": {
      "did_account": "5Df42mkztLtkksgQuLy4YV6hmhzdjYvDknoxHv1QBkaY12Pg",
      "name": "DID_NAME_001",
      "value": "0a39646964...736b6579732d31",
      "valid_for": null
    }
  }
  ```

  ```python Substrate Write Call theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  import os
  from dotenv import load_dotenv
  from peaq_sdk import Sdk
  from peaq_sdk.types import ChainType, CustomDocumentFields, Verification, Service, Signature

  load_dotenv()

  WSS_PEAQ_URL = os.getenv("WSS_PEAQ_URL")
  SUBSTRATE_SEED = os.getenv("SUBSTRATE_SEED")

  sdk = Sdk.create_instance(
      base_url=WSS_PEAQ_URL,
      chain_type=ChainType.SUBSTRATE,
      seed=SUBSTRATE_SEED
  )

  name = 'DID_NAME_001'

  response = sdk.did.update(
      name=name, 
      custom_document_fields=
          CustomDocumentFields(
              verifications=[Verification(type='Ed25519VerificationKey2020')],
              signature=Signature(type='Ed25519VerificationKey2020', issuer='5Df42mkztLtkksgQuLy4YV6hmhzdjYvDknoxHv1QBkaY12Pg', hash='456'),
              services=[Service(id='#updated-ipfs', type='peaqStorage', data='updated-data')]
          )
      )
  ```

  ```python Substrate Write Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  {
    "message": "Successfully updated the DID under the name DID_NAME_001 for user 5Df42mkztLtkksgQuLy4YV6hmhzdjYvDknoxHv1QBkaY12Pg.",
    "receipt": {
      "extrinsic_hash": "0x6f72e86e2c50424866195ab7e7c9f08cd9bcb51621d8dc0cd503320a36df8135",
      "block_hash": "0xca84e35ef7bc07ec487a132d9967a19e8a901ec7ed9e39fe43baa3b39a671132",
      "finalized": false,
      "extrinsic_index": 2,
      "extrinsic": {
        "address": "5Df42mkztLtkksgQuLy4YV6hmhzdjYvDknoxHv1QBkaY12Pg",
        "module": "PeaqDid",
        "function": "update_attribute",
        "args": {
          "did_account": "5Df42mkzt...",
          "name": "DID_NAME_001",
          "value": "... (truncated)",
          "valid_for": null
        },
        "nonce": 1878,
        "tip": 0
      },
      "events": [...],
      "success": true,
      "total_fee": 2013819302693817,
      "weight": {
        "ref_time": 315663944,
        "proof_size": 6153
      }
    }
  }
  ```
</CodeGroup>

## 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.

### Remove DID Code Examples

<CodeGroup>
  ```python EVM Unsigned Tx theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  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)
  ```

  ```python EVM Unsigned Tx Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  {
    "message": "Constructed DID remove transaction for 0x9Eeab1aCcb1A701aEfAB00F3b8a275a39646641C of the name DID_NAME_001. You must sign and send it externally.",
    "tx": {
      "to": "0x0000000000000000000000000000000000000800",
      "data": "0xe8a816900000000000000000000000009eeab1accb1a701aefab00f3b8a275a39646641c0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000c4449445f4e414d455f3030310000000000000000000000000000000000000000"
    }
  }
  ```

  ```python EVM Write Tx theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  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_PRIVATE_KEY = os.getenv("EVM_PRIVATE_KEY")

  sdk = Sdk.create_instance(
      base_url=HTTPS_PEAQ_URL,
      chain_type=ChainType.EVM,
      seed=EVM_PRIVATE_KEY
  )

  name = 'DID_NAME_001'

  response = sdk.did.remove(name=name)
  ```

  ```python EVM Write Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  {
    "message": "Successfully removed the DID under the name DID_NAME_001 for user 0x9Eeab1aCcb1A701aEfAB00F3b8a275a39646641C.",
    "receipt": {
      "transactionHash": "0xfe305926a1a3fbfa2ed43d8d2795d8faefcee587dac1c9726943516e081359f0",
      "transactionIndex": 0,
      "blockHash": "0x8990405a02f54447595a1339b1a9952e58267a9a86044c9e7d8d23310dc98947",
      "from": "0x9Eeab1aCcb1A701aEfAB00F3b8a275a39646641C",
      "to": "0x0000000000000000000000000000000000000800",
      "blockNumber": 5846365,
      "cumulativeGasUsed": 44271,
      "gasUsed": 44271,
      "contractAddress": null,
      "logs": [
        {
          "address": "0x0000000000000000000000000000000000000800",
          "topics": [
            "0x8d8507f4f79e585e0cbbdeff53c51bfb6ffa6d44fbcc86e46ece2fad02b5d902"
          ],
          "data": "0x0000000000000000000000009eeab1accb1a701aefab00f3b8a275...",
          "blockHash": "0x8990405a02f54447595a1339b1a9952e58267a9a86044c9e7d8d23310dc98947",
          "blockNumber": 5846365,
          "transactionHash": "0xfe305926a1a3fbfa2ed43d8d2795d8faefcee587dac1c9726943516e081359f0",
          "transactionIndex": 0,
          "logIndex": 0,
          "transactionLogIndex": "0x0",
          "removed": false
        }
      ],
      "logsBloom": "0x000000400000000000000000000000000000000000000000000000...",
      "status": 1,
      "effectiveGasPrice": 102000000000,
      "type": 2
    }
  }
  ```

  ```python Substrate Unsigned Call theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  import os
  from dotenv import load_dotenv
  from peaq_sdk import Sdk
  from peaq_sdk.types import ChainType

  load_dotenv()

  WSS_PEAQ_URL = os.getenv("WSS_PEAQ_URL")
  SUBSTRATE_ADDRESS = os.getenv("SUBSTRATE_ADDRESS")

  sdk = Sdk.create_instance(
      base_url=WSS_PEAQ_URL,
      chain_type=ChainType.SUBSTRATE
  )

  name = 'DID_NAME_001'

  response = sdk.did.remove(name=name, address=SUBSTRATE_ADDRESS)
  ```

  ```python Substrate Unsigned Call Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  {
    "message": "Constructed DID remove call for 5Df42mkztLtkksgQuLy4YV6hmhzdjYvDknoxHv1QBkaY12Pg of the name DID_NAME_001. You must sign and send externally.",
    "call": {
      "call_module": "PeaqDid",
      "call_function": "remove_attribute",
      "call_args": {
        "did_account": "5Df42mkztLtkksgQuLy4YV6hmhzdjYvDknoxHv1QBkaY12Pg",
        "name": "DID_NAME_001"
      }
    }
  }
  ```

  ```python Substrate Write Call theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  import os
  from dotenv import load_dotenv
  from peaq_sdk import Sdk
  from peaq_sdk.types import ChainType

  load_dotenv()

  WSS_PEAQ_URL = os.getenv("WSS_PEAQ_URL")
  SUBSTRATE_SEED = os.getenv("SUBSTRATE_SEED")

  sdk = Sdk.create_instance(
      base_url=WSS_PEAQ_URL,
      chain_type=ChainType.SUBSTRATE,
      seed=SUBSTRATE_SEED
  )

  name = 'DID_NAME_001'

  response = sdk.did.remove(name=name)
  ```

  ```python Substrate Write Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  {
    "message": "Successfully removed the DID under the name DID_NAME_001 for user 5Df42mkztLtkksgQuLy4YV6hmhzdjYvDknoxHv1QBkaY12Pg.",
    "receipt": {
      "extrinsic_hash": "0x554789ce0eb9c59f082867255e92a19c3e2dc6c54fff13f21c5f2892a3dd6dfd",
      "block_hash": "0xc936185f3cffca622b4b0e97dfd19ea3598252f133367d6ea1a8f8b3bd1b7221",
      "block_number": null,
      "finalized": false,
      "extrinsic_index": 2,
      "extrinsic": {
        "address": "5Df42mkztLtkksgQuLy4YV6hmhzdjYvDknoxHv1QBkaY12Pg",
        "call": {
          "module": "PeaqDid",
          "function": "remove_attribute",
          "args": [
            {
              "name": "did_account",
              "type": "AccountId",
              "value": "5Df42mkztLtkksgQuLy4YV6hmhzdjYvDknoxHv1QBkaY12Pg"
            },
            {
              "name": "name",
              "type": "BoundedVecName",
              "value": "DID_NAME_001"
            }
          ]
        },
        "nonce": 1879
      },
      "events": [...],
      "success": true,
      "total_fee": 2387350825469955
    }
  }

  ```
</CodeGroup>
