generateCreateDIDRequest API Reference
This document provides a concise API reference for the generateCreateDIDRequest function within the Hedera DID SDK for JavaScript.
Function Signature
This function generates a request to create a new Decentralized Identifier (DID) on the Hedera network using the Client Managed Secret Mode.
The generateCreateDIDRequest function is invoked with providers and options parameters. The providers parameter encapsulates configuration parameters for interacting with the Hedera network, while the options parameter enables customization of the DID creation procedure and passing required public key.
function generateCreateDIDRequest(
options: GenerateCreateDIDRequestOptions,
providers: PublisherProviders,
): Promise<CreateDIDRequest>;
Parameters
The function accepts the following parameters:
-
providers: (Required) An object encapsulating configuration parameters for interacting with the Hedera network. -
options: (Required) DID creation request options.
providers Parameter
The table below details the structure of the providers parameter.
| Name | Type | Description |
|---|---|---|
providers |
|
An object containing a Hedera Client or a transaction Publisher (refer to PublisherProviders Type for details). |
options Parameter
The table below details the structure of the options parameter.
| Name | Type | Description |
|---|---|---|
didDocumentFields |
|
Initial DID document fields used to construct the create operation payload. |
topicId? |
|
Existing topic id to use. If omitted, a new topic is created. |
verificationMethod? |
|
Verification method id used for signing-request generation. If omitted, defaults to |
topicReader? |
|
Optional topic reader used by the flow. |
Return Value
Upon successful execution, the function returns a Promise that resolves to a CreateDIDRequest object.
The table below describes the structure of the CreateDIDRequest type.
| Name | Type | Description |
|---|---|---|
state |
|
Serialized state used by |
signingRequest |
|
Proof signing request to be signed client-side. |
Data Types
This section elaborates on the data types employed within the providers and options parameters.
PublisherProviders Type
To utilize this type, at least one of the following must be defined: client or publisher. If both are provided, publisher takes precedence.
The table below provides a detailed description of the PublisherProviders type.
| Name | Type | Description |
|---|---|---|
clientOptions? |
|
Configuration options for instantiating a Hedera Client. See a full running example in the source code. |
client? |
|
An instance of a Hedera Client. See a full running example in the source code. |
publisher? |
|
An instance of a Publisher responsible for submitting the DID creation transaction to the Hedera network. |
Errors
The following table enumerates the exceptions that may arise during the execution of the generateCreateDIDRequest function.
| Exception code | Description |
|---|---|
|
Providers must contain client options or client or publisher. |
|
Hashgraph SDK Client must be configured with a network. |
|
Hashgraph SDK Client must be configured with an operator account. |
|
Controller is not a valid Hedera DID. |
|
DID already exists on the network. |
|
Failed to create topic. |