# DID

## **Get DID list**

<table><thead><tr><th width="271.3333333333333">Name</th><th>Parameters Description</th><th>Response</th></tr></thead><tbody><tr><td><code>getDIDList(address)</code></td><td><code>address</code>: wallet address</td><td>data: a list of DID</td></tr></tbody></table>

## Create a DID

<table><thead><tr><th width="235.66666666666666">Name</th><th>Parameters Description</th><th>Response</th></tr></thead><tbody><tr><td><code>createDID(address)</code></td><td><code>address</code>: wallet address</td><td><ul><li>DID: user DID (new one if none existed)</li><li>message: message to be signed</li><li>updated：updated time</li></ul></td></tr></tbody></table>

## Query DID information

<table><thead><tr><th width="243.66666666666666">Name</th><th>Parameters Description</th><th>Response</th></tr></thead><tbody><tr><td><code>queryDIDDetail(DID)</code></td><td><code>did</code>: DID string</td><td><ul><li>controllers: DID controller information</li><li>public_keys: device public key</li><li>current_public_key: public key</li></ul></td></tr></tbody></table>

## Save DID information

<table><thead><tr><th width="246">Name</th><th width="381.3333333333333">Parameters Description</th><th>Response</th></tr></thead><tbody><tr><td><code>saveDID(DID, data)</code></td><td><ul><li><code>DID</code>: DID string</li><li><p><code>data</code>: </p><ul><li>signature: signature of the signed message (derived by <em>web3.eth.personal.sign</em> method)</li><li>operation: <em>create</em>, <em>link</em>, <em>unlink</em>, <em>link_key</em>, <em>unlink_key</em></li><li>ids: an array of DID strings needed for <em>unlink</em> and <em>unlink_key</em> operation<em>.</em> Unecessary for the <em>create</em>, <em>link</em> and <em>link_public</em> operation<em>.</em></li><li>address: a blockchain-specific wallet address needed for the <em>link</em> and <em>create</em> operation, e.g., <code>did:pkh:eip155:1:wallet_address.</code></li><li>updated: time of the update</li></ul></li></ul></td><td>message</td></tr></tbody></table>

## Update the DID

<table><thead><tr><th width="255">Name</th><th width="308.3333333333333">Parameters Description</th><th>Response</th></tr></thead><tbody><tr><td><code>updateDID(DID, data)</code></td><td><ul><li><code>DID</code>: DID string</li><li><p><code>data</code>:</p><ul><li>ids: the DID ids.</li><li>address: a blockchain-specific wallet address needed for the <em>link</em> and <em>create</em> operation, e.g., <code>did:pkh:eip155:1:wallet_address.</code></li></ul></li></ul></td><td><ul><li>updated：updated time</li><li>message: message to be signed</li><li>DID: user DID (new one if none existed)</li></ul></td></tr></tbody></table>

## Resolve DID

| Name              | Parameters Description | Response |
| ----------------- | ---------------------- | -------- |
| `resolveDID(DID)` | `DID`: DID string      | N/A      |

## Get DID login information

| Name               | Parameters Description | Response                                                                                                                      |
| ------------------ | ---------------------- | ----------------------------------------------------------------------------------------------------------------------------- |
| `preDIDLogin(DID)` | `DID`: DID string      | <ul><li>DID: user DID (new one if none existed)</li><li>message: message to be signed</li><li>updated: updated time</li></ul> |

## DID Login

<table><thead><tr><th width="194.33333333333331">Name</th><th width="340">Parameters Description</th><th>Response</th></tr></thead><tbody><tr><td><code>DIDLogin(data)</code></td><td><p><code>data</code>: </p><ul><li>type: type of login, default set to  <code>m.login.did.identity</code></li><li>updated: the updated time returned by <code>preDiDLogin(did)</code></li><li>device_id: device id (omit this field for a new device)</li><li><p>identifier: login information</p><ul><li>DID: user DID</li><li>token: sign the message returned by <code>preDiDLogin(did)</code> with<code>etherum.Sign(accounts.TextHash(message), privateKey)</code> or<code>personal_sign</code> from <em>metamask</em>, then perform a <em>base16</em> encoding<em>.</em></li></ul></li></ul></td><td><ul><li>access_token: the access token</li><li>user_id: user id</li><li>device_id: device id</li></ul></td></tr></tbody></table>
