DID RPC
Note about Windows command escaping
This document will use Linux/MacOS RPC syntax. When running rpc commands on Windows, you'll need to escape all quotes with backslashes.
For example, here is a typical RPC command on Linux and MacOS:
chia rpc wallet create_new_wallet '{"wallet_type": "nft_wallet"}'
To run the same command on Windows, you need to escape the quotes, so it looks like this (the braces have been removed to support the formatting for this page. You still need to use them in your actual commands.):
chia rpc wallet create_new_wallet '\"wallet_type\": \"nft_wallet\"'
Reference
create_new_wallet
Functionality: Create a new DID wallet (From the Chia wallet RPC endpoint)
Usage: chia rpc wallet [OPTIONS] create_new_wallet [REQUEST]
Note: This is part of the wallet RPC API. It is included here to document the only way in which to create a new DID with an RPC. Because backup_dids
is required, you must already have access to a DID in order to run this RPC. If you do not already have a DID, then run the CLI command to create a DID wallet instead.
Options:
Short Command | Long Command | Type | Required | Description |
---|---|---|---|---|
-j | --json-file | TEXT | False | Instead of REQUEST, provide a json file containing the request data |
-h | --help | None | False | Show a help message and exit |
Request Parameters:
Parameter | Required | Description |
---|---|---|
wallet_type | True | This must be set to did_wallet in order to create a DID wallet |
did_type | True | Set this to new to create a new DID |
amount | True | Number of mojos to add to the DID initially. Minimum value is 1 |
backup_dids | True | A list of DIDs to be used for recovery. Must match actual DIDs |
num_of_backup_ids_needed | True | The number of backup DIDs required for recovery. Minimum value is 1 , maximum value is the number of DIDs in backup_dids |
fee | False | An optional blockchain fee, in mojos |
Example
chia rpc wallet create_new_wallet '{"wallet_type": "did_wallet", "did_type": "new", "amount": 1, "backup_dids": ["did:chia:13p5fdxgm8e2pngdwp8m088t0etp7rgzx9ye2ju8v5ackcyg7t9nqx2um83"], "num_of_backup_ids_needed": 1, "fee": 10000000}'
Response:
{
"my_did": "did:chia:1pzrm9dyhvu8hmqyzqmy0v3wyp7cn98jlxk49jv7mgkhvk229erhqmh6c2m",
"success": true,
"type": 8,
"wallet_id": 2
}
Show the newly created DID wallet:
chia wallet show
Response:
Wallet height: 1144662
Sync status: Synced
Balances, fingerprint: 455254876
Chia Wallet:
-Total Balance: 0.999999999999 txch (999999999999 mojo)
-Pending Total Balance: 0.999999999999 txch (999999999999 mojo)
-Spendable: 0.999999999999 txch (999999999999 mojo)
-Type: STANDARD_WALLET
-Wallet ID: 1
Profile 1:
-Total Balance: 1.0
-Pending Total Balance: 1.0
-Spendable: 1.0
-Type: DECENTRALIZED_ID
-DID ID: did:chia:1pzrm9dyhvu8hmqyzqmy0v3wyp7cn98jlxk49jv7mgkhvk229erhqmh6c2m
-Wallet ID: 2
did_create_attest
Functionality: Create an attest for a DID, to be used for recovery. This command will output the attest data, which can then be added or redirected to a file
Usage: chia rpc wallet [OPTIONS] did_create_attest [REQUEST]
Options:
Short Command | Long Command | Type | Required | Description |
---|---|---|---|---|
-j | --json-file | TEXT | False | Instead of REQUEST, provide a json file containing the request data |
-h | --help | None | False | Show a help message and exit |
Request Parameters:
Parameter | Required | Description |
---|---|---|
wallet_id | True | The Wallet ID for which to create the attest |
coin_name | True | The coin to use for the attest |
pubkey | True | The public key to use for the attest |
puzhash | True | The puzzle hash to use for the attest |
Example
For this example, we'll use a pre-existing DID. First, obtain the coin_id
(coin_name
):
chia rpc wallet did_get_did '{"wallet_id": 4}'
Response:
{
"coin_id": "0x44a3e90ab1f103d6a259aa3009bdb34e9b092dce9f320f96342368df6b0555c7",
"my_did": "did:chia:1d2x5wnm4sl4j2ena8ka3fyv8x7tzc9v520gstd3zfdu4pf6c2yksk8th4u",
"success": true,
"wallet_id": 4
}