TITLE: Set CKB Node API URL Environment Variable DESCRIPTION: 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. SOURCE: https://github.com/nervosnetwork/ckb-cli/blob/develop/README.md#_snippet_1 LANGUAGE: shell CODE: ``` export API_URL=http://127.0.0.1:8114 ``` ---------------------------------------- TITLE: Build CKB-CLI Project with Cargo DESCRIPTION: 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. SOURCE: https://github.com/nervosnetwork/ckb-cli/blob/develop/README.md#_snippet_0 LANGUAGE: shell CODE: ``` git clone https://github.com/nervosnetwork/ckb-cli.git cd ckb-cli cargo install --path . -f --locked ``` ---------------------------------------- TITLE: Start ckb-cli API Server DESCRIPTION: 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. SOURCE: https://github.com/nervosnetwork/ckb-cli/blob/develop/docs/API-Server.md#_snippet_0 LANGUAGE: bash CODE: ``` 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) ``` ---------------------------------------- TITLE: API Method: transfer DESCRIPTION: 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. SOURCE: https://github.com/nervosnetwork/ckb-cli/blob/develop/docs/API-Server.md#_snippet_1 LANGUAGE: APIDOC CODE: ``` 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 ``` ---------------------------------------- TITLE: Example: Call transfer API via cURL DESCRIPTION: 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. SOURCE: https://github.com/nervosnetwork/ckb-cli/blob/develop/docs/API-Server.md#_snippet_2 LANGUAGE: bash CODE: ``` 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 ``` ---------------------------------------- TITLE: Example: transfer API Response DESCRIPTION: This JSON snippet illustrates a typical successful response from the `transfer` API method, providing the transaction hash in the `result` field upon completion. SOURCE: https://github.com/nervosnetwork/ckb-cli/blob/develop/docs/API-Server.md#_snippet_3 LANGUAGE: json CODE: ``` { "jsonrpc": "2.0", "result": "0x14afd2df9bf130962f3d30e17fb68fbab91fbf93189240a77fdc633dc39e6d5a", "id": 2 } ``` ---------------------------------------- TITLE: Start CKB-CLI Interactive Mode DESCRIPTION: This command launches the ckb-cli in its interactive mode, providing a prompt for executing various CKB commands directly. SOURCE: https://github.com/nervosnetwork/ckb-cli/blob/develop/README.md#_snippet_2 LANGUAGE: shell CODE: ``` ckb-cli ``` ---------------------------------------- TITLE: Display CKB-CLI Help Documentation DESCRIPTION: 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. SOURCE: https://github.com/nervosnetwork/ckb-cli/blob/develop/README.md#_snippet_3 LANGUAGE: shell CODE: ``` # Top level help doc ckb-cli --help # RPC help doc ckb-cli rpc --help ``` ---------------------------------------- TITLE: Define CKB-CLI Plugin Configuration Structure in Rust DESCRIPTION: 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. SOURCE: https://github.com/nervosnetwork/ckb-cli/blob/develop/docs/Plugin.md#_snippet_1 LANGUAGE: Rust CODE: ``` struct PluginConfig { name: String, description: String, daemon: bool, roles: Vec, } ``` ---------------------------------------- TITLE: RPC Protocol: Get Plugin Configuration DESCRIPTION: 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. SOURCE: https://github.com/nervosnetwork/ckb-cli/blob/develop/docs/Plugin.md#_snippet_2 LANGUAGE: APIDOC CODE: ``` 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" } ``` ---------------------------------------- TITLE: Define CKB-CLI Plugin Roles in Rust DESCRIPTION: 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. SOURCE: https://github.com/nervosnetwork/ckb-cli/blob/develop/docs/Plugin.md#_snippet_0 LANGUAGE: Rust CODE: ``` 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 }, } ``` ---------------------------------------- TITLE: RPC Protocol: Keystore Create Account DESCRIPTION: 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. SOURCE: https://github.com/nervosnetwork/ckb-cli/blob/develop/docs/Plugin.md#_snippet_4 LANGUAGE: APIDOC CODE: ``` 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" } ``` ---------------------------------------- TITLE: RPC Protocol: Keystore List Accounts DESCRIPTION: 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. SOURCE: https://github.com/nervosnetwork/ckb-cli/blob/develop/docs/Plugin.md#_snippet_3 LANGUAGE: APIDOC CODE: ``` 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" } ``` ---------------------------------------- TITLE: RPC Protocol: Keystore Import Account DESCRIPTION: 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. SOURCE: https://github.com/nervosnetwork/ckb-cli/blob/develop/docs/Plugin.md#_snippet_6 LANGUAGE: APIDOC CODE: ``` 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" } ``` ---------------------------------------- TITLE: RPC Protocol: Keystore Update Account Password DESCRIPTION: 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. SOURCE: https://github.com/nervosnetwork/ckb-cli/blob/develop/docs/Plugin.md#_snippet_5 LANGUAGE: APIDOC CODE: ``` 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" } ``` ---------------------------------------- TITLE: Sign Message with Recoverable Signature via CKB-CLI Keystore Plugin DESCRIPTION: Demonstrates how to use the installed keystore plugin to sign a hexadecimal message with a recoverable signature, requiring a password for the account. SOURCE: https://github.com/nervosnetwork/ckb-cli/blob/develop/docs/Plugin.md#_snippet_17 LANGUAGE: shell CODE: ``` CKB> util sign-message --from-account 0xb39bbc0b3673c7d36450bc14cfcdad2d559c6c64 --message 0xe203d8260a0eb9d0ec8f69976e2108d9e50d0c8fb1920a67d10d61cb9993e284 --recoverable Password: *** recoverable: true signature: 0x0101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101 ``` ---------------------------------------- TITLE: Sign a Message with CKB-CLI Keystore (keystore_sign) DESCRIPTION: 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. SOURCE: https://github.com/nervosnetwork/ckb-cli/blob/develop/docs/Plugin.md#_snippet_9 LANGUAGE: javascript CODE: ``` { "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" } ``` LANGUAGE: javascript CODE: ``` { "result": { "type": "bytes", "content": "0x0101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101" }, "id": 0, "jsonrpc": "2.0" } ``` ---------------------------------------- TITLE: API Method: get_capacity_by_address DESCRIPTION: Documentation for the `get_capacity_by_address` API method, used to retrieve the total, DAO, and immature capacity associated with a given address. SOURCE: https://github.com/nervosnetwork/ckb-cli/blob/develop/docs/API-Server.md#_snippet_4 LANGUAGE: APIDOC CODE: ``` get_capacity_by_address Get capacity by address Parameters: address - Target address ``` ---------------------------------------- TITLE: Example: Call get_capacity_by_address API via cURL DESCRIPTION: 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. SOURCE: https://github.com/nervosnetwork/ckb-cli/blob/develop/docs/API-Server.md#_snippet_5 LANGUAGE: bash CODE: ``` 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 ``` ---------------------------------------- TITLE: Example: get_capacity_by_address API Response DESCRIPTION: 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. SOURCE: https://github.com/nervosnetwork/ckb-cli/blob/develop/docs/API-Server.md#_snippet_6 LANGUAGE: json CODE: ``` { "jsonrpc": "2.0", "result": { "dao": 0, "immature": 0, "total": 3000000009000 }, "id": 2 } ``` ---------------------------------------- TITLE: API Method: get_capacity_by_lock_hash DESCRIPTION: 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. SOURCE: https://github.com/nervosnetwork/ckb-cli/blob/develop/docs/API-Server.md#_snippet_7 LANGUAGE: APIDOC CODE: ``` get_capacity_by_lock_hash Get capacity by lock script hash Parameters: lock_hash - Lock script hash ``` ---------------------------------------- TITLE: Example: Call get_capacity_by_lock_hash API via cURL DESCRIPTION: 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. SOURCE: https://github.com/nervosnetwork/ckb-cli/blob/develop/docs/API-Server.md#_snippet_8 LANGUAGE: bash CODE: ``` 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 ``` ---------------------------------------- TITLE: Example: get_capacity_by_lock_hash API Response DESCRIPTION: 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. SOURCE: https://github.com/nervosnetwork/ckb-cli/blob/develop/docs/API-Server.md#_snippet_9 LANGUAGE: json CODE: ``` { "jsonrpc": "2.0", "result": { "dao": 0, "immature": 0, "total": 3000000009000 }, "id": 2 } ``` ---------------------------------------- TITLE: API Method: get_live_cells_by_address DESCRIPTION: 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. SOURCE: https://github.com/nervosnetwork/ckb-cli/blob/develop/docs/API-Server.md#_snippet_10 LANGUAGE: APIDOC CODE: ``` 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 ``` ---------------------------------------- TITLE: Query Live Cells by Address using cURL and RPC DESCRIPTION: 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. SOURCE: https://github.com/nervosnetwork/ckb-cli/blob/develop/docs/API-Server.md#_snippet_11 LANGUAGE: bash CODE: ``` 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 ``` ---------------------------------------- TITLE: Example JSON RPC Response for Live Cells Query DESCRIPTION: 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. SOURCE: https://github.com/nervosnetwork/ckb-cli/blob/develop/docs/API-Server.md#_snippet_12 LANGUAGE: json CODE: ``` { "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 } ``` ---------------------------------------- TITLE: Get Derived Key Set for HD Wallet Cell Collection (keystore_derived_key_set) DESCRIPTION: 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. SOURCE: https://github.com/nervosnetwork/ckb-cli/blob/develop/docs/Plugin.md#_snippet_11 LANGUAGE: javascript CODE: ``` { "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" } ``` ---------------------------------------- TITLE: Retrieve Extended Public Key (keystore_extended_pubkey) DESCRIPTION: 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. SOURCE: https://github.com/nervosnetwork/ckb-cli/blob/develop/docs/Plugin.md#_snippet_10 LANGUAGE: javascript CODE: ``` { "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" } ``` LANGUAGE: javascript CODE: ``` { "result": { "type": "bytes", "content": "0x02531fe6068134503d2723133227c867ac8fa6c83c537e9a44c3c5bdbdcb1fe337" }, "id": 0, "jsonrpc": "2.0" } ``` ---------------------------------------- TITLE: Retrieve Derived Key Set by Path Index using CKB-CLI Keystore API DESCRIPTION: 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. SOURCE: https://github.com/nervosnetwork/ckb-cli/blob/develop/docs/Plugin.md#_snippet_12 LANGUAGE: javascript CODE: ``` { "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" } ``` LANGUAGE: javascript CODE: ``` { "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" } ``` ---------------------------------------- TITLE: RPC Protocol: Keystore Export Account DESCRIPTION: 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. SOURCE: https://github.com/nervosnetwork/ckb-cli/blob/develop/docs/Plugin.md#_snippet_7 LANGUAGE: APIDOC CODE: ``` 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" } ``` ---------------------------------------- TITLE: Example Master Private Key Response DESCRIPTION: An example JSON response showing the structure for a master private key and chain code, typically returned after a key generation or retrieval operation. SOURCE: https://github.com/nervosnetwork/ckb-cli/blob/develop/docs/Plugin.md#_snippet_8 LANGUAGE: javascript CODE: ``` { "result": { "type": "master_private_key", "content": { "privkey": "0x0303030303030303030303030303030303030303030303030303030303030303", "chain_code": "0x0404040404040404040404040404040404040404040404040404040404040404" } }, "id": 0, "jsonrpc": "2.0" } ``` ---------------------------------------- TITLE: API Method: get_live_cells_by_lock_hash DESCRIPTION: 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`. SOURCE: https://github.com/nervosnetwork/ckb-cli/blob/develop/docs/API-Server.md#_snippet_13 LANGUAGE: APIDOC CODE: ``` 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 ``` ---------------------------------------- TITLE: API Method: get_live_cells_by_type_hash DESCRIPTION: 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`. SOURCE: https://github.com/nervosnetwork/ckb-cli/blob/develop/docs/API-Server.md#_snippet_14 LANGUAGE: APIDOC CODE: ``` 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 ``` ---------------------------------------- TITLE: API Method: get_live_cells_by_code_hash DESCRIPTION: 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`. SOURCE: https://github.com/nervosnetwork/ckb-cli/blob/develop/docs/API-Server.md#_snippet_15 LANGUAGE: APIDOC CODE: ``` 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 ``` ---------------------------------------- TITLE: Build CKB-CLI and Keystore Demo Plugin DESCRIPTION: Instructions for compiling the ckb-cli tool and the example keystore plugin from source using `cargo build`. SOURCE: https://github.com/nervosnetwork/ckb-cli/blob/develop/docs/Plugin.md#_snippet_13 LANGUAGE: shell CODE: ``` # Build ckb-cli cargo build # Build example keystore plugin cd plugin-protocol cargo build --examples ``` ---------------------------------------- TITLE: Install Keystore Demo Plugin in CKB-CLI DESCRIPTION: 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. SOURCE: https://github.com/nervosnetwork/ckb-cli/blob/develop/docs/Plugin.md#_snippet_14 LANGUAGE: shell CODE: ``` ./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 ``` ---------------------------------------- TITLE: Display Detailed Information of Installed CKB-CLI Plugin DESCRIPTION: Command to retrieve and display metadata about an installed plugin, such as its daemon status, description, active status, name, and assigned roles. SOURCE: https://github.com/nervosnetwork/ckb-cli/blob/develop/docs/Plugin.md#_snippet_16 LANGUAGE: shell CODE: ``` 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 ``` ---------------------------------------- TITLE: Deactivate Keystore Demo Plugin in CKB-CLI DESCRIPTION: 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. SOURCE: https://github.com/nervosnetwork/ckb-cli/blob/develop/docs/Plugin.md#_snippet_18 LANGUAGE: shell CODE: ``` 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 ``` ---------------------------------------- TITLE: Retrieve CKB Tip Header (YAML Output) DESCRIPTION: 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. SOURCE: https://github.com/nervosnetwork/ckb-cli/blob/develop/README.md#_snippet_4 LANGUAGE: shell CODE: ``` ckb-cli rpc get_tip_header ``` LANGUAGE: yaml CODE: ``` 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 ``` ---------------------------------------- TITLE: Enable Debug Logging for CKB-CLI Plugins DESCRIPTION: Command to launch ckb-cli with detailed debug log messages specifically for the plugin module, useful for troubleshooting. SOURCE: https://github.com/nervosnetwork/ckb-cli/blob/develop/docs/Plugin.md#_snippet_15 LANGUAGE: shell CODE: ``` RUST_LOG=ckb_cli::plugin=debug ./target/debug/ckb-cli ```