### Install Keystore Demo Plugin in CKB-CLI Source: https://github.com/nervosnetwork/ckb-cli/blob/develop/docs/Plugin.md Steps to start the ckb-cli and install the compiled keystore demo plugin by specifying its binary path. Shows the expected output upon successful installation. ```shell ./target/debug/ckb-cli CKB> plugin install --binary-path ./target/debug/examples/keystore daemon: true description: "It's a keystore for demo" name: demo_keystore ``` -------------------------------- ### Start ckb-cli API Server Source: https://github.com/nervosnetwork/ckb-cli/blob/develop/docs/API-Server.md This snippet shows how to start the ckb-cli API server, including options for specifying the listening address, providing a private key path for advanced functionalities, and ensuring index-store synchronization before execution. ```bash ckb-cli server --help Start advanced API server USAGE: ckb-cli server [FLAGS] [OPTIONS] --listen FLAGS: --wait-for-sync Ensure the index-store synchronizes completely before command being executed OPTIONS: --listen Rpc server listen address (when --privkey-path is given ip MUST be 127.0.0.1) [default: 127.0.0.1:3000] --privkey-path Private key file path (only read first line) ``` -------------------------------- ### Example Master Private Key Response Source: https://github.com/nervosnetwork/ckb-cli/blob/develop/docs/Plugin.md An example JSON response showing the structure for a master private key and chain code, typically returned after a key generation or retrieval operation. ```javascript { "result": { "type": "master_private_key", "content": { "privkey": "0x0303030303030303030303030303030303030303030303030303030303030303", "chain_code": "0x0404040404040404040404040404040404040404040404040404040404040404" } }, "id": 0, "jsonrpc": "2.0" } ``` -------------------------------- ### Build CKB-CLI and Keystore Demo Plugin Source: https://github.com/nervosnetwork/ckb-cli/blob/develop/docs/Plugin.md Instructions for compiling the ckb-cli tool and the example keystore plugin from source using `cargo build`. ```shell # Build ckb-cli cargo build # Build example keystore plugin cd plugin-protocol cargo build --examples ``` -------------------------------- ### Example: Call get_capacity_by_address API via cURL Source: https://github.com/nervosnetwork/ckb-cli/blob/develop/docs/API-Server.md This example demonstrates how to call the `get_capacity_by_address` API method using cURL, sending a JSON RPC request to query the capacity for a specific address. ```bash echo '{ "id": 2, "jsonrpc": "2.0", "method": "get_capacity_by_address", "params": ["ckt1qyqdfjzl8ju2vfwjtl4mttx6me09hayzfldq8m3a0y"] }' \ | tr -d '\n' \ | curl -H 'content-type: application/json' -d @- \ http://localhost:3000 ``` -------------------------------- ### Display Detailed Information of Installed CKB-CLI Plugin Source: https://github.com/nervosnetwork/ckb-cli/blob/develop/docs/Plugin.md Command to retrieve and display metadata about an installed plugin, such as its daemon status, description, active status, name, and assigned roles. ```shell CKB> plugin info --name demo_keystore daemon: true description: "It's a keystore for demo" is_active: true name: demo_keystore roles: - require_password: true role: key_store ``` -------------------------------- ### Example: Call transfer API via cURL Source: https://github.com/nervosnetwork/ckb-cli/blob/develop/docs/API-Server.md This example demonstrates how to invoke the `transfer` API method using cURL, sending a JSON RPC request to transfer a specified capacity to a target address with a given fee rate. ```bash echo '{ "id": 2, "jsonrpc": "2.0", "method": "transfer", "params": [{ "capacity": 200000000000, "fee_rate": 1000, "to_address": "ckt1qyqdfjzl8ju2vfwjtl4mttx6me09hayzfldq8m3a0y", "from_locked_address": null, "to_data": null }] }' \ | tr -d '\n' \ | curl -H 'content-type: application/json' -d @- \ http://localhost:3000 ``` -------------------------------- ### Example: Call get_capacity_by_lock_hash API via cURL Source: https://github.com/nervosnetwork/ckb-cli/blob/develop/docs/API-Server.md This example demonstrates how to call the `get_capacity_by_lock_hash` API method using cURL, sending a JSON RPC request to query the capacity for a specific lock hash. ```bash echo '{ "id": 2, "jsonrpc": "2.0", "method": "get_capacity_by_lock_hash", "params": ["0x951f5af7606e2905a556a2774b99de803f0dac47e06129ecd3d4c42243b290ed"] }' \ | tr -d '\n' \ | curl -H 'content-type: application/json' -d @- \ http://localhost:3000 ``` -------------------------------- ### Example: get_capacity_by_address API Response Source: https://github.com/nervosnetwork/ckb-cli/blob/develop/docs/API-Server.md This JSON snippet shows a typical successful response from the `get_capacity_by_address` API method, detailing the total, DAO, and immature capacity for the queried address. ```json { "jsonrpc": "2.0", "result": { "dao": 0, "immature": 0, "total": 3000000009000 }, "id": 2 } ``` -------------------------------- ### Example: get_capacity_by_lock_hash API Response Source: https://github.com/nervosnetwork/ckb-cli/blob/develop/docs/API-Server.md This JSON snippet shows a typical successful response from the `get_capacity_by_lock_hash` API method, detailing the total, DAO, and immature capacity for the queried lock hash. ```json { "jsonrpc": "2.0", "result": { "dao": 0, "immature": 0, "total": 3000000009000 }, "id": 2 } ``` -------------------------------- ### Start CKB-CLI Interactive Mode Source: https://github.com/nervosnetwork/ckb-cli/blob/develop/README.md This command launches the ckb-cli in its interactive mode, providing a prompt for executing various CKB commands directly. ```shell ckb-cli ``` -------------------------------- ### Sign Message with Recoverable Signature via CKB-CLI Keystore Plugin Source: https://github.com/nervosnetwork/ckb-cli/blob/develop/docs/Plugin.md Demonstrates how to use the installed keystore plugin to sign a hexadecimal message with a recoverable signature, requiring a password for the account. ```shell CKB> util sign-message --from-account 0xb39bbc0b3673c7d36450bc14cfcdad2d559c6c64 --message 0xe203d8260a0eb9d0ec8f69976e2108d9e50d0c8fb1920a67d10d61cb9993e284 --recoverable Password: *** recoverable: true signature: 0x0101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101 ``` -------------------------------- ### Example: transfer API Response Source: https://github.com/nervosnetwork/ckb-cli/blob/develop/docs/API-Server.md This JSON snippet illustrates a typical successful response from the `transfer` API method, providing the transaction hash in the `result` field upon completion. ```json { "jsonrpc": "2.0", "result": "0x14afd2df9bf130962f3d30e17fb68fbab91fbf93189240a77fdc633dc39e6d5a", "id": 2 } ``` -------------------------------- ### Example JSON RPC Response for Live Cells Query Source: https://github.com/nervosnetwork/ckb-cli/blob/develop/docs/API-Server.md This JSON snippet illustrates the expected response structure from a CKB node when querying live cells. It includes details such as the total current capacity, count of live cells, and an array of individual live cell information, including capacity, transaction details, and lock hash. ```json { "jsonrpc": "2.0", "result": { "current_capacity": 2200000009000, "current_count": 2, "live_cells": [ { "info": { "capacity": 2000000009000, "data_bytes": 0, "index": { "output_index": 1, "tx_index": 1 }, "lock_hash": "0x951f5af7606e2905a556a2774b99de803f0dac47e06129ecd3d4c42243b290ed", "number": 62800, "tx_hash": "0xd3f1df20a4b87c01d77b0ab9877c9270c512ce3e9a4443deb0eb685112fc24e5", "output_index": 1, "type_hashes": null }, "mature": true }, { "info": { "capacity": 200000000000, "data_bytes": 0, "index": { "output_index": 0, "tx_index": 1 }, "lock_hash": "0x951f5af7606e2905a556a2774b99de803f0dac47e06129ecd3d4c42243b290ed", "number": 86682, "tx_hash": "0x962562e730cbab29fcfed8c2aff9da8936f669c2236957107da12c357d6847af", "output_index": 0, "type_hashes": null }, "mature": true } ] }, "id": 2 } ``` -------------------------------- ### API Method: get_live_cells_by_type_hash Source: https://github.com/nervosnetwork/ckb-cli/blob/develop/docs/API-Server.md This API method retrieves live cells associated with a specific type script hash. Its parameters and usage examples are similar to those for `get_live_cells_by_address`. ```APIDOC Method: get_live_cells_by_type_hash Description: Get live cells by type script hash Parameters: Similar to get_live_cells_by_address See: ckb-cli wallet get-live-cells --help ``` -------------------------------- ### Deactivate Keystore Demo Plugin in CKB-CLI Source: https://github.com/nervosnetwork/ckb-cli/blob/develop/docs/Plugin.md Instructions to deactivate an installed plugin in ckb-cli and verify its deactivation by attempting an operation that requires the plugin, which should then fail. ```shell CKB> plugin deactive --name demo_keystore Plugin demo_keystore is deactived! CKB> util sign-message --from-account 0xb39bbc0b3673c7d36450bc14cfcdad2d559c6c64 --message 0xe203d8260a0eb9d0ec8f69976e2108d9e50d0c8fb1920a67d10d61cb9993e284 --recoverable Password: *** Account not found: b39bbc0b3673c7d36450bc14cfcdad2d559c6c64 ``` -------------------------------- ### API Method: transfer Source: https://github.com/nervosnetwork/ckb-cli/blob/develop/docs/API-Server.md Documentation for the `transfer` API method, which facilitates transferring capacity to a specified address. This method is enabled when the server is started with a private key path and accepts a single `TransferArgs` object as its parameter. ```APIDOC transfer Transfer capacity to an address. Enabled when start server with --privkey-path** argument. Attention: capacity unit are Shannon. Parameters: transfer_args - A JSON object of type TransferArgs TransferArgs fields: capacity - The capacity (unit: Shannon) fee_rate - The transaction fee rate (unit: shannons/KB) to_address - Target address from_locked_address - (optional) The time locked multisig address to search live cells to_data - (optional) Hex data store in target cell ``` -------------------------------- ### API Method: get_live_cells_by_lock_hash Source: https://github.com/nervosnetwork/ckb-cli/blob/develop/docs/API-Server.md This API method retrieves live cells associated with a specific lock script hash. Its parameters and usage examples are similar to those for `get_live_cells_by_address`. ```APIDOC Method: get_live_cells_by_lock_hash Description: Get live cells by lock script hash Parameters: Similar to get_live_cells_by_address See: ckb-cli wallet get-live-cells --help ``` -------------------------------- ### Retrieve Derived Key Set by Path Index using CKB-CLI Keystore API Source: https://github.com/nervosnetwork/ckb-cli/blob/develop/docs/Plugin.md Demonstrates how to request and interpret the response for deriving a set of keys (external and change) from a keystore using a given account identifier, start indices, and lengths. An optional password can be provided for decryption. ```javascript { "params": [ // The blake160 hash of the public key (account identifier) "0xb39bbc0b3673c7d36450bc14cfcdad2d559c6c64", // The external path start index, include the starting index (template: "m/44'/309'/0'/0/{index}") 0, // The length of external derived key 20, // The change path start index, include the starting index (template: "m/44'/309'/0'/1/{index}") 0, // The length of change derived key 10, // (optional) The password to decrypt the account "123" ], "method": "keystore_derived_key_set_by_index", "id": 0, "jsonrpc": "2.0" } ``` ```javascript { "result": { "type": "derived_key_set", "content": { "external": [ [ "m/44'/309'/0'/0/19", "0x13e41d6f9292555916f17b4882a5477c01270142" ], [ "m/44'/309'/0'/0/20", "0xb39bbc0b3673c7d36450bc14cfcdad2d559c6c64" ] ], "change": [ [ "m/44'/309'/0'/1/19", "0x13e41d6f9292555916f17b4882a5477c01270142" ], [ "m/44'/309'/0'/1/20", "0xb39bbc0b3673c7d36450bc14cfcdad2d559c6c64" ] ] } }, "id": 0, "jsonrpc": "2.0" } ``` -------------------------------- ### API Method: get_live_cells_by_code_hash Source: https://github.com/nervosnetwork/ckb-cli/blob/develop/docs/API-Server.md This API method retrieves live cells associated with a specific type script's code hash. Its parameters and usage examples are similar to those for `get_live_cells_by_address`. ```APIDOC Method: get_live_cells_by_code_hash Description: Get live cells by type script's code hash Parameters: Similar to get_live_cells_by_address See: ckb-cli wallet get-live-cells --help ``` -------------------------------- ### RPC Protocol: Get Plugin Configuration Source: https://github.com/nervosnetwork/ckb-cli/blob/develop/docs/Plugin.md Describes the `get_config` RPC method used by CKB-CLI to retrieve a plugin's configuration. This method returns details like the plugin's name, description, daemon status, and supported roles, allowing ckb-cli to understand and manage the plugin. ```APIDOC Request: { "params": [], "method": "get_config", "id": 0, "jsonrpc": "2.0" } Response: { "result": { "type": "plugin_config", "content": { "roles": [ { "role": "key_store", "require_password": true } ], "name": "demo_keystore", "description": "It's a keystore for demo", "daemon": true } }, "id": 0, "jsonrpc": "2.0" } ``` -------------------------------- ### Get Derived Key Set for HD Wallet Cell Collection (keystore_derived_key_set) Source: https://github.com/nervosnetwork/ckb-cli/blob/develop/docs/Plugin.md Shows how to retrieve a set of derived keys for HD wallet cell collection using the `keystore_derived_key_set` method. Parameters include the account identifier, maximum external keys to search, the last used change address, and maximum change keys to search, with an optional password. ```javascript { "params": [ // The blake160 hash of the public key (account identifier) "0xe8b7cfc565396a49efe154e81fe02c2bca9f3621", // Maximum external keys to search 100, // The last change address been used (for know the next change address) "0xe8b7cfc565396a49efe154e81fe02c2bca9f3621", // Maximum change keys to search 10000, // (optional) The password to decrypt the account "123" ], "method": "keystore_derived_key_set", "id": 0, "jsonrpc": "2.0" } ``` -------------------------------- ### Display CKB-CLI Help Documentation Source: https://github.com/nervosnetwork/ckb-cli/blob/develop/README.md These commands show the available options and sub-commands for ckb-cli. The first command displays top-level help, while the second provides specific help for RPC commands. ```shell # Top level help doc ckb-cli --help # RPC help doc ckb-cli rpc --help ``` -------------------------------- ### RPC Protocol: Keystore Create Account Source: https://github.com/nervosnetwork/ckb-cli/blob/develop/docs/Plugin.md Explains the `keystore_create_account` RPC method for creating a new account within a keystore plugin. It optionally accepts a password to encrypt the new account and returns the H160 hash of the newly created account upon successful creation. ```APIDOC Request: { "params": [ // (optional) The password to encrypt the account "123" ], "method": "keystore_create_account", "id": 0, "jsonrpc": "2.0" } Response: { "result": { "type": "h160", "content": "0xb39bbc0b3673c7d36450bc14cfcdad2d559c6c64" }, "id": 0, "jsonrpc": "2.0" } ``` -------------------------------- ### Build CKB-CLI Project with Cargo Source: https://github.com/nervosnetwork/ckb-cli/blob/develop/README.md This snippet provides instructions to clone the ckb-cli repository and build the project using Cargo. It ensures all dependencies are locked for a consistent build process. ```shell git clone https://github.com/nervosnetwork/ckb-cli.git cd ckb-cli cargo install --path . -f --locked ``` -------------------------------- ### RPC Protocol: Keystore List Accounts Source: https://github.com/nervosnetwork/ckb-cli/blob/develop/docs/Plugin.md Details the `keystore_list_account` RPC method, which allows listing all accounts managed by a keystore plugin. It returns a vector of H160 hashes representing the account identifiers, providing an overview of available accounts. ```APIDOC Request: { "params": [], "method": "keystore_list_account", "id": 0, "jsonrpc": "2.0" } Response: { "result": { "type": "h160_vec", "content": [ "0xe22f7f385830a75e50ab7fc5fd4c35b134f1e84b", "0x13e41d6f9292555916f17b4882a5477c01270142", "0xb39bbc0b3673c7d36450bc14cfcdad2d559c6c64" ] }, "id": 0, "jsonrpc": "2.0" } ``` -------------------------------- ### Sign a Message with CKB-CLI Keystore (keystore_sign) Source: https://github.com/nervosnetwork/ckb-cli/blob/develop/docs/Plugin.md Demonstrates how to sign a message or transaction using the `keystore_sign` method. This operation requires the account identifier, a derivation key path, the message to sign (H256), and optionally a transaction object and password. ```javascript { "params": [ // The blake160 hash of the public key (account identifier) "0xb39bbc0b3673c7d36450bc14cfcdad2d559c6c64", // A derivation key path ("m" for master key) "m/44'/309'/0'/0/19", // The message to sign (H256) "0xe203d8260a0eb9d0ec8f69976e2108d9e50d0c8fb1920a67d10d61cb9993e284", // The sign target, a transaction or any message { "type": "transaction", "content": { "version": "0x0", "cell_deps": [ { "out_point": { "tx_hash": "0xd6ae21528966b5926a95b5dfa75281e91f071af492ba7879aff29d671c7bb523", "index": "0x0" }, "dep_type": "dep_group" } ], "header_deps": [], "inputs": [ { "since": "0x0", "previous_output": { "tx_hash": "0xb79cc8daf20601d5cefda345951e21390fc5e2c6dab33c7a39207f64fb947731", "index": "0x7" } } ], "outputs": [ { "capacity": "0x174876e800", "lock": { "code_hash": "0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8", "hash_type": "type", "args": "0xb39bbc0b3673c7d36450bc14cfcdad2d559c6c64" }, "type": null }, { "capacity": "0x1bc16d5005b88180", "lock": { "code_hash": "0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8", "hash_type": "type", "args": "0xc8328aabcd9b9e8e64fbc566c4385c3bdeb219d7" }, "type": null } ], "outputs_data": [ "0x", "0x" ], "witnesses": [] } }, // Sign use recoverable signature true, // (optional) The password to decrypt the account "123" ], "method": "keystore_sign", "id": 0, "jsonrpc": "2.0" } ``` ```javascript { "result": { "type": "bytes", "content": "0x0101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101" }, "id": 0, "jsonrpc": "2.0" } ``` -------------------------------- ### Enable Debug Logging for CKB-CLI Plugins Source: https://github.com/nervosnetwork/ckb-cli/blob/develop/docs/Plugin.md Command to launch ckb-cli with detailed debug log messages specifically for the plugin module, useful for troubleshooting. ```shell RUST_LOG=ckb_cli::plugin=debug ./target/debug/ckb-cli ``` -------------------------------- ### Define CKB-CLI Plugin Roles in Rust Source: https://github.com/nervosnetwork/ckb-cli/blob/develop/docs/Plugin.md Defines the different roles a CKB-CLI plugin can assume, such as KeyStore, Indexer, SubCommand, and Callback. Each role specifies its unique configuration or purpose within the CKB-CLI ecosystem, enabling flexible plugin integration. ```Rust pub enum PluginRole { // The argument is for if keystore need password KeyStore { require_password: bool }, Indexer, // The argument is for where the sub-command is injected to. SubCommand { name: String }, // The argument is for the callback function name Callback { name: CallbackName }, } ``` -------------------------------- ### RPC Protocol: Keystore Import Account Source: https://github.com/nervosnetwork/ckb-cli/blob/develop/docs/Plugin.md Describes the `keystore_import` RPC method for importing an account into a keystore plugin. It requires the secp256k1 key and chain code of the master private key, with an optional password for encryption during the import process. ```APIDOC Request: { "params": [ // The secp256k1 key of master private key "0x0303030303030303030303030303030303030303030303030303030303030303", // The chain code of master private key "0x0404040404040404040404040404040404040404040404040404040404040404", // (optional) The password to encrypt the account "123" ], "method": "keystore_import", "id": 0, "jsonrpc": "2.0" } ``` -------------------------------- ### API Method: get_capacity_by_address Source: https://github.com/nervosnetwork/ckb-cli/blob/develop/docs/API-Server.md Documentation for the `get_capacity_by_address` API method, used to retrieve the total, DAO, and immature capacity associated with a given address. ```APIDOC get_capacity_by_address Get capacity by address Parameters: address - Target address ``` -------------------------------- ### API Method: get_capacity_by_lock_hash Source: https://github.com/nervosnetwork/ckb-cli/blob/develop/docs/API-Server.md Documentation for the `get_capacity_by_lock_hash` API method, used to retrieve the total, DAO, and immature capacity associated with a given lock script hash. ```APIDOC get_capacity_by_lock_hash Get capacity by lock script hash Parameters: lock_hash - Lock script hash ``` -------------------------------- ### Retrieve Extended Public Key (keystore_extended_pubkey) Source: https://github.com/nervosnetwork/ckb-cli/blob/develop/docs/Plugin.md Illustrates how to fetch the extended public key for a given account identifier and derivation path using the `keystore_extended_pubkey` method. An optional password can be provided for decryption. ```javascript { "params": [ // The blake160 hash of the public key (account identifier) "0xb39bbc0b3673c7d36450bc14cfcdad2d559c6c64", // A derivation key path ("m" for master key) "m/44'/309'/0'/0/19", // (optional) The password to decrypt the account "123" ], "method": "keystore_extended_pubkey", "id": 0, "jsonrpc": "2.0" } ``` ```javascript { "result": { "type": "bytes", "content": "0x02531fe6068134503d2723133227c867ac8fa6c83c537e9a44c3c5bdbdcb1fe337" }, "id": 0, "jsonrpc": "2.0" } ``` -------------------------------- ### Define CKB-CLI Plugin Configuration Structure in Rust Source: https://github.com/nervosnetwork/ckb-cli/blob/develop/docs/Plugin.md Defines the `PluginConfig` struct, which specifies the metadata for a CKB-CLI plugin. This includes its name, description, whether it's a daemon, and the list of roles it supports. This configuration is returned by the `get_config` RPC method. ```Rust struct PluginConfig { name: String, description: String, daemon: bool, roles: Vec, } ``` -------------------------------- ### RPC Protocol: Keystore Export Account Source: https://github.com/nervosnetwork/ckb-cli/blob/develop/docs/Plugin.md Documents the `keystore_export` RPC method for exporting an account from a keystore plugin. It requires the account identifier (blake160 hash) and an optional password for decryption, allowing secure retrieval of account data. ```APIDOC Request: { "params": [ // The blake160 hash of the public key (account identifier) "0xb39bbc0b3673c7d36450bc14cfcdad2d559c6c64", // (optional) The password to encrypt the account "123" ], "method": "keystore_export", "id": 0, "jsonrpc": "2.0" } ``` -------------------------------- ### Retrieve CKB Tip Header (YAML Output) Source: https://github.com/nervosnetwork/ckb-cli/blob/develop/README.md This command invokes the `get_tip_header` RPC method to retrieve the current tip header of the CKB blockchain. The output is formatted in YAML, providing detailed information about the latest block. ```shell ckb-cli rpc get_tip_header ``` ```yaml version: "0" parent_hash: 0xb379bf3d369fccadfa69fa2273a8f596489b69dab996ca02a3eb1ae4cf765ca3 timestamp: "1567775474688" number: "102" epoch: "0" transactions_root: 0xc4991d3e261c27a0ce7ea9801de5f0a5f56ffb82a29d7a6e8e7cf44dbb2db114 witnesses_root: 0x39116bc1a56f5ca82cf5226f172f97ff8a8d9626ca7e41d8cd92e76666e069f8 proposals_hash: 0x0000000000000000000000000000000000000000000000000000000000000000 difficulty: 0x4000000 extra_hash: 0x0000000000000000000000000000000000000000000000000000000000000000 uncles_count: "0" dao: 0x0100000000000000af9a31ce318a230000cc083d71c4350000d774f0356a0000 nonce: "1876243812404095811" hash: 0x0384ebc55b7cb56e51044743e05fb83a4edb7173524339c35df4c71fcdb ``` -------------------------------- ### API Method: get_live_cells_by_address Source: https://github.com/nervosnetwork/ckb-cli/blob/develop/docs/API-Server.md Documentation for the `get_live_cells_by_address` API method, used to retrieve live cells associated with a given address, with optional filtering by block number range and a limit on the number of cells returned. ```APIDOC get_live_cells_by_address Get live cells by address Parameters: address - Target address from - (optional) Search from block number (included) to - (optional) Search to block number (included) limit - Get live cells <= limit ``` -------------------------------- ### Query Live Cells by Address using cURL and RPC Source: https://github.com/nervosnetwork/ckb-cli/blob/develop/docs/API-Server.md This bash command demonstrates how to send a JSON RPC request to a CKB node using `curl` to retrieve live cells associated with a specific address. It pipes a JSON payload to `curl` for the `get_live_cells_by_address` method. ```bash echo '{ "id": 2, "jsonrpc": "2.0", "method": "get_live_cells_by_address", "params": ["ckt1qyqdfjzl8ju2vfwjtl4mttx6me09hayzfldq8m3a0y", null, null, 2] }' \ | tr -d '\n' \ | curl -H 'content-type: application/json' -d @- \ http://localhost:3000 ``` -------------------------------- ### Set CKB Node API URL Environment Variable Source: https://github.com/nervosnetwork/ckb-cli/blob/develop/README.md Before using ckb-cli, it's recommended to export the CKB node's API URL as an environment variable. This allows the CLI to connect to the specified node without requiring the URL in every command. ```shell export API_URL=http://127.0.0.1:8114 ``` -------------------------------- ### RPC Protocol: Keystore Update Account Password Source: https://github.com/nervosnetwork/ckb-cli/blob/develop/docs/Plugin.md Documents the `keystore_update_password` RPC method, used to change the password for an existing account in a keystore plugin. It requires the account identifier (blake160 hash), the current password, and the new password for the update. ```APIDOC Request: { "params": [ // The blake160 hash of the public key (account identifier) "0xb39bbc0b3673c7d36450bc14cfcdad2d559c6c64", // The password to decrypt the account "123", // The password to encrypt the account "123" ], "method": "keystore_update_password", "id": 0, "jsonrpc": "2.0" } Response: { "result": { "type": "ok" }, "id": 0, "jsonrpc": "2.0" } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.