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
}
Next, obtain the did_innerpuz
(puzhash
):
chia rpc wallet did_get_current_coin_info '{"wallet_id": 4}'
Response:
{
"did_amount": 1,
"did_innerpuz": "0xb83b62a297e44cb53878276e51db3daaf6b0a69ca8fdd4165c8c5bb1816289ea",
"did_parent": "0x7738c8bc6629a6ece9197280238fa2db9437a66d4dc09d8c7d8446956e91e905",
"my_did": "did:chia:1d2x5wnm4sl4j2ena8ka3fyv8x7tzc9v520gstd3zfdu4pf6c2yksk8th4u",
"success": true,
"wallet_id": 4
}
Next, obtain the Master public key
(pubkey
);
chia keys show
Response:
Showing all public keys derived from your master seed and private key:
Fingerprint: 3003259627
Master public key (m): af8024892a231de462ed7f70abfc1a49372be4d2c34b80f9b48f06093a1629f7a0734c001eb0dd3942aeaecb372b70d2
Farmer public key (m/12381/8444/0/0): 88305aa55e306dd25d433ce889b3c307f20076ce44429950fa507426197df27b5ce8cbd9df4ec166a3888d372c9ea91c
Pool public key (m/12381/8444/1/0): 85d02120064fe68236e2a274d8bc76100b2e8b632e454d4465db44b6dc9b6eabcdb66c9e44a04f3bed4a49fa45411886
First wallet address: txch13w2ytvchereqawqjp4r09mqjhwk7unvndew2a400jxtu7q5kr7csqy70f7
Finally, using the above values, output the attest data:
chia rpc wallet did_create_attest '{"wallet_id": 4, "coin_name": "0x44a3e90ab1f103d6a259aa3009bdb34e9b092dce9f320f96342368df6b0555c7", "pubkey": "af8024892a231de462ed7f70abfc1a49372be4d2c34b80f9b48f06093a1629f7a0734c001eb0dd3942aeaecb372b70d2", "puzhash": "0xb83b62a297e44cb53878276e51db3daaf6b0a69ca8fdd4165c8c5bb1816289ea"}'
Response:
{
"attest_data": "6a8d474f7587eb25667d3dbb14918737962c159453d105b6224b7950a758512d:0000000144a3e90ab1f103d6a259aa3009bdb34e9b092dce9f320f96342368df6b0555c77ffee04b4796a1442b18ddb41644acd8de703ac23771a7bb779ff08cbc97cf290000000000000000ff01ffff3cffa044a3e90ab1f103d6a259aa3009bdb34e9b092dce9f320f96342368df6b0555c780ffff31ffb0af8024892a231de462ed7f70abfc1a49372be4d2c34b80f9b48f06093a1629f7a0734c001eb0dd3942aeaecb372b70d2ffa0b83b62a297e44cb53878276e51db3daaf6b0a69ca8fdd4165c8c5bb1816289ea808080c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000:7738c8bc6629a6ece9197280238fa2db9437a66d4dc09d8c7d8446956e91e905:b83b62a297e44cb53878276e51db3daaf6b0a69ca8fdd4165c8c5bb1816289ea:1",
"info": [
"7738c8bc6629a6ece9197280238fa2db9437a66d4dc09d8c7d8446956e91e905",
"b83b62a297e44cb53878276e51db3daaf6b0a69ca8fdd4165c8c5bb1816289ea",
1
],
"message_spend_bundle": "0000000144a3e90ab1f103d6a259aa3009bdb34e9b092dce9f320f96342368df6b0555c77ffee04b4796a1442b18ddb41644acd8de703ac23771a7bb779ff08cbc97cf290000000000000000ff01ffff3cffa044a3e90ab1f103d6a259aa3009bdb34e9b092dce9f320f96342368df6b0555c780ffff31ffb0af8024892a231de462ed7f70abfc1a49372be4d2c34b80f9b48f06093a1629f7a0734c001eb0dd3942aeaecb372b70d2ffa0b83b62a297e44cb53878276e51db3daaf6b0a69ca8fdd4165c8c5bb1816289ea808080c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"success": true
}
The attest_data
value can then be directed to a text file, which can later be used for recovery with the did_recovery_spend
RPC. For example:
echo "6a8d474f7587eb25667d3dbb14918737962c159453d105b6224b7950a758512d:0000000144a3e90ab1f103d6a259aa3009bdb34e9b092dce9f320f96342368df6b0555c77ffee04b4796a1442b18ddb41644acd8de703ac23771a7bb779ff08cbc97cf290000000000000000ff01ffff3cffa044a3e90ab1f103d6a259aa3009bdb34e9b092dce9f320f96342368df6b0555c780ffff31ffb0af8024892a231de462ed7f70abfc1a49372be4d2c34b80f9b48f06093a1629f7a0734c001eb0dd3942aeaecb372b70d2ffa0b83b62a297e44cb53878276e51db3daaf6b0a69ca8fdd4165c8c5bb1816289ea808080c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000:7738c8bc6629a6ece9197280238fa2db9437a66d4dc09d8c7d8446956e91e905:b83b62a297e44cb53878276e51db3daaf6b0a69ca8fdd4165c8c5bb1816289ea:1" > attest1
did_create_backup_file
Functionality: Output the backup data of a DID wallet's metadata. This output can then be saved or redirected to a file
Usage: chia rpc wallet [OPTIONS] did_create_backup_file [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 of the DID wallet from which to obtain the coin info |
Example
chia rpc wallet did_create_backup_file '{"wallet_id": 3}' > wallet2.bak
more wallet2.bak
Response:
{
"backup_data": "9818b416c60ad3052ff3a8dd702a6f32fc21cbd1bd3712583c331452505bba02:eff07522495060c066f66f32acc2a77e3a3e737aca8baea4d1a64ea4cdc13da9:1:6a8d474f7587eb25667d3dbb14918737962c159453d105b6224b7950a758512d,443a397fe5f8db5b38cd47eea3e2538fe7ae7bed48a1d858a87556118b1953d9:ff02ffff01ff02ffff01ff02ffff03ff81bfffff01ff02ff05ff82017f80ffff01ff02ffff03ffff22ffff09ffff02ff7effff04ff02ffff04ff8217ffff80808080ff0b80ffff15ff17ff808080ffff01ff04ffff04ff28ffff04ff82017fff808080ffff04ffff04ff34ffff04ff8202ffffff04ff82017fffff04ffff04ff8202ffff8080ff8080808080ffff04ffff04ff38ffff04ff822fffff808080ffff02ff26ffff04ff02ffff04ff2fffff04ff17ffff04ff8217ffffff04ff822fffffff04ff8202ffffff04ff8205ffffff04ff820bffffff01ff8080808080808080808080808080ffff01ff088080ff018080ff0180ffff04ffff01ffffffff313dff4946ffff0233ff3c04ffffff0101ff02ff02ffff03ff05ffff01ff02ff3affff04ff02ffff04ff0dffff04ffff0bff2affff0bff22ff3c80ffff0bff2affff0bff2affff0bff22ff3280ff0980ffff0bff2aff0bffff0bff22ff8080808080ff8080808080ffff010b80ff0180ffffff02ffff03ff17ffff01ff02ffff03ff82013fffff01ff04ffff04ff30ffff04ffff0bffff0bffff02ff36ffff04ff02ffff04ff05ffff04ff27ffff04ff82023fffff04ff82053fffff04ff820b3fff8080808080808080ffff02ff7effff04ff02ffff04ffff02ff2effff04ff02ffff04ff2fffff04ff5fffff04ff82017fff808080808080ff8080808080ff2f80ff808080ffff02ff26ffff04ff02ffff04ff05ffff04ff0bffff04ff37ffff04ff2fffff04ff5fffff04ff8201bfffff04ff82017fffff04ffff10ff8202ffffff010180ff808080808080808080808080ffff01ff02ff26ffff04ff02ffff04ff05ffff04ff37ffff04ff2fffff04ff5fffff04ff8201bfffff04ff82017fffff04ff8202ffff8080808080808080808080ff0180ffff01ff02ffff03ffff15ff8202ffffff11ff0bffff01018080ffff01ff04ffff04ff20ffff04ff82017fffff04ff5fff80808080ff8080ffff01ff088080ff018080ff0180ff0bff17ffff02ff5effff04ff02ffff04ff09ffff04ff2fffff04ffff02ff7effff04ff02ffff04ffff04ff09ffff04ff0bff1d8080ff80808080ff808080808080ff5f80ffff04ffff0101ffff04ffff04ff2cffff04ff05ff808080ffff04ffff04ff20ffff04ff17ffff04ff0bff80808080ff80808080ffff0bff2affff0bff22ff2480ffff0bff2affff0bff2affff0bff22ff3280ff0580ffff0bff2affff02ff3affff04ff02ffff04ff07ffff04ffff0bff22ff2280ff8080808080ffff0bff22ff8080808080ff02ffff03ffff07ff0580ffff01ff0bffff0102ffff02ff7effff04ff02ffff04ff09ff80808080ffff02ff7effff04ff02ffff04ff0dff8080808080ffff01ff0bffff0101ff058080ff0180ff018080ffff04ffff01ff02ffff01ff02ffff01ff02ffff03ff0bffff01ff02ffff03ffff09ff05ffff1dff0bffff1effff0bff0bffff02ff06ffff04ff02ffff04ff17ff8080808080808080ffff01ff02ff17ff2f80ffff01ff088080ff0180ffff01ff04ffff04ff04ffff04ff05ffff04ffff02ff06ffff04ff02ffff04ff17ff80808080ff80808080ffff02ff17ff2f808080ff0180ffff04ffff01ff32ff02ffff03ffff07ff0580ffff01ff0bffff0102ffff02ff06ffff04ff02ffff04ff09ff80808080ffff02ff06ffff04ff02ffff04ff0dff8080808080ffff01ff0bffff0101ff058080ff0180ff018080ffff04ffff01b0840620390879eecb831216e9d19dbab041c62075a4dede87ce15b6ae93e1c3e413e00533bd20811ae4d6d148d285c4d2ff018080ffff04ffff01a06e904ff8aa967cac220193d5b0745d0475e844db8bbbf88daa94f0e7f3d1d0f3ffff04ffff0102ffff04ffff01ffa0f1e8350cec62f8204aaf867cc3c12cae369f619258206616108c6cfd7be760b3ffa0f41209fefd72794b52620c74cd7b87a008bb87dde6f6b3a6b0929711b7a85119a0eff07522495060c066f66f32acc2a77e3a3e737aca8baea4d1a64ea4cdc13da9ffff04ffff0180ff01808080808080:2:{}",
"success": true,
"wallet_id": 3
}
did_find_lost_did
Functionality: Recover a missing or unspendable DID wallet by submitting a coin id of the DID
Usage: chia rpc wallet [OPTIONS] did_find_lost_did [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 | Type | Required | Description |
---|---|---|---|
coin_id | STRING | True | The DID ID, launcher ID, or latest coin ID of the DID you want to recover. The most time-efficient of these is the latest coin ID |
recovery_list_hash | STRING | False | Override the recovery list hash of the DID. Only set this if your last DID spend updated the recovery list |
num_verification | NUMBER | False | Override the required verification number of the DID. Only set this if your last DID spend updated the required verification number |
metadata | STRING | False | The new whole metadata in json format |
Example 1
If the DID belongs to the current wallet, the command should succeed:
chia rpc wallet did_find_lost_did '{"coin_id": "did:chia:1cxw5dqug4gavvgylx88zfkmqv235ryr6j9tvyjwwuga0pa52wjvqavdyar"}'
Response:
{
"latest_coin_id": "fa6a754142a557b0bf3ce5122f0146b5d7d996aadd521cf63b97f49a0e998c53",
"success": true
}
Example 2
If the DID does not belong to this wallet, the command will fail:
chia rpc wallet did_find_lost_did '{"coin_id": "fa6a754142a557b0bf3ce5122f0146b5d7d996aadd521cf63b97f49a0e998c53"}'
Response:
Request failed: {'error': 'This DID c19d468388aa3ac6209f31ce24db6062a341907a9156c249cee23af0f68a7498 is not belong to the connected wallet', 'success': False}
did_get_current_coin_info
Functionality: Get the current coin info (parent coin, puzzle hash, amount) for a DID wallet
Usage: chia rpc wallet [OPTIONS] did_get_current_coin_info [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 of the DID wallet from which to obtain the coin info |
Example
chia rpc wallet did_get_current_coin_info '{"wallet_id": 3}'