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

# Serialized DID

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](/peaqchain/sdk-reference/javascript/did-operations#customdocumentfields) section.

## generateDidDocument(address, customDocumentFields)

| Parameter                | Type                   | EVM      | Substrate | Description                                                                                                                      |
| ------------------------ | ---------------------- | -------- | --------- | -------------------------------------------------------------------------------------------------------------------------------- |
| **address**              | `string`               | Required | Required  | Used for the id and controller fields in the generated DID Document.                                                             |
| **chainType**            | `ChainType`            | Required | Required  | Defines the expected type of address to be passed. H160 for EVM and SS58 for Substrate. Defaults expect SS58 address.            |
| **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. |

<CodeGroup>
  ```javascript Request theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  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
  });
  ```

  ```javascript Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  // result object of generated DID Document for the value stored on chain
  {
    value: '0a336469643a706561713a30783945656162316143636231413730316145664142303046336238613237356133393634363634314312336469643a706561713a3078394565616231614363623141373031614566414230304633623861323735613339363436363431432a590a052369706673120b6d616368696e65446174611a4368747470733a2f2f697066732e696f2f697066732f516d597741504a7a7635435a736e417a7438617556544c76336a45396e31547a3865787a68544874564d4a643374'
  }
  ```
</CodeGroup>
