> For the complete documentation index, see [llms.txt](https://sending-network.gitbook.io/sending.network/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://sending-network.gitbook.io/sending.network/sdk-documentation/unreal-sdk/did.md).

# DID

### Step 1. Check if the address has a DID.

```cpp
DidListResponse getResponse = request.getDidList(node,address);
```

Parameters：

| Name    | Type   | Description    | Required |
| ------- | ------ | -------------- | -------- |
| node    | string | edge node url  | true     |
| address | string | wallet address | True     |

Returns：

`DidListResponse`:

| Name  | Type         | Description      | Required |
| ----- | ------------ | ---------------- | -------- |
| Array | string array | a list of DID(s) | true     |

### Step 2. Choose DID or log in with an wallet address

Use the address for login when the interface array is empty; otherwise, use the first element of the array as the DID parameter.

```cpp
PreloginResponse postResponse = request.prelogin(node, preloginRequest.toString());
```

Parameters:

| Name    | Type   | Description                    | Required |
| ------- | ------ | ------------------------------ | -------- |
| did     | string | DID string，DID or address      | False    |
| address | string | wallet address, DID or address | False    |
| node    | string | edge node url                  | True     |

Returns:

`PreloginResponse`:

| Name    | Type   | Description                    | Required |
| ------- | ------ | ------------------------------ | -------- |
| did     | string | DID (existed or newly created) | true     |
| message | string | message to be signed           | true     |
| updated | string | update time                    | true     |

### 3. Sign the return value in step 2.

```cpp
LoginResponse loginResponse = request.didlogin(node, loginRequest.toString());
```

Parameters:

`LoginRequest`:

| Name        | Type            | Description                                         | Required |
| ----------- | --------------- | --------------------------------------------------- | -------- |
| type        | string          | login type（current value is `m.login.did.identity`） | true     |
| updated     | string          | time returned by `pre_login` `updated`              | true     |
| identifier  | IdentifierModel | login information                                   | true     |
| `device_id` | string          | device id, not required for new device              | false    |

`IdentifierModel` type：

| Name  | Type   | Description                                                                                                                                                                                            |
| ----- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| did   | string | DID                                                                                                                                                                                                    |
| token | string | sign the returned message from `pre_login`, and encode with *base16*. The signing method is to sign directly using a private key: You can directly call the `web3Sign()` in the DID class for signing. |

Returns:

`LoginResponse`:

| Name          | Type   | Description  | Required |
| ------------- | ------ | ------------ | -------- |
| access\_token | string | access token | true     |
| user\_id      | string | user id      | true     |
| device\_id    | string | device id    | true     |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://sending-network.gitbook.io/sending.network/sdk-documentation/unreal-sdk/did.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
