TITLE: Request: Get Cells by Lock and Type Script (CKB RPC) DESCRIPTION: JSON RPC request body to query CKB cells filtered by a lock script and further filtered by a type script. Specifies the 'get_cells' method, parameters including the primary lock script, script type, sort order, page size, and a 'filter' object containing the details of the type script. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_59 LANGUAGE: json CODE: ``` { "id": 2, "jsonrpc": "2.0", "method": "get_cells", "params": [ { "script": { "code_hash": "0x58c5f491aba6d61678b7cf7edf4910b1f5e00ec0cde2f42e0abb4fd9aff25a63", "hash_type": "type", "args": "0x2a49720e721553d0614dff29454ee4e1f07d0707" }, "script_type": "lock", "filter": { "script": { "code_hash": "0xc5e5dcf215925f7ef4dfaf5f4b4f105bc321c02776d6e7d52a1db3fcd9d011a4", "hash_type": "type", "args": "0x8462b20277bcbaa30d821790b852fb322d55c2b12e750ea91ad7059bc98dda4b" } } }, "asc", "0x64" ] } ``` ---------------------------------------- TITLE: Start CKB Node (shell) DESCRIPTION: Starts the CKB node process using the configuration found in the current directory. The node will begin syncing with the network or reusing existing data if available. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/docs/quick-start.md#_snippet_2 LANGUAGE: shell CODE: ``` ckb run ``` ---------------------------------------- TITLE: Successful get_block Response (verbosity 2) - JSON DESCRIPTION: Example JSON response object returned by the `get_block` RPC method when `verbosity` is 2, showing the detailed block structure including header, transactions, proposals, and uncles. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_3 LANGUAGE: JSON CODE: ``` { "id": 42, "jsonrpc": "2.0", "result": { "header": { "compact_target": "0x1e083126", "dao": "0xb5a3e047474401001bc476b9ee573000c0c387962a38000000febffacf030000", "epoch": "0x7080018000001", "extra_hash": "0x0000000000000000000000000000000000000000000000000000000000000000", "hash": "0xa5f5c85987a15de25661e5a214f2c1449cd803f071acc7999820f25246471f40", "nonce": "0x0", "number": "0x400", "parent_hash": "0xae003585fa15309b30b31aed3dcf385e9472c3c3e93746a6c4540629a6a1ed2d", "proposals_hash": "0x0000000000000000000000000000000000000000000000000000000000000000", "timestamp": "0x5cd2b117", "transactions_root": "0xc47d5b78b3c4c4c853e2a32810818940d0ee403423bea9ec7b8e566d9595206c", "version": "0x0" }, "proposals": [], "transactions": [ { "cell_deps": [], "hash": "0x365698b50ca0da75dca2c87f9e7b563811d3b5813736b8cc62cc3b106faceb17", "header_deps": [], "inputs": [ { "previous_output": { "index": "0xffffffff", "tx_hash": "0x0000000000000000000000000000000000000000000000000000000000000000" }, "since": "0x400" } ], "outputs": [ { "capacity": "0x18e64b61cf", "lock": { "code_hash": "0x28e83a1277d48add8e72fadaa9248559e1b632bab2bd60b27955ebc4c03800a5", "hash_type": "data", "args": "0x" }, "type": null } ], "outputs_data": [ "0x" ], "version": "0x0", "witnesses": [ "0x450000000c000000410000003500000010000000300000003100000028e83a1277d48add8e72fadaa9248559e1b632bab2bd60b27955ebc4c03800a5000000000000000000" ] } ], "uncles": [] } } ``` ---------------------------------------- TITLE: Response for get_block_by_number (Verbosity 2, JSON) DESCRIPTION: Example JSON response for the `get_block_by_number` RPC method when `verbosity` is 2, showing the detailed `BlockView` structure including header, transactions, proposals, and uncles. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_7 LANGUAGE: json CODE: ``` { "id": 42, "jsonrpc": "2.0", "result": { "header": { "compact_target": "0x1e083126", "dao": "0xb5a3e047474401001bc476b9ee573000c0c387962a38000000febffacf030000", "epoch": "0x7080018000001", "extra_hash": "0x0000000000000000000000000000000000000000000000000000000000000000", "hash": "0xa5f5c85987a15de25661e5a214f2c1449cd803f071acc7999820f25246471f40", "nonce": "0x0", "number": "0x400", "parent_hash": "0xae003585fa15309b30b31aed3dcf385e9472c3c3e93746a6c4540629a6a1ed2d", "proposals_hash": "0x0000000000000000000000000000000000000000000000000000000000000000", "timestamp": "0x5cd2b117", "transactions_root": "0xc47d5b78b3c4c4c853e2a32810818940d0ee403423bea9ec7b8e566d9595206c", "version": "0x0" }, "proposals": [], "transactions": [ { "cell_deps": [], "hash": "0x365698b50ca0da75dca2c87f9e7b563811d3b5813736b8cc62cc3b106faceb17", "header_deps": [], "inputs": [ { "previous_output": { "index": "0xffffffff", "tx_hash": "0x0000000000000000000000000000000000000000000000000000000000000000" }, "since": "0x400" } ], "outputs": [ { "capacity": "0x18e64b61cf", "lock": { "code_hash": "0x28e83a1277d48add8e72fadaa9248559e1b632bab2bd60b27955ebc4c03800a5", "hash_type": "data", "args": "0x" }, "type": null } ], "outputs_data": [ "0x" ], "version": "0x0", "witnesses": [ "0x450000000c000000410000003500000010000000300000003100000028e83a1277d48add8e72fadaa9248559e1b632bab2bd60b27955ebc4c03800a5000000000000000000" ] } ], "uncles": [] } } ``` ---------------------------------------- TITLE: CKB Indexer get_cells RPC Response Example DESCRIPTION: An example of the JSON response structure returned by the CKB Indexer get_cells RPC method, showing a list of cell objects. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_61 LANGUAGE: json CODE: ``` { "jsonrpc": "2.0", "result": { "last_cursor": "0x4058c5f491aba6d61678b7cf7edf4910b1f5e00ec0cde2f42e0abb4fd9aff25a63012a49720e721553d0614dff29454ee4e1f07d070700000000002adf830000000200000001", "objects": [ { "block_number": "0x2adf83", "out_point": { "index": "0x1", "tx_hash": "0x23ec897027c1d2a2b39e2446162bac182f18581be048cb3896ad695559b6839e" }, "output": { "capacity": "0x54b42b70b4", "lock": { "args": "0x2a49720e721553d0614dff29454ee4e1f07d0707", "code_hash": "0x58c5f491aba6d61678b7cf7edf4910b1f5e00ec0cde2f42e0abb4fd9aff25a63", "hash_type": "type" }, "type": null }, "output_data": "0x", "tx_index": "0x2" } ] }, "id": 2 } ``` ---------------------------------------- TITLE: Submitting Transaction to Pool (send_transaction) - CKB RPC - JSON Request DESCRIPTION: Example JSON request payload for the `send_transaction` RPC method. It includes a complete transaction object with cell dependencies, header dependencies, inputs, outputs, output data, version, and witnesses, along with the optional `outputs_validator` parameter set to "passthrough". SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_105 LANGUAGE: JSON CODE: ``` { "id": 42, "jsonrpc": "2.0", "method": "send_transaction", "params": [ { "cell_deps": [ { "dep_type": "code", "out_point": { "index": "0x0", "tx_hash": "0xa4037a893eb48e18ed4ef61034ce26eba9c585f15c9cee102ae58505565eccc3" } } ], "header_deps": [ "0x7978ec7ce5b507cfb52e149e36b1a23f6062ed150503c85bbf825da3599095ed" ], "inputs": [ { "previous_output": { "index": "0x0", "tx_hash": "0x365698b50ca0da75dca2c87f9e7b563811d3b5813736b8cc62cc3b106faceb17" }, "since": "0x0" } ], "outputs": [ { "capacity": "0x2540be400", "lock": { "code_hash": "0x28e83a1277d48add8e72fadaa9248559e1b632bab2bd60b27955ebc4c03800a5", "hash_type": "data", "args": "0x" }, "type": null } ], "outputs_data": [ "0x" ], "version": "0x0", "witnesses": [] }, "passthrough" ] } ``` ---------------------------------------- TITLE: Initialize CKB Node Directory (shell) DESCRIPTION: Initializes the current directory with default CKB configuration files (`ckb.toml`). This command prepares the directory for running a CKB node. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/docs/quick-start.md#_snippet_1 LANGUAGE: shell CODE: ``` ckb init ``` ---------------------------------------- TITLE: Response: Get Cells by Lock Script (CKB RPC) DESCRIPTION: JSON RPC response body containing the result of the 'get_cells' query filtered by lock script. Includes the 'last_cursor' for pagination and an array of 'objects' representing the matching cells, each with details like block number, out point, output (capacity, lock, type), output data, and transaction index. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_58 LANGUAGE: json CODE: ``` { "jsonrpc": "2.0", "result": { "last_cursor": "0x409bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8015989ae415bb667931a99896e5fbbfad9ba53a22300000000005b0f8c0000000100000000", "objects": [ { "block_number": "0x5b0e6d", "out_point": { "index": "0x0", "tx_hash": "0xe8f2180dfba0cb15b45f771d520834515a5f8d7aa07f88894da88c22629b79e9" }, "output": { "capacity": "0x189640200", "lock": { "args": "0x5989ae415bb667931a99896e5fbbfad9ba53a223", "code_hash": "0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8", "hash_type": "type" }, "type": null }, "output_data": "0x", "tx_index": "0x1" }, { "block_number": "0x5b0e90", "out_point": { "index": "0x0", "tx_hash": "0xece3a27409bde2914fb7a1555d6bfca453ee46af73e665149ef549fd46ec1fc6" }, "output": { "capacity": "0x189640200", "lock": { "args": "0x5989ae415bb667931a99896e5fbbfad9ba53a223", "code_hash": "0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8", "hash_type": "type" }, "type": null }, "output_data": "0x", "tx_index": "0x1" }, { "block_number": "0x5b0ead", "out_point": { "index": "0x1", "tx_hash": "0x5c48768f91e3795b418c53211c76fd038c464a24c4aa7e35bbbb6ac5b219f581" }, "output": { "capacity": "0xe36dceec20", "lock": { "args": "0x5989ae415bb667931a99896e5fbbfad9ba53a223", "code_hash": "0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8", "hash_type": "type" }, "type": null }, "output_data": "0x", "tx_index": "0x1" }, { "block_number": "0x5b0eeb", "out_point": { "index": "0x0", "tx_hash": "0x90e6981d6a5692d92e54344dc0e12d213447710fa069cc19ddea874619b9ba48" }, "output": { "capacity": "0x174876e800", "lock": { "args": "0x5989ae415bb667931a99896e5fbbfad9ba53a223", "code_hash": "0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8", "hash_type": "type" }, "type": null }, "output_data": "0x", "tx_index": "0x1" }, { "block_number": "0x5b0f8c", "out_point": { "index": "0x0", "tx_hash": "0x9ea14510219ae97afa0275215fa77c3c015905281c953a3917a7fd036767429c" }, "output": { "capacity": "0x189640200", "lock": { "args": "0x5989ae415bb667931a99896e5fbbfad9ba53a223", "code_hash": "0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8", "hash_type": "type" }, "type": null }, "output_data": "0x", "tx_index": "0x1" } ] }, "id": 2 } ``` ---------------------------------------- TITLE: Verifying CKB Binary Signature (gpg) DESCRIPTION: This command verifies the PGP signature file (`.asc`) against the corresponding CKB binary archive (`.zip`). It checks if the signature is valid and was created by a trusted key. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/docs/integrity-check.md#_snippet_1 LANGUAGE: Shell CODE: ``` gpg --verify ckb_v0.43.0_x86_64-apple-darwin.zip.asc ckb_v0.43.0_x86_64-apple-darwin.zip ``` ---------------------------------------- TITLE: Query CKB Node RPC (shell) DESCRIPTION: Uses `curl` to send an RPC request to the running CKB node, assuming it's listening on port 8114. This specific request calls the `get_tip_header` method to retrieve the header of the current tip block. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/docs/quick-start.md#_snippet_3 LANGUAGE: shell CODE: ``` curl -d '{"id": 1, "jsonrpc": "2.0", "method":"get_tip_header","params": []}' \ -H 'content-type:application/json' 'http://localhost:8114' ``` ---------------------------------------- TITLE: Request get_blockchain_info RPC (JSON) DESCRIPTION: Example JSON request payload for calling the `get_blockchain_info` RPC method to retrieve statistics about the CKB chain. It uses JSON-RPC 2.0 format. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_124 LANGUAGE: json CODE: ``` { "id": 42, "jsonrpc": "2.0", "method": "get_blockchain_info", "params": [] } ``` ---------------------------------------- TITLE: Request: Get Cells by Lock Script (CKB RPC) DESCRIPTION: JSON RPC request body to query CKB cells filtered by a specific lock script. Specifies the method 'get_cells', parameters including the lock script details (code_hash, hash_type, args), script type, sort order ('asc'), and page size ('0x64'). SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_57 LANGUAGE: json CODE: ``` { "id": 2, "jsonrpc": "2.0", "method": "get_cells", "params": [ { "script": { "code_hash": "0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8", "hash_type": "type", "args": "0x5989ae415bb667931a99896e5fbbfad9ba53a223" }, "script_type": "lock" }, "asc", "0x64" ] } ``` ---------------------------------------- TITLE: Create and Navigate CKB Directory (shell) DESCRIPTION: Creates a new directory named `ckb-dev` and changes the current directory to it. This directory will be used to store the CKB node configuration and data. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/docs/quick-start.md#_snippet_0 LANGUAGE: shell CODE: ``` mkdir ckb-dev cd ckb-dev ``` ---------------------------------------- TITLE: Receiving Transaction Details (Verbosity 2) - CKB RPC - JSON DESCRIPTION: Shows a JSON RPC response from the `get_transaction` method when `verbosity` is 2. It includes the full transaction object, cycles, time added to pool, fee, min replace fee, and the transaction status. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_20 LANGUAGE: json CODE: ``` { "id": 42, "jsonrpc": "2.0", "result": { "transaction": { "cell_deps": [ { "dep_type": "code", "out_point": { "index": "0x0", "tx_hash": "0xa4037a893eb48e18ed4ef61034ce26eba9c585f15c9cee102ae58505565eccc3" } } ], "hash": "0xa0ef4eb5f4ceeb08a4c8524d84c5da95dce2f608e0ca2ec8091191b0f330c6e3", "header_deps": [ "0x7978ec7ce5b507cfb52e149e36b1a23f6062ed150503c85bbf825da3599095ed" ], "inputs": [ { "previous_output": { "index": "0x0", "tx_hash": "0x365698b50ca0da75dca2c87f9e7b563811d3b5813736b8cc62cc3b106faceb17" }, "since": "0x0" } ], "outputs": [ { "capacity": "0x2540be400", "lock": { "code_hash": "0x28e83a1277d48add8e72fadaa9248559e1b632bab2bd60b27955ebc4c03800a5", "hash_type": "data", "args": "0x" }, "type": null } ], "outputs_data": [ "0x" ], "version": "0x0", "witnesses": [] }, "cycles": "0x219", "time_added_to_pool" : "0x187b3d137a1", "fee": "0x16923f7dcf", "min_replace_fee": "0x16923f7f6a", "tx_status": { "block_hash": null, "block_number": null, "status": "pending", "tx_index": null, "reason": null } } } ``` ---------------------------------------- TITLE: Example OutPoint JSON Object DESCRIPTION: Illustrates the structure and typical values of the `OutPoint` JSON object, which references a cell by its transaction hash and output index. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_149 LANGUAGE: JSON CODE: ``` { "index": "0x0", "tx_hash": "0x365698b50ca0da75dca2c87f9e7b563811d3b5813736b8cc62cc3b106faceb17" } ``` ---------------------------------------- TITLE: Response get_blockchain_info RPC (JSON) DESCRIPTION: Example JSON response payload returned by the `get_blockchain_info` RPC method. It contains various chain statistics like alerts, chain name, difficulty, epoch, IBD status, and median time. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_125 LANGUAGE: json CODE: ``` { "id": 42, "jsonrpc": "2.0", "result": { "alerts": [ { "id": "0x2a", "message": "An example alert message!", "notice_until": "0x24bcca57c00", "priority": "0x1" } ], "chain": "ckb", "difficulty": "0x1f4003", "epoch": "0x7080018000001", "is_initial_block_download": true, "median_time": "0x5cd2b105" } } ``` ---------------------------------------- TITLE: Example CKB Block Header JSON DESCRIPTION: This JSON object provides an example structure and typical values for a CKB block header (HeaderView). It illustrates the format of fields like compact_target, dao, epoch, hash, nonce, number, parent_hash, proposals_hash, timestamp, transactions_root, extra_hash, and version. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_146 LANGUAGE: json CODE: ``` { "compact_target": "0x1e083126", "dao": "0xb5a3e047474401001bc476b9ee573000c0c387962a38000000febffacf030000", "epoch": "0x7080018000001", "hash": "0xa5f5c85987a15de25661e5a214f2c1449cd803f071acc7999820f25246471f40", "nonce": "0x0", "number": "0x400", "parent_hash": "0xae003585fa15309b30b31aed3dcf385e9472c3c3e93746a6c4540629a6a1ed2d", "proposals_hash": "0x0000000000000000000000000000000000000000000000000000000000000000", "timestamp": "0x5cd2b117", "transactions_root": "0xc47d5b78b3c4c4c853e2a32810818940d0ee403423bea9ec7b8e566d9595206c", "extra_hash": "0x0000000000000000000000000000000000000000000000000000000000000000", "version": "0x0" } ``` ---------------------------------------- TITLE: Local Node Info RPC Request (JSON) DESCRIPTION: JSON request payload for the `local_node_info` RPC method. This method requires no parameters. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_91 LANGUAGE: json CODE: ``` { "id": 42, "jsonrpc": "2.0", "method": "local_node_info", "params": [] } ``` ---------------------------------------- TITLE: Local Node Info RPC Response (JSON) DESCRIPTION: JSON response payload for the `local_node_info` RPC method. It returns detailed information about the local CKB node, including addresses, connections, node ID, protocols, and version. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_92 LANGUAGE: json CODE: ``` { "id": 42, "jsonrpc": "2.0", "result": { "active": true, "addresses": [ { "address": "/ip4/192.168.0.2/tcp/8112/p2p/QmTRHCdrRtgUzYLNCin69zEvPvLYdxUZLLfLYyHVY3DZAS", "score": "0xff" }, { "address": "/ip4/0.0.0.0/tcp/8112/p2p/QmTRHCdrRtgUzYLNCin69zEvPvLYdxUZLLfLYyHVY3DZAS", "score": "0x1" } ], "connections": "0xb", "node_id": "QmTRHCdrRtgUzYLNCin69zEvPvLYdxUZLLfLYyHVY3DZAS", "protocols": [ { "id": "0x0", "name": "/ckb/ping", "support_versions": [ "0.0.1" ] }, { "id": "0x1", "name": "/ckb/discovery", "support_versions": [ "0.0.1" ] } ], "version": "0.34.0 (f37f598 2020-07-17)" } } ``` ---------------------------------------- TITLE: Example LocalNode JSON Object DESCRIPTION: Illustrates the structure and typical values of the `LocalNode` JSON object, representing the local CKB node's status and configuration, including network addresses, connections, protocols, and version. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_147 LANGUAGE: JSON CODE: ``` { "active": true, "addresses": [ { "address": "/ip4/192.168.0.2/tcp/8112/p2p/QmTRHCdrRtgUzYLNCin69zEvPvLYdxUZLLfLYyHVY3DZAS", "score": "0xff" }, { "address": "/ip4/0.0.0.0/tcp/8112/p2p/QmTRHCdrRtgUzYLNCin69zEvPvLYdxUZLLfLYyHVY3DZAS", "score": "0x1" } ], "connections": "0xb", "node_id": "QmTRHCdrRtgUzYLNCin69zEvPvLYdxUZLLfLYyHVY3DZAS", "protocols": [ { "id": "0x0", "name": "/ckb/ping", "support_versions": [ "0.0.1" ] }, { "id": "0x1", "name": "/ckb/discovery", "support_versions": [ "0.0.1" ] } ], "version": "0.34.0 (f37f598 2020-07-17)" } ``` ---------------------------------------- TITLE: Initializing CKB Dev Chain for Mining Test (Shell) DESCRIPTION: Initializes a local CKB development chain configured for mining tests. It creates a directory, changes into it, and runs the `ckb init` command specifying the 'dev' chain and a public key hash for the base address. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/docs/dev-miner.md#_snippet_0 LANGUAGE: Shell CODE: ``` mkdir ckb-dev-miner-test cd ckb-dev-miner-test ckb init --chain dev --ba-arg 0x470dcdc5e44064909650113a274b3b36aecb6dc7 ``` ---------------------------------------- TITLE: WebSocket RPC Subscription Example (JavaScript) DESCRIPTION: Shows how to use JavaScript's `WebSocket` API to connect to a CKB node, set up an `onmessage` handler to receive push notifications, and send `subscribe` and `unsubscribe` JSON-RPC messages. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_129 LANGUAGE: javascript CODE: ``` let socket = new WebSocket("ws://localhost:28114") socket.onmessage = function(event) { console.log(`Data received from server: ${event.data}`); } socket.send(`{"id": 2, "jsonrpc": "2.0", "method": "subscribe", "params": ["new_tip_header"]}`) socket.send(`{"id": 2, "jsonrpc": "2.0", "method": "unsubscribe", "params": ["0x0"]}`) ``` ---------------------------------------- TITLE: Export Testnet Configuration (Shell) DESCRIPTION: Initializes the current directory with configuration files specifically tailored for the Pudge testnet. Use this to set up a testnet node. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/docs/configure.md#_snippet_2 LANGUAGE: Shell CODE: ``` ckb init --chain testnet ``` ---------------------------------------- TITLE: Requesting a Block by Number (JSON) DESCRIPTION: Example JSON request payload for the `get_block_by_number` RPC method, specifying the block number '0x400' to retrieve details for. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_6 LANGUAGE: json CODE: ``` { "id": 42, "jsonrpc": "2.0", "method": "get_block_by_number", "params": [ "0x400" ] } ``` ---------------------------------------- TITLE: Submitting Transaction to Pool (send_transaction) - CKB RPC - JSON Response DESCRIPTION: Example JSON response for the `send_transaction` RPC method. A successful submission returns the transaction hash (`H256`) of the submitted transaction in the `result` field. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_106 LANGUAGE: JSON CODE: ``` { "id": 42, "jsonrpc": "2.0", "result": "0xa0ef4eb5f4ceeb08a4c8524d84c5da95dce2f608e0ca2ec8091191b0f330c6e3" } ``` ---------------------------------------- TITLE: Initialize CKB Configuration Files (Shell) DESCRIPTION: Exports the bundled default CKB configuration files into the current working directory. This is the first step to customize node settings. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/docs/configure.md#_snippet_0 LANGUAGE: Shell CODE: ``` ckb init ``` ---------------------------------------- TITLE: Starting CKB Node (Shell) DESCRIPTION: Starts the CKB node process. This command launches the configured dev chain, making it ready to accept connections and process blocks. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/docs/dev-miner.md#_snippet_2 LANGUAGE: Shell CODE: ``` ckb run ``` ---------------------------------------- TITLE: TCP RPC Subscription Example (Bash) DESCRIPTION: Demonstrates how to establish a TCP connection using `telnet` and send JSON-RPC requests to subscribe (`subscribe`) and unsubscribe (`unsubscribe`) from the `new_tip_header` topic. Shows example request and response messages. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_128 LANGUAGE: bash CODE: ``` telnet localhost 18114 > {"id": 2, "jsonrpc": "2.0", "method": "subscribe", "params": ["new_tip_header"]} < {"jsonrpc":"2.0","result":"0x0","id":2} < {"jsonrpc":"2.0","method":"subscribe","params":{"result":"...block header json...","subscription":0}} < {"jsonrpc":"2.0","method":"subscribe","params":{"result":"...block header json...","subscription":0}} < ... > {"id": 2, "jsonrpc": "2.0", "method": "unsubscribe", "params": ["0x0"]} < {"jsonrpc":"2.0","result":true,"id":2} ``` ---------------------------------------- TITLE: Response: Get Cells by Lock and Type Script (CKB RPC) DESCRIPTION: JSON RPC response body containing the result of the 'get_cells' query filtered by both lock and type scripts. Includes the 'last_cursor' for pagination and an array of 'objects' representing the matching cells, each with details like block number and out point. Note: The provided response snippet is truncated. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_60 LANGUAGE: json CODE: ``` { "jsonrpc": "2.0", "result": { "last_cursor": "0x4058c5f491aba6d61678b7cf7edf4910b1f5e00ec0cde2f42e0abb4fd9aff25a63012a49720e721553d0614dff29454ee4e1f07d070700000000002adf870000000100000001", "objects": [ { "block_number": "0x2adf87", "out_point": { "index": "0x1", ``` ---------------------------------------- TITLE: Requesting Transaction Details - CKB RPC - JSON DESCRIPTION: Demonstrates a JSON RPC request to the `get_transaction` method, querying details for a specific transaction hash. It includes the standard JSON RPC fields (`id`, `jsonrpc`, `method`) and the `params` array containing the transaction hash. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_19 LANGUAGE: json CODE: ``` { "id": 42, "jsonrpc": "2.0", "method": "get_transaction", "params": [ "0xa0ef4eb5f4ceeb08a4c8524d84c5da95dce2f608e0ca2ec8091191b0f330c6e3" ] } ``` ---------------------------------------- TITLE: Example CellInput JSON DESCRIPTION: Provides an example JSON representation of a CellInput object, showing how it references a previous output cell (previous_output) and includes a since value for transaction validity constraints. Cell inputs consume existing cells. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_139 LANGUAGE: json CODE: ``` { "previous_output": { "index": "0x0", "tx_hash": "0x365698b50ca0da75dca2c87f9e7b563811d3b5813736b8cc62cc3b106faceb17" }, "since": "0x0" } ``` ---------------------------------------- TITLE: Notify CKB Transaction RPC Request (JSON) DESCRIPTION: JSON RPC request payload to call the `notify_transaction` method, which adds a specified transaction to the transaction pool. Includes a detailed transaction structure. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_79 LANGUAGE: json CODE: ``` { "id": 42, "jsonrpc": "2.0", "method": "notify_transaction", "params": [ { "cell_deps": [{ "dep_type": "code", "out_point": { "index": "0x0", "tx_hash": "0xa4037a893eb48e18ed4ef61034ce26eba9c585f15c9cee102ae58505565eccc3" } }], "header_deps": [ "0x7978ec7ce5b507cfb52e149e36b1a23f6062ed150503c85bbf825da3599095ed" ], "inputs": [{ "previous_output": { "index": "0x0", "tx_hash": "0x365698b50ca0da75dca2c87f9e7b563811d3b5813736b8cc62cc3b106faceb17" }, "since": "0x0" }], "outputs": [{ "capacity": "0x2540be400", "lock": { "code_hash": "0x28e83a1277d48add8e72fadaa9248559e1b632bab2bd60b27955ebc4c03800a5", "hash_type": "data", "args": "0x" }, "type": null }], "outputs_data": [ "0x" ], "version": "0x0", "witnesses": [] } ] } ``` ---------------------------------------- TITLE: CKB Indexer get_cells RPC Request - Filter by Capacity Range DESCRIPTION: Demonstrates a get_cells RPC request to retrieve cells locked by a specific script, filtering for cells where the output capacity is within a specified range. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_64 LANGUAGE: json CODE: ``` { "id": 2, "jsonrpc": "2.0", "method": "get_cells", "params": [ { "script": { "code_hash": "0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8", "hash_type": "type", "args": "0x5989ae415bb667931a99896e5fbbfad9ba53a223" }, "script_type": "lock", "filter": { "output_capacity_range": ["0x0", "0x174876e801"] } }, "asc", "0x64" ] } ``` ---------------------------------------- TITLE: Request estimate_fee_rate CKB RPC (JSON) DESCRIPTION: Example JSON request payload for calling the `estimate_fee_rate` RPC method to get fee estimates. It includes the standard JSON-RPC fields: id, jsonrpc version, method name, and an empty params array. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_53 LANGUAGE: json CODE: ``` { "id": 42, "jsonrpc": "2.0", "method": "estimate_fee_rate", "params": [] } ``` ---------------------------------------- TITLE: Requesting dry_run_transaction RPC (JSON) DESCRIPTION: This JSON object represents a request to the `dry_run_transaction` RPC method. It includes a sample transaction object with cell dependencies, header dependencies, inputs, outputs, output data, version, and witnesses to be dry-run for cycle estimation. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_49 LANGUAGE: JSON CODE: ``` { "id": 42, "jsonrpc": "2.0", "method": "dry_run_transaction", "params": [ { "cell_deps": [ { "dep_type": "code", "out_point": { "index": "0x0", "tx_hash": "0xa4037a893eb48e18ed4ef61034ce26eba9c585f15c9cee102ae58505565eccc3" } } ], "header_deps": [ "0x7978ec7ce5b507cfb52e149e36b1a23f6062ed150503c85bbf825da3599095ed" ], "inputs": [ { "previous_output": { "index": "0x0", "tx_hash": "0x365698b50ca0da75dca2c87f9e7b563811d3b5813736b8cc62cc3b106faceb17" }, "since": "0x0" } ], "outputs": [ { "capacity": "0x2540be400", "lock": { "code_hash": "0x28e83a1277d48add8e72fadaa9248559e1b632bab2bd60b27955ebc4c03800a5", "hash_type": "data", "args": "0x" }, "type": null } ], "outputs_data": [ "0x" ], "version": "0x0", "witnesses": [] } ] } ``` ---------------------------------------- TITLE: Requesting Block Hash by Number - CKB RPC - JSON DESCRIPTION: Demonstrates a JSON RPC request to the `get_block_hash` method, querying the hash of a block using its block number. It includes the standard JSON RPC fields and the `params` array containing the block number. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_22 LANGUAGE: json CODE: ``` { "id": 42, "jsonrpc": "2.0", "method": "get_block_hash", "params": [ "0x400" ] } ``` ---------------------------------------- TITLE: CKB Indexer get_cells RPC Response - Filter by Capacity Range DESCRIPTION: An example response for a get_cells request filtered by output capacity range, showing a cell object with a capacity within the requested range. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_65 LANGUAGE: json CODE: ``` { "jsonrpc": "2.0", "result": { "last_cursor": "0x409bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8015989ae415bb667931a99896e5fbbfad9ba53a22300000000005b59df0000000100000001", "objects": [ { "block_number": "0x5b59df", "out_point": { "index": "0x1", "tx_hash": "0x21c4632a41140b828e9347ff80480b3e07be4e0a0b8d577565e7421fd5473194" }, "output": { "capacity": "0xe815b81c0", "lock": { "args": "0x5989ae415bb667931a99896e5fbbfad9ba53a223", "code_hash": "0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8", "hash_type": "type" }, "type": null }, "output_data": "0x", "tx_index": "0x1" } ] }, "id": 2 } ``` ---------------------------------------- TITLE: Initialize CKB data directory and config DESCRIPTION: Creates the data directory for CKB and initializes the configuration files for joining the mainnet, directing logs to stdout. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/devtools/init/linux-systemd/README.md#_snippet_1 LANGUAGE: bash CODE: ``` sudo mkdir /var/lib/ckb sudo /usr/local/bin/ckb init -C /var/lib/ckb --chain mainnet --log-to stdout ``` ---------------------------------------- TITLE: List Supported CKB Chains (Shell) DESCRIPTION: Displays a list of all supported chain specifications that can be used with the `ckb init` command to export specific chain configurations. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/docs/configure.md#_snippet_1 LANGUAGE: Shell CODE: ``` ckb init --list-chains ``` ---------------------------------------- TITLE: Example CellOutput JSON DESCRIPTION: Provides an example JSON representation of a CellOutput object, detailing the cell's capacity, lock script, and optional type script. Cell outputs create new cells. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_140 LANGUAGE: json CODE: ``` { "capacity": "0x2540be400", "lock": { "code_hash": "0x28e83a1277d48add8e72fadaa9248559e1b632bab2bd60b27955ebc4c03800a5", "hash_type": "data", "args": "0x" }, "type": null } ``` ---------------------------------------- TITLE: Install and start CKB node systemd service DESCRIPTION: Downloads the CKB node systemd service file, copies it to the systemd directory, sets ownership and permissions, reloads the systemd daemon, and starts the CKB node service. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/devtools/init/linux-systemd/README.md#_snippet_3 LANGUAGE: bash CODE: ``` curl -L -O https://raw.githubusercontent.com/nervosnetwork/ckb/master/devtools/init/linux-systemd/ckb.service sudo cp ckb.service /etc/systemd/system/ sudo chown root:root /etc/systemd/system/ckb.service sudo chmod 644 /etc/systemd/system/ckb.service sudo systemctl daemon-reload sudo systemctl start ckb.service ``` ---------------------------------------- TITLE: Response for dry_run_transaction RPC (JSON) DESCRIPTION: This JSON object shows a typical successful response from the `dry_run_transaction` RPC method. It contains the estimated execution cycles for the provided transaction within the `result` field. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_50 LANGUAGE: JSON CODE: ``` { "id": 42, "jsonrpc": "2.0", "result": { "cycles": "0x219" } } ``` ---------------------------------------- TITLE: Calling test_tx_pool_accept RPC (JSON) - Request DESCRIPTION: This JSON object represents a request to the `test_tx_pool_accept` RPC method. It includes a full transaction structure with cell dependencies, header dependencies, inputs, outputs, output data, version, and witnesses, along with an `outputs_validator` parameter set to "passthrough". SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_107 LANGUAGE: json CODE: ``` { "id": 42, "jsonrpc": "2.0", "method": "test_tx_pool_accept", "params": [ { "cell_deps": [ { "dep_type": "code", "out_point": { "index": "0x0", "tx_hash": "0xa4037a893eb48e18ed4ef61034ce26eba9c585f15c9cee102ae58505565eccc3" } } ], "header_deps": [ "0x7978ec7ce5b507cfb52e149e36b1a23f6062ed150503c85bbf825da3599095ed" ], "inputs": [ { "previous_output": { "index": "0x0", "tx_hash": "0x075fe030c1f4725713c5aacf41c2f59b29b284008fdb786e5efd8a058be51d0c" }, "since": "0x0" } ], "outputs": [ { "capacity": "0x2431ac129", "lock": { "code_hash": "0x28e83a1277d48add8e72fadaa9248559e1b632bab2bd60b27955ebc4c03800a5", "hash_type": "data", "args": "0x" }, "type": null } ], "outputs_data": [ "0x" ], "version": "0x0", "witnesses": [] }, "passthrough" ] } ``` ---------------------------------------- TITLE: Setup CKB user, group, and permissions DESCRIPTION: Creates a dedicated system user and group for running CKB, sets the home directory, disables login, and assigns ownership and permissions to the data directory and configuration files. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/devtools/init/linux-systemd/README.md#_snippet_2 LANGUAGE: bash CODE: ``` sudo groupadd ckb sudo useradd \ -g ckb --no-user-group \ --home-dir /var/lib/ckb --no-create-home \ --shell /usr/sbin/nologin \ --system ckb sudo chown -R ckb:ckb /var/lib/ckb sudo chmod 755 /var/lib/ckb sudo chmod 644 /var/lib/ckb/ckb.toml /var/lib/ckb/ckb-miner.toml ``` ---------------------------------------- TITLE: tx_pool_info RPC (JSON) - Response DESCRIPTION: This JSON object shows the response from the `tx_pool_info` RPC method. The `result` field contains a `TxPoolInfo` object with various statistics and configuration values related to the transaction pool, such as pending/proposed transaction counts, fee rates, and pool size limits. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_113 LANGUAGE: json CODE: ``` { "id": 42, "jsonrpc": "2.0", "result": { "last_txs_updated_at": "0x0", "min_fee_rate": "0x3e8", "min_rbf_rate": "0x5dc", "max_tx_pool_size": "0xaba9500", "orphan": "0x0", "pending": "0x1", "proposed": "0x0", "tip_hash": "0xa5f5c85987a15de25661e5a214f2c1449cd803f071acc7999820f25246471f40", "tip_number": "0x400", "total_tx_cycles": "0x219", "total_tx_size": "0x112", "tx_size_limit": "0x7d000", "verify_queue_size": "0x0" } } ``` ---------------------------------------- TITLE: Example CellWithStatus Live State (JSON) DESCRIPTION: This JSON snippet shows an example of a CellWithStatus object when the cell is in the "live" state. It includes the cell's data, output details (capacity, lock, type), and the status. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_141 LANGUAGE: json CODE: ``` { "cell": { "data": { "content": "0x7f454c460201010000000000000000000200f3000100000078000100000000004000000000000000980000000000000005000000400038000100400003000200010000000500000000000000000000000000010000000000000001000000000082000000000000008200000000000000001000000000000001459308d00573000000002e7368737472746162002e74657874000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000b000000010000000600000000000000780001000000000078000000000000000a0000000000000000000000000000000200000000000000000000000000000001000000030000000000000000000000000000000000000082000000000000001100000000000000000000000000000001000000000000000000000000000000", "hash": "0x28e83a1277d48add8e72fadaa9248559e1b632bab2bd60b27955ebc4c03800a5" }, "output": { "capacity": "0x802665800", "lock": { "args": "0x", "code_hash": "0x0000000000000000000000000000000000000000000000000000000000000000", "hash_type": "data" }, "type": null } }, "status": "live" } ``` ---------------------------------------- TITLE: Example CellDep JSON DESCRIPTION: Provides an example JSON representation of a CellDep object, illustrating how it specifies a cell dependency with dep_type and out_point. Cell dependencies are used to reference cells containing code or data required by a transaction. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_137 LANGUAGE: json CODE: ``` { "dep_type": "code", "out_point": { "index": "0x0", "tx_hash": "0xa4037a893eb48e18ed4ef61034ce26eba9c585f15c9cee102ae58505565eccc3" } } ``` ---------------------------------------- TITLE: Header Response by Number (JSON, Verbosity 1) DESCRIPTION: JSON response payload for the `get_header_by_number` RPC method when verbosity is 1, showing a detailed block header object. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_14 LANGUAGE: json CODE: ``` { "id": 42, "jsonrpc": "2.0", "result": { "compact_target": "0x1e083126", "dao": "0xb5a3e047474401001bc476b9ee573000c0c387962a38000000febffacf030000", "epoch": "0x7080018000001", "extra_hash": "0x0000000000000000000000000000000000000000000000000000000000000000", "hash": "0xa5f5c85987a15de25661e5a214f2c1449cd803f071acc7999820f25246471f40", "nonce": "0x0", "number": "0x400", "parent_hash": "0xae003585fa15309b30b31aed3dcf385e9472c3c3e93746a6c4540629a6a1ed2d", "proposals_hash": "0x0000000000000000000000000000000000000000000000000000000000000000", "timestamp": "0x5cd2b117", "transactions_root": "0xc47d5b78b3c4c4c853e2a32810818940d0ee403423bea9ec7b8e566d9595206c", "version": "0x0" } } ``` ---------------------------------------- TITLE: Subscribe to CKB RPC Topic - JSON DESCRIPTION: Example JSON request to subscribe to a specific CKB RPC topic, such as `new_tip_header`. The `params` array contains the name of the topic to subscribe to. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_131 LANGUAGE: json CODE: ``` { "id": 42, "jsonrpc": "2.0", "method": "subscribe", "params": [ "new_tip_header" ] } ``` ---------------------------------------- TITLE: View CKB node service logs DESCRIPTION: Shows the journal logs for the CKB node systemd service since the last boot, useful for debugging issues. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/devtools/init/linux-systemd/README.md#_snippet_6 LANGUAGE: bash CODE: ``` sudo journalctl --boot -u ckb.service ``` ---------------------------------------- TITLE: Check CKB node service status DESCRIPTION: Displays the current status of the CKB node systemd service, showing whether it is active and recent log output. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/devtools/init/linux-systemd/README.md#_snippet_5 LANGUAGE: bash CODE: ``` sudo systemctl status ckb.service ``` ---------------------------------------- TITLE: Example CellInfo JSON DESCRIPTION: Provides an example JSON representation of a CellInfo object, combining CellData and CellOutput fields to give a complete view of a cell. This structure is useful for representing a cell's full state. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_138 LANGUAGE: json CODE: ``` { "data": { "content": "0x7f454c460201010000000000000000000200f3000100000078000100000000004000000000000000980000000000000005000000400038000100400003000200010000000500000000000000000000000000010000000000000001000000000082000000000000008200000000000000001000000000000001459308d00573000000002e7368737472746162002e74657874000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000b000000010000000600000000000000780001000000000078000000000000000a0000000000000000000000000000000200000000000000000000000000000001000000030000000000000000000000000000000000000082000000000000001100000000000000000000000000000001000000000000000000000000000000", "hash": "0x28e83a1277d48add8e72fadaa9248559e1b632bab2bd60b27955ebc4c03800a5" }, "output": { "capacity": "0x802665800", "lock": { "args": "0x", "code_hash": "0x0000000000000000000000000000000000000000000000000000000000000000", "hash_type": "data" }, "type": null } } ``` ---------------------------------------- TITLE: Response Format for get_block_by_number (with_cycles, JSON) DESCRIPTION: Example JSON response format for the `get_block_by_number` RPC method when `with_cycles` is specified, including the block data (either object or hex string) and a list of cycles. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_9 LANGUAGE: json CODE: ``` { "id": 42, "jsonrpc": "2.0", "result": { "block": " or \"0x...\"", "cycles": [] } } ``` ---------------------------------------- TITLE: RPC Request: get_consensus (JSON) DESCRIPTION: This JSON object represents a standard RPC request to retrieve the current consensus parameters of the CKB network. It uses the 'get_consensus' method with no parameters. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_39 LANGUAGE: json CODE: ``` { "id": 42, "jsonrpc": "2.0", "method": "get_consensus", "params": [] } ``` ---------------------------------------- TITLE: Initialize CKB with Secp256k1 Block Assembler (Shell) DESCRIPTION: This command initializes the CKB directory, setting the block assembler using a secp256k1 compressed public key. It combines the `ckb init` command with the output of `ckb cli secp256k1-lock --format cmd` to automatically provide the necessary `--ba-code-hash` and `--ba-arg` options. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/CHANGELOG.md#_snippet_3 LANGUAGE: Shell CODE: ``` ckb init $(ckb cli secp256k1-lock --format cmd) ``` ---------------------------------------- TITLE: Running CKB with Rich-Indexer (SQLite) DESCRIPTION: Command to start the CKB node with the default Rich-Indexer using the embedded SQLite database. This requires no extra configuration and initiates the indexing process. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/util/rich-indexer/README.md#_snippet_0 LANGUAGE: bash CODE: ``` ckb run -C --rich-indexer ``` ---------------------------------------- TITLE: Requesting Header by Number (JSON) DESCRIPTION: JSON request payload for the `get_header_by_number` RPC method, querying a block header using its block number. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_13 LANGUAGE: json CODE: ``` { "id": 42, "jsonrpc": "2.0", "method": "get_header_by_number", "params": [ "0x400" ] } ``` ---------------------------------------- TITLE: Requesting a Block by Hash (get_block) - JSON DESCRIPTION: Example JSON request payload for calling the `get_block` RPC method with a specific block hash to retrieve block information. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_2 LANGUAGE: JSON CODE: ``` { "id": 42, "jsonrpc": "2.0", "method": "get_block", "params": [ "0xa5f5c85987a15de25661e5a214f2c1449cd803f071acc7999820f25246471f40" ] } ``` ---------------------------------------- TITLE: Example CellData JSON DESCRIPTION: Provides an example JSON representation of a CellData object, showing its content (as hex bytes) and hash. CellData represents the actual data stored within a cell. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_136 LANGUAGE: json CODE: ``` { "content": "0x7f454c460201010000000000000000000200f3000100000078000100000000004000000000000000980000000000000005000000400038000100400003000200010000000500000000000000000000000000010000000000000001000000000082000000000000008200000000000000001000000000000001459308d00573000000002e7368737472746162002e74657874000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000b000000010000000600000000000000780001000000000078000000000000000a0000000000000000000000000000000200000000000000000000000000000001000000030000000000000000000000000000000000000082000000000000001100000000000000000000000000000001000000000000000000000000000000", "hash": "0x28e83a1277d48add8e72fadaa9248559e1b632bab2bd60b27955ebc4c03800a5" } ``` ---------------------------------------- TITLE: Subscription Push Message Example (JSON) DESCRIPTION: An example of the JSON-RPC message format that the CKB node pushes to a subscriber when a new event occurs on a subscribed topic. It includes the method name (`subscribe`), the result payload, and the subscription ID. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_130 LANGUAGE: json CODE: ``` { "jsonrpc": "2.0", "method": "subscribe", "params": { "result": { ... }, "subscription": "0x2a" } } ``` ---------------------------------------- TITLE: Requesting Transactions by Lock Script - CKB RPC - JSON DESCRIPTION: This JSON object represents an RPC request to the CKB node using the `get_transactions` method. It queries for transactions where either an input or an output cell's lock script matches the provided `code_hash`, `hash_type`, and `args`. The request specifies sorting order ('asc') and a limit ('0x64'). SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_66 LANGUAGE: json CODE: ``` { "id": 2, "jsonrpc": "2.0", "method": "get_transactions", "params": [ { "script": { "code_hash": "0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8", "hash_type": "type", "args": "0x5989ae415bb667931a99896e5fbbfad9ba53a223" }, "script_type": "lock" }, "asc", "0x64" ] } ``` ---------------------------------------- TITLE: Response for Fee Rate Statistics (get_fee_rate_statistics) - JSON DESCRIPTION: Shows a sample JSON response from the `get_fee_rate_statistics` RPC method. The response contains the mean and median fee rates in shannons per kilo-weight under the `result` field. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_48 LANGUAGE: json CODE: ``` { "id": 42, "jsonrpc": "2.0", "result": { "mean": "0xe79d", "median": "0x14a8" } } ``` ---------------------------------------- TITLE: Requesting Fee Rate Statistics (get_fee_rate_statistics) - JSON DESCRIPTION: Provides a sample JSON request body for the current `get_fee_rate_statistics` RPC method. This method is used to retrieve fee rate statistics for confirmed blocks. The request takes no parameters in this example. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_47 LANGUAGE: json CODE: ``` { "id": 42, "jsonrpc": "2.0", "method": "get_fee_rate_statistics", "params": [] } ``` ---------------------------------------- TITLE: Check CKB Daemon Status (Bash) DESCRIPTION: Checks the current status of the CKB daemon process to see if it is running. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/devtools/init/README.md#_snippet_1 LANGUAGE: bash CODE: ``` ckb daemon --check ``` ---------------------------------------- TITLE: Header Response by Hash (JSON, Verbosity 1) DESCRIPTION: JSON response payload for the `get_header` RPC method when verbosity is 1, showing a detailed block header object. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_11 LANGUAGE: json CODE: ``` { "id": 42, "jsonrpc": "2.0", "result": { "compact_target": "0x1e083126", "dao": "0xb5a3e047474401001bc476b9ee573000c0c387962a38000000febffacf030000", "epoch": "0x7080018000001", "extra_hash": "0x0000000000000000000000000000000000000000000000000000000000000000", "hash": "0xa5f5c85987a15de25661e5a214f2c1449cd803f071acc7999820f25246471f40", "nonce": "0x0", "number": "0x400", "parent_hash": "0xae003585fa15309b30b31aed3dcf385e9472c3c3e93746a6c4540629a6a1ed2d", "proposals_hash": "0x0000000000000000000000000000000000000000000000000000000000000000", "timestamp": "0x5cd2b117", "transactions_root": "0xc47d5b78b3c4c4c853e2a32810818940d0ee403423bea9ec7b8e566d9595206c", "version": "0x0" } } ``` ---------------------------------------- TITLE: Install and start CKB miner systemd service DESCRIPTION: Downloads the CKB miner systemd service file, copies it to the systemd directory, sets ownership and permissions, reloads the systemd daemon, and starts the CKB miner service. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/devtools/init/linux-systemd/README.md#_snippet_7 LANGUAGE: bash CODE: ``` curl -L -O https://raw.githubusercontent.com/nervosnetwork/ckb/master/devtools/init/linux-systemd/ckb-miner.service sudo cp ckb-miner.service /etc/systemd/system/ sudo chown root:root /etc/systemd/system/ckb-miner.service sudo chmod 644 /etc/systemd/system/ckb-miner.service sudo systemctl daemon-reload sudo systemctl start ckb-miner.service ``` ---------------------------------------- TITLE: Importing CKB PGP Public Key (gpg) DESCRIPTION: This command imports the specified PGP public key from a keyserver network using the `gpg` tool. This key is required to verify the digital signatures of CKB release binaries. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/docs/integrity-check.md#_snippet_0 LANGUAGE: Shell CODE: ``` gpg --recv-keys E21C4F2E34FF2E93 ``` ---------------------------------------- TITLE: Requesting CKB Indexer Cells Capacity (JSON) DESCRIPTION: This JSON snippet demonstrates how to construct a request to the CKB Indexer's `get_cells_capacity` RPC method. It specifies the method name, RPC version, request ID, and the parameters, including the search key with script details (code hash, hash type, and args) and the script type ('lock'). SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_68 LANGUAGE: JSON CODE: ``` { "id": 2, "jsonrpc": "2.0", "method": "get_cells_capacity", "params": [ { "script": { "code_hash": "0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8", "hash_type": "type", "args": "0x5989ae415bb667931a99896e5fbbfad9ba53a223" }, "script_type": "lock" } ] } ``` ---------------------------------------- TITLE: Run CKB in Daemon Mode (Bash) DESCRIPTION: Runs the CKB node process in daemon mode, detaching it from the terminal. This mode is specifically for Linux/MacOS systems. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/devtools/init/README.md#_snippet_0 LANGUAGE: bash CODE: ``` ckb run --daemon ``` ---------------------------------------- TITLE: Running CKB with Rich-Indexer (PostgreSQL) DESCRIPTION: Command to start the CKB node with the Rich-Indexer configured to use an external PostgreSQL database. Requires the --rich-indexer flag and the PostgreSQL connection settings in ckb.toml. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/util/rich-indexer/README.md#_snippet_5 LANGUAGE: bash CODE: ``` ckb run -C --rich-indexer ``` ---------------------------------------- TITLE: Response estimate_fee_rate CKB RPC (JSON) DESCRIPTION: Example JSON response payload returned by the `estimate_fee_rate` RPC method. It includes the standard JSON-RPC fields: id, jsonrpc version, and the result which is the estimated fee rate as a hexadecimal string. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_54 LANGUAGE: json CODE: ``` { "id": 42, "jsonrpc": "2.0", "result": "0x3e8" } ``` ---------------------------------------- TITLE: Requesting Transaction Cycle Estimation (estimate_cycles) - JSON DESCRIPTION: Provides a sample JSON request body for the `estimate_cycles` RPC method. This method is used to estimate the execution cycles required for a given transaction. The request includes transaction details like cell dependencies, header dependencies, inputs, outputs, output data, version, and witnesses. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_43 LANGUAGE: json CODE: ``` { "id": 42, "jsonrpc": "2.0", "method": "estimate_cycles", "params": [ { "cell_deps": [ { "dep_type": "code", "out_point": { "index": "0x0", "tx_hash": "0xa4037a893eb48e18ed4ef61034ce26eba9c585f15c9cee102ae58505565eccc3" } } ], "header_deps": [ "0x7978ec7ce5b507cfb52e149e36b1a23f6062ed150503c85bbf825da3599095ed" ], "inputs": [ { "previous_output": { "index": "0x0", "tx_hash": "0x365698b50ca0da75dca2c87f9e7b563811d3b5813736b8cc62cc3b106faceb17" }, "since": "0x0" } ], "outputs": [ { "capacity": "0x2540be400", "lock": { "code_hash": "0x28e83a1277d48add8e72fadaa9248559e1b632bab2bd60b27955ebc4c03800a5", "hash_type": "data", "args": "0x" }, "type": null } ], "outputs_data": [ "0x" ], "version": "0x0", "witnesses": [] } ] } ``` ---------------------------------------- TITLE: Configuring CKB Rich-Indexer Filters (TOML) DESCRIPTION: Configuration settings for the CKB built-in indexer/rich-indexer, allowing customization of block and cell filtering rules and setting an initial tip hash for faster synchronization. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/util/rich-indexer/README.md#_snippet_1 LANGUAGE: toml CODE: ``` # CKB built-in indexer/rich-indexer settings. # Utilize the `ckb reset-data --indexer` and `ckb reset-data --rich-indexer` subcommands to efficiently clean existing indexes. [indexer_v2] # # Indexing the pending txs in the ckb tx-pool # index_tx_pool = false # # Customize block filtering rules to index only retained blocks block_filter = "block.header.number.to_uint() >= \"0x0\".to_uint()" # # Customize cell filtering rules to index only retained cells cell_filter = "let script = output.type;script!=() && script.code_hash == \"0x00000000000000000000000000000000000000000000000000545950455f4944\"" # # The initial tip can be set higher than the current indexer tip as the starting height for indexing. init_tip_hash = "0x8fbd0ec887159d2814cee475911600e3589849670f5ee1ed9798b38fdeef4e44" ``` ---------------------------------------- TITLE: RPC Request for send_test_transaction (JSON) DESCRIPTION: This JSON object represents the request payload for the `send_test_transaction` RPC method. It includes details like cell dependencies, header dependencies, inputs, outputs with lock scripts and capacities, outputs data, transaction version, and witnesses. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_85 LANGUAGE: json CODE: ``` { "id": 42, "jsonrpc": "2.0", "method": "send_test_transaction", "params": [ { "cell_deps": [ { "dep_type": "code", "out_point": { "index": "0x0", "tx_hash": "0xa4037a893eb48e18ed4ef61034ce26eba9c585f15c9cee102ae58505565eccc3" } } ], "header_deps": [ "0x7978ec7ce5b507cfb52e149e36b1a23f6062ed150503c85bbf825da3599095ed" ], "inputs": [ { "previous_output": { "index": "0x0", "tx_hash": "0x365698b50ca0da75dca2c87f9e7b563811d3b5813736b8cc62cc3b106faceb17" }, "since": "0x0" } ], "outputs": [ { "capacity": "0x2540be400", "lock": { "code_hash": "0x28e83a1277d48add8e72fadaa9248559e1b632bab2bd60b27955ebc4c03800a5", "hash_type": "data", "args": "0x" }, "type": null } ], "outputs_data": [ "0x" ], "version": "0x0", "witnesses": [] }, "passthrough" ] } ``` ---------------------------------------- TITLE: Response for Transaction Cycle Estimation (estimate_cycles) - JSON DESCRIPTION: Shows a sample JSON response from the `estimate_cycles` RPC method. The response contains the estimated number of cycles required for the transaction execution under the `result` field. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_44 LANGUAGE: json CODE: ``` { "id": 42, "jsonrpc": "2.0", "result": { "cycles": "0x219" } } ``` ---------------------------------------- TITLE: CKB Indexer Cells Capacity Response (JSON) DESCRIPTION: This JSON snippet shows an example response from the CKB Indexer's `get_cells_capacity` RPC method. It includes the RPC version, request ID, and the result object containing the indexed tip block hash, block number, and the total capacity of live cells matching the search criteria. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_69 LANGUAGE: JSON CODE: ``` { "jsonrpc": "2.0", "result": { "block_hash": "0xbc52444952dc5eb01a7826aaf6bb1b660db0179797414e259e7a6e6d636de8fc7c", "block_number": "0x5b727a", "capacity": "0xf0e8e4b4a0" }, "id": 2 } ``` ---------------------------------------- TITLE: Request get_indexer_tip CKB Indexer RPC (JSON) DESCRIPTION: Example JSON request payload for calling the `get_indexer_tip` RPC method within the Indexer module. It requests the current tip of the CKB indexer. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_55 LANGUAGE: json CODE: ``` { "id": 2, "jsonrpc": "2.0", "method": "get_indexer_tip" } ``` ---------------------------------------- TITLE: Successful get_block Response (with_cycles) - JSON DESCRIPTION: Example JSON response structure returned by the `get_block` RPC method when `with_cycles` is true, including the block data and transaction cycles. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_5 LANGUAGE: JSON CODE: ``` { "id": 42, "jsonrpc": "2.0", "result": { "block": " or \"0x...\"", "cycles": [] } } ``` ---------------------------------------- TITLE: Response get_indexer_tip CKB Indexer RPC (JSON) DESCRIPTION: Example JSON response payload returned by the `get_indexer_tip` RPC method. It provides the standard JSON-RPC fields and the result containing the block hash and block number of the indexed tip. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_56 LANGUAGE: json CODE: ``` { "jsonrpc": "2.0", "result": { "block_hash": "0x4959d6e764a2edc6038dbf03d61ebcc99371115627b186fdcccb2161fbd26edc", "block_number": "0x5b513e" }, "id": 2 } ``` ---------------------------------------- TITLE: Response for Get Transactions by Lock Script - CKB RPC - JSON DESCRIPTION: This JSON object represents the expected response from the CKB node for the `get_transactions` RPC call filtered by a lock script. It includes a `last_cursor` for pagination and an array of `objects`, where each object details a transaction input or output (`io_type`, `io_index`) associated with the queried script, along with its `block_number`, `tx_hash`, and `tx_index`. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_67 LANGUAGE: json CODE: ``` { "jsonrpc": "2.0", "result": { "last_cursor": "0x809bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8015989ae415bb667931a99896e5fbbfad9ba53a22300000000005b59df000000010000000101", "objects": [ { "block_number": "0x5b033a", "io_index": "0x0", "io_type": "output", "tx_hash": "0x556060b62d16386da53f8a4b458314dfa2d1988a7bcc5c96c3bb2a350a3453a1", "tx_index": "0x4" }, { "block_number": "0x5b0671", "io_index": "0x0", "io_type": "input", "tx_hash": "0x8205b2b4cd6380d7e332c7a5b49bf776a0322ba19f46dc6ca1f8c59f7daee08d", "tx_index": "0x1" }, { "block_number": "0x5b0671", "io_index": "0x1", "io_type": "output", "tx_hash": "0x8205b2b4cd6380d7e332c7a5b49bf776a0322ba19f46dc6ca1f8c59f7daee08d", "tx_index": "0x1" }, { "block_number": "0x5b0e6d", "io_index": "0x0", "io_type": "output", "tx_hash": "0xe8f2180dfba0cb15b45f771d520834515a5f8d7aa07f88894da88c22629b79e9", "tx_index": "0x1" }, { "block_number": "0x5b0e90", "io_index": "0x0", "io_type": "output", "tx_hash": "0xece3a27409bde2914fb7a1555d6bfca453ee46af73e665149ef549fd46ec1fc6", "tx_index": "0x1" }, { "block_number": "0x5b0ead", "io_index": "0x0", "io_type": "input", "tx_hash": "0x5c48768f91e3795b418c53211c76fd038c464a24c4aa7e35bbbb6ac5b219f581", "tx_index": "0x1" }, { "block_number": "0x5b0ead", "io_index": "0x1", "io_type": "output", "tx_hash": "0x5c48768f91e3795b418c53211c76fd038c464a24c4aa7e35bbbb6ac5b219f581", "tx_index": "0x1" }, { "block_number": "0x5b0eeb", "io_index": "0x0", "io_type": "output", "tx_hash": "0x90e6981d6a5692d92e54344dc0e12d213447710fa069cc19ddea874619b9ba48", "tx_index": "0x1" }, { "block_number": "0x5b0f8c", "io_index": "0x0", "io_type": "output", "tx_hash": "0x9ea14510219ae97afa0275215fa77c3c015905281c953a3917a7fd036767429c", "tx_index": "0x1" }, { "block_number": "0x5b5638", "io_index": "0x0", "io_type": "input", "tx_hash": "0x9346da4caa846cc035c182ecad0c17326a587983d25fb1e12a388f1a9c5c56b4", "tx_index": "0x1" }, { "block_number": "0x5b5638", "io_index": "0x1", "io_type": "input", "tx_hash": "0x9346da4caa846cc035c182ecad0c17326a587983d25fb1e12a388f1a9c5c56b4", "tx_index": "0x1" }, { "block_number": "0x5b5638", "io_index": "0x1", "io_type": "output", "tx_hash": "0x9346da4caa846cc035c182ecad0c17326a587983d25fb1e12a388f1a9c5c56b4", "tx_index": "0x1" }, { "block_number": "0x5b5638", "io_index": "0x2", "io_type": "input", "tx_hash": "0x9346da4caa846cc035c182ecad0c17326a587983d25fb1e12a388f1a9c5c56b4", "tx_index": "0x1" }, { "block_number": "0x5b59c2", "io_index": "0x0", "io_type": "input", "tx_hash": "0x5b58f90fb3309333bf0bec878f3a05038c7fe816747300ecdac37a9da76c4128", "tx_index": "0x1" }, { "block_number": "0x5b59c2", "io_index": "0x1", "io_type": "output", "tx_hash": "0x5b58f90fb3309333bf0bec878f3a05038c7fe816747300ecdac37a9da76c4128", "tx_index": "0x1" }, { "block_number": "0x5b59cc", "io_index": "0x0", "io_type": "input", "tx_hash": "0x57ca2822c28e02b199424a731b2efd2c9bf752f07b7309f555f2e71abe83ba26", "tx_index": "0x1" }, { "block_number": "0x5b59cc", "io_index": "0x1", "io_type": "input", "tx_hash": "0x57ca2822c28e02b199424a731b2efd2c9bf752f07b7309f555f2e71abe83ba26", "tx_index": "0x1" }, { "block_number": "0x5b59cc", "io_index": "0x1", "io_type": "output", "tx_hash": "0x57ca2822c28e02b199424a731b2efd2c9bf752f07b7309f555f2e71abe83ba26", "tx_index": "0x1" } ``` ---------------------------------------- TITLE: test_tx_pool_accept RPC (JSON) - Error Response DESCRIPTION: This JSON object illustrates an error response from the `test_tx_pool_accept` RPC method when the transaction pool check fails. It includes an `error` object with a `code`, `data`, and `message` detailing the reason for rejection, such as a duplicated transaction. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_109 LANGUAGE: json CODE: ``` { "id": 42, "jsonrpc": "2.0", "result": null, "error": { "code": -1107, "data": "Duplicated(Byte32(0xa0ef4eb5f4ceeb08a4c8524d84c5da95dce2f608e0ca2ec8091191b0f330c6e3))", "message": "PoolRejectedDuplicatedTransaction: Transaction(Byte32(0xa0ef4eb5f4ceeb08a4c8524d84c5da95dce2f608e0ca2ec8091191b0f330c6e3)) already exists in transaction_pool" } } ``` ---------------------------------------- TITLE: test_tx_pool_accept RPC (JSON) - Success Response DESCRIPTION: This JSON object shows a successful response from the `test_tx_pool_accept` RPC method. It returns the calculated `cycles` and `fee` for the transaction if it passes the pool checks. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_108 LANGUAGE: json CODE: ``` { "id": 42, "jsonrpc": "2.0", "result": { "cycles": "0x219", "fee": "0x2a66f36e90" } } ``` ---------------------------------------- TITLE: Response get_transaction_proof JSON DESCRIPTION: Example JSON RPC response for a successful `get_transaction_proof` call. It returns a `TransactionProof` object containing the block hash, the proof structure (indices and lemmas), and the witnesses root. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_29 LANGUAGE: JSON CODE: ``` { "id": 42, "jsonrpc": "2.0", "result": { "block_hash": "0x7978ec7ce5b507cfb52e149e36b1a23f6062ed150503c85bbf825da3599095ed", "proof": { "indices": [ "0x0" ], "lemmas": [] }, "witnesses_root": "0x2bb631f4a251ec39d943cc238fc1e39c7f0e99776e8a1e7be28a03c70c4f4853" } } ``` ---------------------------------------- TITLE: Response Format for get_block_by_number (Verbosity 0, JSON) DESCRIPTION: Example JSON response format for the `get_block_by_number` RPC method when `verbosity` is 0, returning the block serialized by molecule as a 0x-prefixed hex string. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_8 LANGUAGE: json CODE: ``` { "id": 42, "jsonrpc": "2.0", "result": "0x..." } ``` ---------------------------------------- TITLE: Get Transaction and Witness Proof RPC Request (JSON) DESCRIPTION: Example JSON RPC request payload for the `get_transaction_and_witness_proof` method. It takes an array of transaction hashes and an optional block hash to generate a Merkle proof. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_32 LANGUAGE: json CODE: ``` { "id": 42, "jsonrpc": "2.0", "method": "get_transaction_and_witness_proof", "params": [ [ "0xa4037a893eb48e18ed4ef61034ce26eba9c585f15c9cee102ae58505565eccc3" ] ] } ``` ---------------------------------------- TITLE: Request get_transaction_proof JSON DESCRIPTION: Example JSON RPC request to generate a Merkle proof for specific transactions within a block using the `get_transaction_proof` method. It takes an array of transaction hashes as a parameter. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_28 LANGUAGE: JSON CODE: ``` { "id": 42, "jsonrpc": "2.0", "method": "get_transaction_proof", "params": [ [ "0xa4037a893eb48e18ed4ef61034ce26eba9c585f15c9cee102ae58505565eccc3" ] ] } ``` ---------------------------------------- TITLE: Requesting Header by Hash (JSON) DESCRIPTION: JSON request payload for the `get_header` RPC method, querying a block header using its hash. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_10 LANGUAGE: json CODE: ``` { "id": 42, "jsonrpc": "2.0", "method": "get_header", "params": [ "0xa5f5c85987a15de25661e5a214f2c1449cd803f071acc7999820f25246471f40" ] } ``` ---------------------------------------- TITLE: get_raw_tx_pool RPC Result (JSON Response) DESCRIPTION: Example JSON response received after calling the `get_raw_tx_pool` RPC method with `verbose=true`, showing detailed information for transactions in the pending pool. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_119 LANGUAGE: JSON CODE: ``` { "id": 42, "jsonrpc": "2.0", "result": { "pending": { "0xa0ef4eb5f4ceeb08a4c8524d84c5da95dce2f608e0ca2ec8091191b0f330c6e3": { "cycles": "0x219", "size": "0x112", "fee": "0x16923f7dcf", "ancestors_size": "0x112", "ancestors_cycles": "0x219", "ancestors_count": "0x1", "timestamp": "0x17c983e6e44" } }, "conflicted": [], "proposed": {} } } ``` ---------------------------------------- TITLE: Successful get_block Response (verbosity 0) - JSON DESCRIPTION: Example JSON response structure returned by the `get_block` RPC method when `verbosity` is 0, showing the block serialized by molecule as a 0x-prefixed hex string. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_4 LANGUAGE: JSON CODE: ``` { "id": 42, "jsonrpc": "2.0", "result": "0x..." } ``` ---------------------------------------- TITLE: sync_state RPC Method - JSON Response DESCRIPTION: Example JSON RPC response for a successful call to the `sync_state` method. The result field contains an object detailing the node's synchronization status, including tip hash, block numbers, and IBD state. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_96 LANGUAGE: json CODE: ``` { "id": 42, "jsonrpc": "2.0", "result": { "assume_valid_target": "0x0000000000000000000000000000000000000000000000000000000000000000", "assume_valid_target_reached": true, "best_known_block_number": "0x400", "best_known_block_timestamp": "0x5cd2b117", "fast_time": "0x3e8", "ibd": true, "inflight_blocks_count": "0x0", "low_time": "0x5dc", "min_chain_work": "0x0", "min_chain_work_reached": true, "normal_time": "0x4e2", "orphan_blocks_count": "0x0", "tip_hash": "0xa5f5c85987a15de25661e5a214f2c1449cd803f071acc7999820f25246471f40", "tip_number": "0x400", "unverified_tip_hash": "0xa5f5c85987a15de25661e5a214f2c1449cd803f071acc7999820f25246471f40", "unverified_tip_number": "0x400" } } ``` ---------------------------------------- TITLE: get_pool_tx_detail_info RPC Result (JSON Response) DESCRIPTION: Example JSON response received after calling the `get_pool_tx_detail_info` RPC method, providing detailed information about a specific transaction in the pool. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_121 LANGUAGE: JSON CODE: ``` { "jsonrpc": "2.0", "result": { "ancestors_count": "0x0", "descendants_count": "0x0", "entry_status": "pending", "pending_count": "0x1", "proposed_count": "0x0", "rank_in_pending": "0x1", "score_sortkey": { "ancestors_fee": "0x16923f7dcf", "ancestors_weight": "0x112", "fee": "0x16923f7dcf", "weight": "0x112" }, "timestamp": "0x18aa1baa54c" }, "id": 42 } ``` ---------------------------------------- TITLE: Calling set_network_active RPC Method - JSON Request DESCRIPTION: Example JSON RPC request to call the `set_network_active` method. This method enables or disables all P2P network activity. The example shows disabling the network by passing `false`. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_97 LANGUAGE: json CODE: ``` { "id": 42, "jsonrpc": "2.0", "method": "set_network_active", "params": [ false ] } ``` ---------------------------------------- TITLE: Calling add_node RPC Method - JSON Request DESCRIPTION: Example JSON RPC request to call the `add_node` method. This method attempts to add a node to the peers list and connect to it, using the node's peer ID and address. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_99 LANGUAGE: json CODE: ``` { "id": 42, "jsonrpc": "2.0", "method": "add_node", "params": [ "QmUsZHPbjjzU627UZFt4k8j6ycEcNvXRnVGxCPKqwbAfQS", "/ip4/192.168.2.100/tcp/8114" ] } ``` ---------------------------------------- TITLE: Calling set_ban RPC Method - JSON Request DESCRIPTION: Example JSON RPC request to call the `set_ban` method. This method is used to insert or delete an IP/subnet from the banned list. The example shows inserting a single IP with an absolute ban time and reason. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_93 LANGUAGE: json CODE: ``` { "id": 42, "jsonrpc": "2.0", "method": "set_ban", "params": [ "192.168.0.2", "insert", "0x1ac89236180", true, "set_ban example" ] } ``` ---------------------------------------- TITLE: RPC Response: get_block_median_time (JSON) DESCRIPTION: This JSON object shows a sample response from the 'get_block_median_time' RPC method, returning the median time (as a Uint64 hex string) for the specified block and its preceding 36 blocks on the canonical chain. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_42 LANGUAGE: json CODE: ``` { "id": 42, "jsonrpc": "2.0", "result": "0x5cd2b105" } ``` ---------------------------------------- TITLE: Request get_epoch_by_number JSON DESCRIPTION: Example JSON RPC request to retrieve epoch information by its number using the `get_epoch_by_number` method. It specifies the method name and the epoch number ('0x0') as a parameter. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_24 LANGUAGE: JSON CODE: ``` { "id": 42, "jsonrpc": "2.0", "method": "get_epoch_by_number", "params": [ "0x0" ] } ``` ---------------------------------------- TITLE: RPC Request: generate_block_with_template (JSON) DESCRIPTION: This JSON object represents a request payload for the `generate_block_with_template` RPC method. It includes various parameters defining the block template, such as bytes limit, cellbase details, compact target, current time, cycles limit, DAO, epoch, extension, number, parent hash, proposals, transactions, uncles, uncles count limit, version, and work ID. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_81 LANGUAGE: json CODE: ``` { "id": 42, "jsonrpc": "2.0", "method": "generate_block_with_template", "params": [ { "bytes_limit": "0x91c08", "cellbase": { "cycles": null, "data": { "cell_deps": [], "header_deps": [], "inputs": [ { "previous_output": { "index": "0xffffffff", "tx_hash": "0x0000000000000000000000000000000000000000000000000000000000000000" }, "since": "0x401" } ], "outputs": [ { "capacity": "0x18e64efc04", "lock": { "code_hash": "0x28e83a1277d48add8e72fadaa9248559e1b632bab2bd60b27955ebc4c03800a5", "hash_type": "data", "args": "0x" }, "type": null } ], "outputs_data": [ "0x" ], "version": "0x0", "witnesses": [ "0x650000000c00000055000000490000001000000030000000310000001892ea40d82b53c678ff88312450bbb17e164d7a3e0a90941aa58839f56f8df20114000000b2e61ff569acf041b3c2c17724e2379c581eeac30c00000054455354206d657373616765" ] }, "hash": "0xbaf7e4db2fd002f19a597ca1a31dfe8cfe26ed8cebc91f52b75b16a7a5ec8bab" }, "compact_target": "0x1e083126", "current_time": "0x174c45e17a3", "cycles_limit": "0xd09dc300", "dao": "0xd495a106684401001e47c0ae1d5930009449d26e32380000000721efd0030000", "epoch": "0x7080019000001", "extension": "0xb0a0079f3778c0ba0d89d88b389c602cc18b8a0355d16c0713f8bfcee64b5f84", "number": "0x401", "parent_hash": "0xa5f5c85987a15de25661e5a214f2c1449cd803f071acc7999820f25246471f40", "proposals": ["0xa0ef4eb5f4ceeb08a4c8"], "transactions": [], "uncles": [ { "hash": "0xdca341a42890536551f99357612cef7148ed471e3b6419d0844a4e400be6ee94", "header": { "compact_target": "0x1e083126", "dao": "0xb5a3e047474401001bc476b9ee573000c0c387962a38000000febffacf030000", "epoch": "0x7080018000001", "extra_hash": "0x0000000000000000000000000000000000000000000000000000000000000000", "nonce": "0x0", "number": "0x400", "parent_hash": "0xae003585fa15309b30b31aed3dcf385e9472c3c3e93746a6c4540629a6a1ed2d", "proposals_hash": "0x0000000000000000000000000000000000000000000000000000000000000000", "timestamp": "0x5cd2b118", "transactions_root": "0xc47d5b78b3c4c4c853e2a32810818940d0ee403423bea9ec7b8e566d9595206c", "version":"0x0" }, "proposals": [], "required": false } ], "uncles_count_limit": "0x2", "version": "0x0", "work_id": "0x0" } ] } ``` ---------------------------------------- TITLE: Configure EaglesongBlake2b PoW Engine (TOML) DESCRIPTION: Sets the Proof-of-Work function to 'EaglesongBlake2b'. This variant is commonly used for the testnet (Pudge) and requires corresponding miner worker configuration. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/docs/configure.md#_snippet_4 LANGUAGE: TOML CODE: ``` [pow] func = "EaglesongBlake2b" ``` ---------------------------------------- TITLE: CKB Indexer get_cells RPC Request - Filter by Script Length DESCRIPTION: Demonstrates a get_cells RPC request to retrieve cells locked by a specific script, filtering for cells where the type script length is within the range [0, 1), effectively finding cells with no type script. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_62 LANGUAGE: json CODE: ``` { "id": 2, "jsonrpc": "2.0", "method": "get_cells", "params": [ { "script": { "code_hash": "0x58c5f491aba6d61678b7cf7edf4910b1f5e00ec0cde2f42e0abb4fd9aff25a63", "hash_type": "type", "args": "0x2a49720e721553d0614dff29454ee4e1f07d0707" }, "script_type": "lock", "filter": { "script_len_range": ["0x0", "0x1"] } }, "asc", "0x64" ] } ``` ---------------------------------------- TITLE: Calling tx_pool_info RPC (JSON) - Request DESCRIPTION: This JSON object represents a request to the `tx_pool_info` RPC method. This method requires no parameters and is used to retrieve current information about the transaction pool. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_112 LANGUAGE: json CODE: ``` { "id": 42, "jsonrpc": "2.0", "method": "tx_pool_info", "params": [] } ``` ---------------------------------------- TITLE: Response get_epoch_by_number JSON DESCRIPTION: Example JSON RPC response for a successful `get_epoch_by_number` call. It returns an `EpochView` object containing details like compact target, length, number, and start number for the requested epoch. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_25 LANGUAGE: JSON CODE: ``` { "id": 42, "jsonrpc": "2.0", "result": { "compact_target": "0x20010000", "length": "0x3e8", "number": "0x0", "start_number": "0x0" } } ``` ---------------------------------------- TITLE: Calling get_pool_tx_detail_info RPC (JSON Request) DESCRIPTION: Example JSON request payload to invoke the `get_pool_tx_detail_info` RPC method, querying details for a specific transaction hash in the pool. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_120 LANGUAGE: JSON CODE: ``` { "id": 42, "jsonrpc": "2.0", "method": "get_pool_tx_detail_info", "params": [ "0xa0ef4eb5f4ceeb08a4c8524d84c5da95dce2f608e0ca2ec8091191b0f330c6e3" ] } ``` ---------------------------------------- TITLE: Requesting calculate_dao_maximum_withdraw RPC (JSON) DESCRIPTION: This JSON object represents a request to the `calculate_dao_maximum_withdraw` RPC method. It provides an `out_point` referencing a DAO cell and a `kind` parameter (a block hash in this example) to calculate the maximum withdrawal amount. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_51 LANGUAGE: JSON CODE: ``` { "id": 42, "jsonrpc": "2.0", "method": "calculate_dao_maximum_withdraw", "params": [ { "index": "0x0", "tx_hash": "0xa4037a893eb48e18ed4ef61034ce26eba9c585f15c9cee102ae58505565eccc3" }, "0xa5f5c85987a15de25661e5a214f2c1449cd803f071acc7999820f25246471f40" ] } ``` ---------------------------------------- TITLE: Header Response by Hash (Text, Verbosity 0) DESCRIPTION: Text response payload for the `get_header` RPC method when verbosity is 0, showing a simplified result as a hex string. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_12 LANGUAGE: text CODE: ``` { "id": 42, "jsonrpc": "2.0", "result": "0x..." } ``` ---------------------------------------- TITLE: Receiving Block Hash - CKB RPC - JSON DESCRIPTION: Shows a JSON RPC response from the `get_block_hash` method. The `result` field contains the 0x-prefixed hex-encoded hash of the requested block if found, or null otherwise. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_23 LANGUAGE: json CODE: ``` { "id": 42, "jsonrpc": "2.0", "result": "0xa5f5c85987a15de25661e5a214f2c1449cd803f071acc7999820f25246471f40" } ``` ---------------------------------------- TITLE: MainLoggerConfig Filter Examples DESCRIPTION: Provides examples for configuring the `filter` field of the `MainLoggerConfig`, demonstrating how to set log levels globally or specifically for different CKB modules using a comma-separated string. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_148 LANGUAGE: Text CODE: ``` info ``` LANGUAGE: Text CODE: ``` info,ckb-rpc=debug,ckb-sync=debug,ckb-relay=debug,ckb-tx-pool=debug,ckb-network=debug ``` ---------------------------------------- TITLE: CKB RPC Subscribe Response - JSON DESCRIPTION: Example JSON response received after successfully subscribing to a CKB RPC topic. The `result` field contains the subscription ID, which is a string. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_132 LANGUAGE: json CODE: ``` { "id": 42, "jsonrpc": "2.0", "result": "0xf3" } ``` ---------------------------------------- TITLE: Request get_block_economic_state JSON DESCRIPTION: Example JSON RPC request to retrieve the economic state of a specific block using the `get_block_economic_state` method. It includes the block hash as a parameter. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_26 LANGUAGE: JSON CODE: ``` { "id": 42, "jsonrpc": "2.0", "method": "get_block_economic_state", "params": [ "0x02530b25ad0ff677acc365cb73de3e8cc09c7ddd58272e879252e199d08df83b" ] } ``` ---------------------------------------- TITLE: Response get_block_economic_state JSON DESCRIPTION: Example JSON RPC response for a successful `get_block_economic_state` call. It returns details about the block's economic state, including issuance, miner reward breakdown, and transaction fees. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_27 LANGUAGE: JSON CODE: ``` { "id": 42, "jsonrpc": "2.0", "result": { "finalized_at": "0xa5f5c85987a15de25661e5a214f2c1449cd803f071acc7999820f25246471f40", "issuance": { "primary": "0x18ce922bca", "secondary": "0x7f02ec655" }, "miner_reward": { "committed": "0x0", "primary": "0x18ce922bca", "proposal": "0x0", "secondary": "0x17b93605" }, "txs_fee": "0x0" } } ``` ---------------------------------------- TITLE: Start CKB Miner (shell) DESCRIPTION: Starts the CKB miner process. This command requires the miner lock to be configured in `ckb.toml` and the `ckb run` process to be active. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/docs/quick-start.md#_snippet_4 LANGUAGE: shell CODE: ``` ckb miner ``` ---------------------------------------- TITLE: Generate CKB Block RPC Request (JSON) DESCRIPTION: JSON RPC request payload to call the `generate_block` method, which generates a new block and broadcasts it. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_74 LANGUAGE: json CODE: ``` { "id": 42, "jsonrpc": "2.0", "method": "generate_block", "params": [] } ``` ---------------------------------------- TITLE: Configure CKB Logger Filter - Specific Debug (Text) DESCRIPTION: Example configuration string for the `filter` field of `ExtraLoggerConfig`. Sets the log level to 'debug' for specified modules (rpc, sync, relay, tx-pool, network) and 'info' for all other modules. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_145 LANGUAGE: text CODE: ``` info,ckb-rpc=debug,ckb-sync=debug,ckb-relay=debug,ckb-tx-pool=debug,ckb-network=debug ``` ---------------------------------------- TITLE: Example JSON for EpochView DESCRIPTION: This JSON snippet provides an example representation of the EpochView structure, showing the format and typical values for its fields. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_143 LANGUAGE: JSON CODE: ``` { "compact_target": "0x1e083126", "length": "0x708", "number": "0x1", "start_number": "0x3e8" } ``` ---------------------------------------- TITLE: Header Response by Number (Text, Verbosity 0) DESCRIPTION: Text response payload for the `get_header_by_number` RPC method when verbosity is 0, showing a simplified result as a hex string. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_15 LANGUAGE: text CODE: ``` { "id": 42, "jsonrpc": "2.0", "result": "0x..." } ``` ---------------------------------------- TITLE: Enable CKB miner service on boot DESCRIPTION: Configures the systemd service for the CKB miner to automatically start when the system boots. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/devtools/init/linux-systemd/README.md#_snippet_8 LANGUAGE: bash CODE: ``` sudo systemctl enable ckb-miner.service ``` ---------------------------------------- TITLE: Stop CKB Daemon Process (Bash) DESCRIPTION: Sends a signal to the running CKB daemon process to stop it gracefully. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/devtools/init/README.md#_snippet_2 LANGUAGE: bash CODE: ``` ckb daemon --stop ``` ---------------------------------------- TITLE: CKB Indexer get_cells RPC Response - Filter by Script Length DESCRIPTION: An example response for a get_cells request filtered by script length, showing a cell object where the 'type' field is null, indicating no type script. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_63 LANGUAGE: json CODE: ``` { "jsonrpc": "2.0", "result": { "last_cursor": "0x4058c5f491aba6d61678b7cf7edf4910b1f5e00ec0cde2f42e0abb4fd9aff25a63012a49720e721553d0614dff29454ee4e1f07d070700000000002adf830000000200000001", "objects": [ { "block_number": "0x2adf83", "out_point": { "index": "0x1", "tx_hash": "0x23ec897027c1d2a2b39e2446162bac182f18581be048cb3896ad695559b6839e" }, "output": { "capacity": "0x54b42b70b4", "lock": { "args": "0x2a49720e721553d0614dff29454ee4e1f07d0707", "code_hash": "0x58c5f491aba6d61678b7cf7edf4910b1f5e00ec0cde2f42e0abb4fd9aff25a63", "hash_type": "type" }, "type": null }, "output_data": "0x", "tx_index": "0x2" } ] }, "id": 2 } ``` ---------------------------------------- TITLE: Response for get_fork_block (JSON) DESCRIPTION: Example JSON response received from the `get_fork_block` RPC method. It contains detailed information about the requested block, including header, transactions, and uncles. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_37 LANGUAGE: json CODE: ``` { "id": 42, "jsonrpc": "2.0", "result": { "header": { "compact_target": "0x1e083126", "dao": "0xb5a3e047474401001bc476b9ee573000c0c387962a38000000febffacf030000", "epoch": "0x7080018000001", "extra_hash": "0x0000000000000000000000000000000000000000000000000000000000000000", "hash": "0xdca341a42890536551f99357612cef7148ed471e3b6419d0844a4e400be6ee94", "nonce": "0x0", "number": "0x400", "parent_hash": "0xae003585fa15309b30b31aed3dcf385e9472c3c3e93746a6c4540629a6a1ed2d", "proposals_hash": "0x0000000000000000000000000000000000000000000000000000000000000000", "timestamp": "0x5cd2b118", "transactions_root": "0xc47d5b78b3c4c4c853e2a32810818940d0ee403423bea9ec7b8e566d9595206c", "version": "0x0" }, "proposals": [], "transactions": [ { "cell_deps": [], "hash": "0x365698b50ca0da75dca2c87f9e7b563811d3b5813736b8cc62cc3b106faceb17", "header_deps": [], "inputs": [ { "previous_output": { "index": "0xffffffff", "tx_hash": "0x0000000000000000000000000000000000000000000000000000000000000000" }, "since": "0x400" } ], "outputs": [ { "capacity": "0x18e64b61cf", "lock": { "code_hash": "0x28e83a1277d48add8e72fadaa9248559e1b632bab2bd60b27955ebc4c03800a5", "hash_type": "data", "args": "0x" }, "type": null } ], "outputs_data": [ "0x" ], "version": "0x0", "witnesses": [ "0x450000000c000000410000003500000010000000300000003100000028e83a1277d48add8e72fadaa9248559e1b632bab2bd60b27955ebc4c03800a5000000000000000000" ] } ], "uncles": [] } } ``` ---------------------------------------- TITLE: Configuring CKB Rich-Indexer for PostgreSQL (TOML) DESCRIPTION: Configuration settings in ckb.toml to specify connection parameters for using a PostgreSQL database with the CKB Rich-Indexer instead of the default SQLite. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/util/rich-indexer/README.md#_snippet_4 LANGUAGE: toml CODE: ``` # CKB rich-indexer has its unique configuration. [indexer_v2.rich_indexer] # By default, it uses an embedded SQLite database. # Alternatively, you can set up a PostgreSQL database service and provide the connection parameters. db_type = "postgres" db_name = "ckb-rich-indexer" db_host = "127.0.0.1" db_port = 5432 db_user = "postgres" db_password = "123456" ``` ---------------------------------------- TITLE: RPC Response: get_consensus (JSON) DESCRIPTION: This JSON object shows a sample response from the 'get_consensus' RPC method, containing various consensus parameters like block versions, epoch durations, genesis hash, hardfork features, rewards, and softfork details. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_40 LANGUAGE: json CODE: ``` { "id": 42, "jsonrpc": "2.0", "result": { "block_version": "0x0", "cellbase_maturity": "0x10000000000", "dao_type_hash": "0x0000000000000000000000000000000000000000000000000000000000000000", "epoch_duration_target": "0x3840", "genesis_hash": "0x7978ec7ce5b507cfb52e149e36b1a23f6062ed150503c85bbf825da3599095ed", "hardfork_features": [ { "rfc": "0028", "epoch_number": "0x1526" }, { "rfc": "0029", "epoch_number": "0x0" }, { "rfc": "0030", "epoch_number": "0x0" }, { "rfc": "0031", "epoch_number": "0x0" }, { "rfc": "0032", "epoch_number": "0x1526" }, { "rfc": "0036", "epoch_number": "0x0" }, { "rfc": "0038", "epoch_number": "0x0" }, { "rfc": "0048", "epoch_number": "0x3005" }, { "rfc": "0049", "epoch_number": "0x3005" } ], "id": "main", "initial_primary_epoch_reward": "0x71afd498d000", "max_block_bytes": "0x91c08", "max_block_cycles": "0xd09dc300", "max_block_proposals_limit": "0x5dc", "max_uncles_num": "0x2", "median_time_block_count": "0x25", "orphan_rate_target": { "denom": "0x28", "numer": "0x1" }, "permanent_difficulty_in_dummy": false, "primary_epoch_reward_halving_interval": "0x2238", "proposer_reward_ratio": { "denom": "0xa", "numer": "0x4" }, "secondary_epoch_reward": "0x37d0c8e28542", "secp256k1_blake160_multisig_all_type_hash": null, "secp256k1_blake160_sighash_all_type_hash": null, "softforks": { "testdummy": { "status": "rfc0043", "rfc0043": { "bit": 1, "min_activation_epoch": "0x0", "period": "0xa", "start": "0x0", "threshold": { "denom": "0x4", "numer": "0x3" }, "timeout": "0x0" } } }, "tx_proposal_window": { "closest": "0x2", "farthest": "0xa" }, "tx_version": "0x0", "type_id_code_hash": "0x00000000000000000000000000000000000000000000000000545950455f4944" } } ``` ---------------------------------------- TITLE: remove_transaction RPC (JSON) - Response DESCRIPTION: This JSON object shows the response from the `remove_transaction` RPC method. The `result` field is a boolean indicating whether the transaction was found and removed (`true`) or not (`false`). SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_111 LANGUAGE: json CODE: ``` { "id": 42, "jsonrpc": "2.0", "result": true } ``` ---------------------------------------- TITLE: Calling remove_transaction RPC (JSON) - Request DESCRIPTION: This JSON object is a request to the `remove_transaction` RPC method. It takes a single parameter, the `tx_hash`, which is the hash of the transaction to be removed from the transaction pool. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_110 LANGUAGE: json CODE: ``` { "id": 42, "jsonrpc": "2.0", "method": "remove_transaction", "params": [ "0xa0ef4eb5f4ceeb08a4c8524d84c5da95dce2f608e0ca2ec8091191b0f330c6e3" ] } ``` ---------------------------------------- TITLE: Calling clear_tx_pool RPC (JSON) - Request DESCRIPTION: This JSON object is a request to the `clear_tx_pool` RPC method. This method takes no parameters and is used to remove all transactions currently in the transaction pool. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_114 LANGUAGE: json CODE: ``` { "id": 42, "jsonrpc": "2.0", "method": "clear_tx_pool", "params": [] } ``` ---------------------------------------- TITLE: Calling tx_pool_ready RPC (JSON Request) DESCRIPTION: Example JSON request payload to invoke the `tx_pool_ready` RPC method, which checks if the transaction pool service is ready. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_122 LANGUAGE: JSON CODE: ``` { "id": 42, "jsonrpc": "2.0", "method": "tx_pool_ready", "params": [] } ``` ---------------------------------------- TITLE: Block Filter Response by Hash (Text, Non-Null Result) DESCRIPTION: Text response payload for the `get_block_filter` RPC method when a block filter is found, showing the data and hash. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_18 LANGUAGE: text CODE: ``` { "id": 42, "jsonrpc": "2.0", "result": { "data": "0x...", "hash": "0x..." } } ``` ---------------------------------------- TITLE: Install and configure CKB binary DESCRIPTION: Copies the CKB binary to a system directory and sets appropriate ownership and permissions for execution. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/devtools/init/linux-systemd/README.md#_snippet_0 LANGUAGE: bash CODE: ``` sudo cp /path/to/ckb /usr/local/bin sudo chown root:root /usr/local/bin/ckb sudo chmod 755 /usr/local/bin/ckb ``` ---------------------------------------- TITLE: Requesting Block Filter by Hash (JSON) DESCRIPTION: JSON request payload for the `get_block_filter` RPC method, querying a block filter using its block hash. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_16 LANGUAGE: json CODE: ``` { "id": 42, "jsonrpc": "2.0", "method": "get_block_filter", "params": [ "0xa5f5c85987a15de25661e5a214f2c1449cd803f071acc7999820f25246471f40" ] } ``` ---------------------------------------- TITLE: Response get_deployments_info RPC (JSON) DESCRIPTION: Example JSON response payload returned by the `get_deployments_info` RPC method. It includes the current epoch, block hash, and detailed information about various deployments, including their state and threshold. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_127 LANGUAGE: json CODE: ``` { "id": 42, "jsonrpc": "2.0", "result": { "epoch": "0x1", "hash": "0xa5f5c85987a15de25661e5a214f2c1449cd803f071acc7999820f25246471f40", "deployments": { "testdummy": { "bit": 1, "min_activation_epoch": "0x0", "period": "0xa", "since": "0x0", "start": "0x0", "state": "failed", "timeout": "0x0", "threshold": { "numer": "0x3", "denom": "0x4" } } } } } ``` ---------------------------------------- TITLE: Response JSON for get_block_template DESCRIPTION: Example JSON-RPC response payload returned by the `get_block_template` method. It contains a detailed block template including limits, cellbase transaction structure, target, time, epoch, parent hash, and other block components. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_88 LANGUAGE: json CODE: ``` { "id": 42, "jsonrpc": "2.0", "result": { "bytes_limit": "0x91c08", "cellbase": { "cycles": null, "data": { "cell_deps": [], "header_deps": [], "inputs": [ { "previous_output": { "index": "0xffffffff", "tx_hash": "0x0000000000000000000000000000000000000000000000000000000000000000" }, "since": "0x401" } ], "outputs": [ { "capacity": "0x18e64efc04", "lock": { "code_hash": "0x28e83a1277d48add8e72fadaa9248559e1b632bab2bd60b27955ebc4c03800a5", "hash_type": "data", "args": "0x" }, "type": null } ], "outputs_data": [ "0x" ], "version": "0x0", "witnesses": [ "0x6a0000000c00000055000000490000001000000030000000310000001892ea40d82b53c678ff88312450bbb17e164d7a3e0a90941aa58839f56f8df20114000000b2e61ff569acf041b3c2c17724e2379c581eeac311000000000000002054455354206d657373616765" ] }, "hash": "0xbaf7e4db2fd002f19a597ca1a31dfe8cfe26ed8cebc91f52b75b16a7a5ec8bab" }, "compact_target": "0x1e083126", "current_time": "0x174c45e17a3", "cycles_limit": "0xd09dc300", "dao": "0xd495a106684401001e47c0ae1d5930009449d26e32380000000721efd0030000", "epoch": "0x7080019000001", "extension": "0xb0a0079f3778c0ba0d89d88b389c602cc18b8a0355d16c0713f8bfcee64b5f84", "number": "0x401", "parent_hash": "0xa5f5c85987a15de25661e5a214f2c1449cd803f071acc7999820f25246471f40", "proposals": ["0xa0ef4eb5f4ceeb08a4c8"], "transactions": [], "uncles": [ { "hash": "0xdca341a42890536551f99357612cef7148ed471e3b6419d0844a4e400be6ee94", "header": { "compact_target": "0x1e083126", "dao": "0xb5a3e047474401001bc476b9ee573000c0c387962a38000000febffacf030000", "epoch": "0x7080018000001", "extra_hash": "0x0000000000000000000000000000000000000000000000000000000000000000", "nonce": "0x0", "number": "0x400", "parent_hash": "0xae003585fa15309b30b31aed3dcf385e9472c3c3e93746a6c4540629a6a1ed2d", "proposals_hash": "0x0000000000000000000000000000000000000000000000000000000000000000", "timestamp": "0x5cd2b118", "transactions_root": "0xc47d5b78b3c4c4c853e2a32810818940d0ee403423bea9ec7b8e566d9595206c", "version":"0x0" }, "proposals": [], "required": false } ], "uncles_count_limit": "0x2", "version": "0x0", "work_id": "0x0" } } ``` ---------------------------------------- TITLE: Run Multiple CKB Nodes (Shell) DESCRIPTION: Demonstrates how to set up and run two CKB nodes simultaneously, each with its own configuration directory and using the dev chain with a shared genesis message. Requires manual editing of config files to change ports and potentially add bootnodes. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/docs/configure.md#_snippet_8 LANGUAGE: Shell CODE: ``` mkdir node1 node2 ckb -C node1 init --chain dev --genesis-message dev-genesis ckb -C node2 init --chain dev --genesis-message dev-genesis # Change listen ports 8114/8115 to 8116/8117 in node2/ckb.toml. # Change `rpc_url` in node2/ckb.toml to use 8116. # start node1 ckb -C node1 run # If you want node2 connects node1, copy the P2P address of node1 in its log. # Add the address into the section `bootnodes` in `node2/ckb.toml`. # start node2 ckb -C node2 run ``` ---------------------------------------- TITLE: Calling remove_node RPC Method - JSON Request DESCRIPTION: Example JSON RPC request to call the `remove_node` method. This method attempts to remove a node from the peers list and disconnect from it, using the node's peer ID. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_101 LANGUAGE: json CODE: ``` { "id": 42, "jsonrpc": "2.0", "method": "remove_node", "params": [ "QmUsZHPbjjzU627UZFt4k8j6ycEcNvXRnVGxCPKqwbAfQS" ] } ``` ---------------------------------------- TITLE: Generating CKB Peer IDs via Command Line DESCRIPTION: This snippet shows how to use the `ckb peer-id` subcommand to generate a new peer ID and derive one from a secret file. It requires the CKB executable to be installed and available in the system's PATH. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/CHANGELOG.md#_snippet_0 LANGUAGE: Shell CODE: ``` ckb peer-id gen --secret_path ./a.txt ckb peer-id from-secret --secret-path ./a.txt ``` ---------------------------------------- TITLE: tx_pool_ready RPC Result (JSON Response) DESCRIPTION: Example JSON response received after calling the `tx_pool_ready` RPC method, indicating whether the transaction pool service is ready (`true` or `false`). SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_123 LANGUAGE: JSON CODE: ``` { "id": 42, "jsonrpc": "2.0", "result": true } ``` ---------------------------------------- TITLE: Verify Transaction and Witness Proof RPC Response (JSON) DESCRIPTION: Example JSON RPC response payload for the `verify_transaction_and_witness_proof` method. It returns an array containing the transaction hash(es) that the provided proof commits to. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_35 LANGUAGE: json CODE: ``` { "id": 42, "jsonrpc": "2.0", "result": [ "0xa4037a893eb48e18ed4ef61034ce26eba9c585f15c9cee102ae58505565eccc3" ] } ``` ---------------------------------------- TITLE: Disabling PostgreSQL JIT Compilation DESCRIPTION: Recommended PostgreSQL configuration parameter to disable Just-In-Time (JIT) compilation, which can sometimes improve performance for certain workloads relevant to the CKB Rich-Indexer. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/util/rich-indexer/README.md#_snippet_3 LANGUAGE: conf CODE: ``` #------------------------------------------------------------------------------ # QUERY TUNING #------------------------------------------------------------------------------ # - Other Planner Options - jit = off # allow JIT compilation ``` ---------------------------------------- TITLE: Verify Transaction Proof RPC Response (JSON) DESCRIPTION: Example JSON RPC response payload for the `verify_transaction_proof` method. It returns an array containing the transaction hash(es) that the provided proof commits to. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_31 LANGUAGE: json CODE: ``` { "id": 42, "jsonrpc": "2.0", "result": [ "0xa4037a893eb48e18ed4ef61034ce26eba9c585f15c9cee102ae58505565eccc3" ] } ``` ---------------------------------------- TITLE: Submit Block RPC Response (JSON) DESCRIPTION: JSON response payload for the `submit_block` RPC method. It typically returns a result hash upon successful submission. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_90 LANGUAGE: json CODE: ``` { "id": 42, "jsonrpc": "2.0", "result": "0xa5f5c85987a15de25661e5a214f2c1449cd803f071acc7999820f25246471f40" } ``` ---------------------------------------- TITLE: Block Filter Response by Hash (JSON, Null Result) DESCRIPTION: JSON response payload for the `get_block_filter` RPC method when no block filter is found for the given hash, returning null. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_17 LANGUAGE: json CODE: ``` { "id": 42, "jsonrpc": "2.0", "result": null } ``` ---------------------------------------- TITLE: Receiving Transaction Details (Verbosity 0) - CKB RPC - JSON DESCRIPTION: Shows a simplified JSON RPC response from the `get_transaction` method when `verbosity` is 0. It includes the transaction hash as a hex-encoded string, cycles, and the transaction status, omitting the full transaction object details. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_21 LANGUAGE: json CODE: ``` { "id": 42, "jsonrpc": "2.0", "result": { "transaction": "0x.....", "cycles": "0x219", "tx_status": { "block_hash": null, "block_number": null, "status": "pending", "tx_index": null, "reason": null } } } ``` ---------------------------------------- TITLE: Generate CKB Epochs RPC Request (Text) - Fractional Input DESCRIPTION: Text RPC request payload to call the `generate_epochs` method with a fractional epoch number input, represented as a hex string in `EpochNumberWithFraction` format. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_77 LANGUAGE: text CODE: ``` { "id": 42, "jsonrpc": "2.0", "method": "generate_epochs", "params": ["0x20001000000"] } ``` ---------------------------------------- TITLE: Starting CKB Built-in Miner (Shell) DESCRIPTION: Executes the built-in CKB miner. This command starts the mining process using the configuration defined in `ckb-miner.toml` to find blocks on the running CKB dev chain. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/docs/dev-miner.md#_snippet_4 LANGUAGE: Shell CODE: ``` ckb miner ``` ---------------------------------------- TITLE: Calling get_raw_tx_pool RPC (JSON Request) DESCRIPTION: Example JSON request payload to invoke the `get_raw_tx_pool` RPC method with `verbose` set to `true`, requesting detailed transaction pool information. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_118 LANGUAGE: JSON CODE: ``` { "id": 42, "jsonrpc": "2.0", "method": "get_raw_tx_pool", "params": [true] } ``` ---------------------------------------- TITLE: Configure Eaglesong PoW Engine (TOML) DESCRIPTION: Sets the Proof-of-Work function to 'Eaglesong' in the CKB configuration file. This is typically used for the mainnet (Mirana). SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/docs/configure.md#_snippet_3 LANGUAGE: TOML CODE: ``` [pow] func = "Eaglesong" ``` ---------------------------------------- TITLE: Verify Transaction Proof RPC Request (JSON) DESCRIPTION: Example JSON RPC request payload for the `verify_transaction_proof` method. It includes the block hash, the transaction proof structure (indices and lemmas), and the witnesses root hash. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_30 LANGUAGE: json CODE: ``` { "id": 42, "jsonrpc": "2.0", "method": "verify_transaction_proof", "params": [ { "block_hash": "0x7978ec7ce5b507cfb52e149e36b1a23f6062ed150503c85bbf825da3599095ed", "proof": { "indices": [ "0x0" ], "lemmas": [] }, "witnesses_root": "0x2bb631f4a251ec39d943cc238fc1e39c7f0e99776e8a1e7be28a03c70c4f4853" } ] } ``` ---------------------------------------- TITLE: Request get_deployments_info RPC (JSON) DESCRIPTION: Example JSON request payload for calling the `get_deployments_info` RPC method to retrieve statistics about chain deployments. It follows the JSON-RPC 2.0 format. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_126 LANGUAGE: json CODE: ``` { "id": 42, "jsonrpc": "2.0", "method": "get_deployments_info", "params": [] } ``` ---------------------------------------- TITLE: RPC Request: calculate_dao_field (JSON) DESCRIPTION: This JSON object represents a request to the `calculate_dao_field` RPC method, providing detailed block header information as parameters. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_83 LANGUAGE: JSON CODE: ``` { "id": 42, "jsonrpc": "2.0", "method": "calculate_dao_field", "params": [ { "bytes_limit": "0x91c08", "cellbase": { "cycles": null, "data": { "cell_deps": [], "header_deps": [], "inputs": [ { "previous_output": { "index": "0xffffffff", "tx_hash": "0x0000000000000000000000000000000000000000000000000000000000000000" }, "since": "0x401" } ], "outputs": [ { "capacity": "0x18e64efc04", "lock": { "code_hash": "0x28e83a1277d48add8e72fadaa9248559e1b632bab2bd60b27955ebc4c03800a5", "hash_type": "data", "args": "0x" }, "type": null } ], "outputs_data": [ "0x" ], "version": "0x0", "witnesses": [ "0x650000000c00000055000000490000001000000030000000310000001892ea40d82b53c678ff88312450bbb17e164d7a3e0a90941aa58839f56f8df20114000000b2e61ff569acf041b3c2c17724e2379c581eeac30c00000054455354206d657373616765" ] }, "hash": "0xbaf7e4db2fd002f19a597ca1a31dfe8cfe26ed8cebc91f52b75b16a7a5ec8bab" }, "compact_target": "0x1e083126", "current_time": "0x174c45e17a3", "cycles_limit": "0xd09dc300", "dao": "0xd495a106684401001e47c0ae1d5930009449d26e32380000000721efd0030000", "epoch": "0x7080019000001", "extension": "0xb0a0079f3778c0ba0d89d88b389c602cc18b8a0355d16c0713f8bfcee64b5f84", "number": "0x401", "parent_hash": "0xa5f5c85987a15de25661e5a214f2c1449cd803f071acc7999820f25246471f40", "proposals": ["0xa0ef4eb5f4ceeb08a4c8"], "transactions": [], "uncles": [ { "hash": "0xdca341a42890536551f99357612cef7148ed471e3b6419d0844a4e400be6ee94", "header": { "compact_target": "0x1e083126", "dao": "0xb5a3e047474401001bc476b9ee573000c0c387962a38000000febffacf030000", "epoch": "0x7080018000001", "extra_hash": "0x0000000000000000000000000000000000000000000000000000000000000000", "nonce": "0x0", "number": "0x400", "parent_hash": "0xae003585fa15309b30b31aed3dcf385e9472c3c3e93746a6c4540629a6a1ed2d", "proposals_hash": "0x0000000000000000000000000000000000000000000000000000000000000000", "timestamp": "0x5cd2b118", "transactions_root": "0xc47d5b78b3c4c4c853e2a32810818940d0ee403423bea9ec7b8e566d9595206c", "version":"0x0" }, "proposals": [], "required": false } ], "uncles_count_limit": "0x2", "version": "0x0", "work_id": "0x0" } ] } ``` ---------------------------------------- TITLE: RPC Response: generate_block_with_template (JSON) DESCRIPTION: This JSON object represents the expected successful response from the `generate_block_with_template` RPC method. The `result` field contains the hash of the generated block as a Byte32 value. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_82 LANGUAGE: json CODE: ``` { "id": 42, "jsonrpc": "2.0", "result": "0x899541646ae412a99fdbefc081e1a782605a7815998a096af16e51d4df352c75" } ``` ---------------------------------------- TITLE: Generate CKB Block RPC Response (JSON) DESCRIPTION: JSON RPC response payload for a successful `generate_block` method call. The result is the hash of the newly generated block. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_75 LANGUAGE: json CODE: ``` { "id": 42, "jsonrpc": "2.0", "result": "0x60dd3fa0e81db3ee3ad41cf4ab956eae7e89eb71cd935101c26c4d0652db3029" } ``` ---------------------------------------- TITLE: Run Rust Tests with Failpoints (Shell) DESCRIPTION: This command executes the Rust tests for the project using `cargo test`. The `--features fail/failpoints` flag enables the 'failpoints' feature, which is used for injecting failures during testing. The `-- --test-threads=1` part passes arguments directly to the test runner, specifically limiting the tests to run on a single thread. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/freezer/README.md#_snippet_0 LANGUAGE: Shell CODE: ``` cargo test --features fail/failpoints -- --test-threads=1 ``` ---------------------------------------- TITLE: Run CKB Fuzz Test DESCRIPTION: Executes a specific fuzz test target (`transaction_scripts_verifier_data1`) using `cargo-fuzz` with the nightly Rust toolchain, utilizing all available CPU cores. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/script/fuzz/README.md#_snippet_2 LANGUAGE: Shell CODE: ``` cargo +nightly fuzz run -j $(nproc) transaction_scripts_verifier_data1 ``` ---------------------------------------- TITLE: Configuring PostgreSQL Shared Buffers DESCRIPTION: Recommended PostgreSQL configuration parameter to adjust the amount of memory dedicated to shared memory buffers, improving query performance for the CKB Rich-Indexer. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/util/rich-indexer/README.md#_snippet_2 LANGUAGE: conf CODE: ``` #------------------------------------------------------------------------------ # RESOURCE USAGE (except WAL) #------------------------------------------------------------------------------ # - Memory - shared_buffers = 2GB # min 128kB ``` ---------------------------------------- TITLE: Configure EaglesongSimple Miner Worker (TOML) DESCRIPTION: Configures a miner worker using the 'EaglesongSimple' type with an extra Blake2b hash function. This setting is required in `ckb-miner.toml` when using the 'EaglesongBlake2b' PoW engine. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/docs/configure.md#_snippet_5 LANGUAGE: TOML CODE: ``` [[miner.workers]] worker_type = "EaglesongSimple" threads = 1 extra_hash_function = "Blake2b" ``` ---------------------------------------- TITLE: Add Fields to tx_pool_info RPC Output (JSON) DESCRIPTION: This snippet illustrates the additions to the `tx_pool_info` RPC output. It adds fields to report the total cycles and size of transactions currently in the transaction pool as part of the changes for applying transaction pool limits. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/CHANGELOG.md#_snippet_5 LANGUAGE: JSON CODE: ``` + "total_tx_cycles": "2", + "total_tx_size": "156", ``` ---------------------------------------- TITLE: RPC Request: get_block_median_time (JSON) DESCRIPTION: This JSON object represents an RPC request to get the past median time for a block specified by its hash. It uses the 'get_block_median_time' method with a single parameter, the block hash. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_41 LANGUAGE: json CODE: ``` { "id": 42, "jsonrpc": "2.0", "method": "get_block_median_time", "params": [ "0xa5f5c85987a15de25661e5a214f2c1449cd803f071acc7999820f25246471f40" ] } ``` ---------------------------------------- TITLE: Request JSON for get_block_template DESCRIPTION: Example JSON-RPC request payload for the `get_block_template` method. The parameters are set to null, indicating a request for a basic block template without specific constraints. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_87 LANGUAGE: json CODE: ``` { "id": 42, "jsonrpc": "2.0", "method": "get_block_template", "params": [ null, null, null ] } ``` ---------------------------------------- TITLE: Update CKB tx_pool Configuration (Config) DESCRIPTION: This snippet shows the configuration changes in the `ckb.toml` file related to the transaction pool limits. It replaces older size-based limits with new memory and cycle limits as part of the changes for applying transaction pool limits. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/CHANGELOG.md#_snippet_4 LANGUAGE: Config CODE: ``` [tx_pool] - max_pool_size = 10000 - max_orphan_size = 10000 - max_proposal_size = 10000 - max_cache_size = 1000 - max_pending_size = 10000 - txs_verify_cache_size = 100000 + max_mem_size = 20_000_000 # 20mb + max_cycles = 200_000_000_000 + max_verfify_cache_size = 100_000 ``` ---------------------------------------- TITLE: Unsubscribe from CKB RPC Topic - JSON DESCRIPTION: Example JSON request to unsubscribe from a previously subscribed CKB RPC topic. The `params` array contains the subscription ID obtained from the subscribe response. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_133 LANGUAGE: json CODE: ``` { "id": 42, "jsonrpc": "2.0", "method": "unsubscribe", "params": [ "0xf3" ] } ``` ---------------------------------------- TITLE: set_ban RPC Method - JSON Response DESCRIPTION: Example JSON RPC response for a successful call to the `set_ban` method. A successful operation returns `null` in the result field. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_94 LANGUAGE: json CODE: ``` { "id": 42, "jsonrpc": "2.0", "result": null } ``` ---------------------------------------- TITLE: Run CKB Integration Tests (Default) DESCRIPTION: Executes the default set of CKB integration tests using `cargo run`. Assumes the CKB binary is built and the node is running on port 9000. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/test/README.md#_snippet_0 LANGUAGE: bash CODE: ``` cargo run ``` ---------------------------------------- TITLE: RPC Response: calculate_dao_field (JSON) DESCRIPTION: This JSON object represents the successful response from the `calculate_dao_field` RPC method, containing the calculated DAO field value. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_84 LANGUAGE: JSON CODE: ``` { "id": 42, "jsonrpc": "2.0", "result": "0xd495a106684401001e47c0ae1d5930009449d26e32380000000721efd0030000" } ``` ---------------------------------------- TITLE: Notify CKB Transaction RPC Response (JSON) DESCRIPTION: JSON RPC response payload for a successful `notify_transaction` method call. The result is the hash of the added transaction. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_80 LANGUAGE: json CODE: ``` { "id": 42, "jsonrpc": "2.0", "result": "0xa0ef4eb5f4ceeb08a4c8524d84c5da95dce2f608e0ca2ec8091191b0f330c6e3" } ``` ---------------------------------------- TITLE: clear_tx_pool RPC (JSON) - Response DESCRIPTION: This JSON object shows the response from the `clear_tx_pool` RPC method. The `result` field is `null`, indicating that the operation completed successfully and the transaction pool has been cleared. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_115 LANGUAGE: json CODE: ``` { "id": 42, "jsonrpc": "2.0", "result": null } ``` ---------------------------------------- TITLE: Get Transaction and Witness Proof RPC Response (JSON) DESCRIPTION: Example JSON RPC response payload for the `get_transaction_and_witness_proof` method. It returns the block hash, the transactions proof, and the witnesses proof. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_33 LANGUAGE: json CODE: ``` { "jsonrpc": "2.0", "result": { "block_hash": "0x7978ec7ce5b507cfb52e149e36b1a23f6062ed150503c85bbf825da3599095ed", "transactions_proof": { "indices": [ "0x0" ], "lemmas": [] }, "witnesses_proof": { "indices": [ "0x0" ], "lemmas": [] } }, "id": 42 } ``` ---------------------------------------- TITLE: CKB v0.8.0 Breaking Change: ckb.toml Config Changes DESCRIPTION: This snippet shows the breaking changes to the `ckb.toml` configuration file in CKB v0.8.0. It illustrates the removal of certain options like `logger.file`, `db.path`, and `network.path`, and the addition of new options like `logger.log_to_stdout`, `logger.log_to_file`, and changes to the `block_assembler` section. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/CHANGELOG.md#_snippet_6 LANGUAGE: diff CODE: ``` Config file `ckb.toml` changes: - Removed `logger.file`, `db.path` and `network.path` from config file. - Added config option `logger.log_to_stdout` and `logger.log_to_file`. - Section `block_assembler` now accepts two options `binary_hash` and `args`. - Added a new option to set sentry DSN. ``` ---------------------------------------- TITLE: clear_tx_verify_queue RPC Result (JSON Response) DESCRIPTION: Example JSON response received after successfully calling the `clear_tx_verify_queue` RPC method. The result is `null`. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_117 LANGUAGE: JSON CODE: ``` { "id": 42, "jsonrpc": "2.0", "result": null } ``` ---------------------------------------- TITLE: Verify Transaction and Witness Proof RPC Request (JSON) DESCRIPTION: Example JSON RPC request payload for the `verify_transaction_and_witness_proof` method. It takes a `TransactionAndWitnessProof` object generated by `get_transaction_and_witness_proof`. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_34 LANGUAGE: json CODE: ``` { "id": 42, "jsonrpc": "2.0", "method": "verify_transaction_and_witness_proof", "params": [ { "block_hash": "0x7978ec7ce5b507cfb52e149e36b1a23f6062ed150503c85bbf825da3599095ed", "transactions_proof": { "indices": [ "0x0" ], "lemmas": [] }, "witnesses_proof": { "indices": [ "0x0" ], "lemmas": [] } } ] } ``` ---------------------------------------- TITLE: Build CKB Test Scripts with Docker DESCRIPTION: This command uses the Makefile within a Docker environment to build all test scripts for the CKB project. It assumes dependencies have been downloaded. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/script/testdata/README.md#_snippet_0 LANGUAGE: shell CODE: ``` make all-in-docker ``` ---------------------------------------- TITLE: Response for calculate_dao_maximum_withdraw RPC (JSON) DESCRIPTION: This JSON object shows a typical successful response from the `calculate_dao_maximum_withdraw` RPC method. The `result` field contains the calculated maximum withdrawal capacity as a hexadecimal string. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_52 LANGUAGE: JSON CODE: ``` { "id": 42, "jsonrpc": "2.0", "result": "0x4a8b4e8a4" } ``` ---------------------------------------- TITLE: Install cargo-fuzz DESCRIPTION: Installs the `cargo-fuzz` tool, which is used to integrate fuzz testing into Rust projects. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/script/fuzz/README.md#_snippet_1 LANGUAGE: Shell CODE: ``` cargo install cargo-fuzz ``` ---------------------------------------- TITLE: Install Rust Components and Tools DESCRIPTION: Installs necessary Rust components (`llvm-tools-preview`) and cargo tools (`cargo-binutils`, `rustfilt`) required for fuzz testing and coverage analysis. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/script/fuzz/README.md#_snippet_0 LANGUAGE: Shell CODE: ``` rustup component add llvm-tools-preview cargo install cargo-binutils cargo install rustfilt ``` ---------------------------------------- TITLE: Modifying CKB Dev Chain PoW Algorithm (Diff) DESCRIPTION: Shows the necessary change in the `specs/dev.toml` configuration file to switch the Proof-of-Work algorithm from the default 'Dummy' to 'Eaglesong' for mining tests. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/docs/dev-miner.md#_snippet_1 LANGUAGE: Diff CODE: ``` - func = "Dummy" + func = "Eaglesong" ``` ---------------------------------------- TITLE: Configuring CKB Built-in Miner (Diff) DESCRIPTION: Illustrates the modifications required in the `ckb-miner.toml` configuration file to set up the built-in miner to use the 'EaglesongSimple' worker type and specify the number of threads for mining on the dev chain. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/docs/dev-miner.md#_snippet_3 LANGUAGE: Diff CODE: ``` - worker_type = "Dummy" - delay_type = "Constant" - value = 9500 + worker_type = "EaglesongSimple" + threads = 1 ``` ---------------------------------------- TITLE: CKB RPC Unsubscribe Response - JSON DESCRIPTION: Example JSON response received after successfully unsubscribing from a CKB RPC topic. The `result` field is a boolean indicating the success or failure of the unsubscribe operation. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_134 LANGUAGE: json CODE: ``` { "id": 42, "jsonrpc": "2.0", "result": true } ``` ---------------------------------------- TITLE: Alert Send Failure Response (JSON) DESCRIPTION: This JSON object shows an example response from the `send_alert` RPC method when an error occurs. Specifically, it indicates an `AlertFailedToVerifySignatures` error with code -1000, data "SigNotEnough", and a descriptive message. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_1 LANGUAGE: JSON CODE: ``` { "error": { "code": -1000, "data": "SigNotEnough", "message":"AlertFailedToVerifySignatures: The count of sigs is less than threshold." }, "jsonrpc": "2.0", "result": null, "id": 42 } ``` ---------------------------------------- TITLE: Response for get_fork_block (Verbosity 0) DESCRIPTION: Example response for the `get_fork_block` RPC method when the `verbosity` parameter is set to 0. It returns a simplified result containing only the block hash string. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_38 LANGUAGE: text CODE: ``` { "id": 42, "jsonrpc": "2.0", "result": "0x..." } ``` ---------------------------------------- TITLE: Example ProposalWindow Object (Text) DESCRIPTION: An example representation of the ProposalWindow structure, showing the `closest` and `farthest` fields with example values. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_151 LANGUAGE: text CODE: ``` ProposalWindow { closest: 2, farthest: 10 } ``` ---------------------------------------- TITLE: Updating CKB DB Configuration in JSON DESCRIPTION: This snippet shows the required update to the node's configuration file to include the new database configuration section. This is a breaking change introduced in v0.6.0, requiring users to add a 'db' object with a 'path' property to their JSON config. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/CHANGELOG.md#_snippet_8 LANGUAGE: JSON CODE: ``` { + "db": { + "path": "db" + } } ``` ---------------------------------------- TITLE: Requesting a Fork Block (JSON) DESCRIPTION: Example JSON request payload for the `get_fork_block` RPC method. It specifies the method name and includes the block hash as a parameter to retrieve details for a specific block. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_36 LANGUAGE: json CODE: ``` { "id": 42, "jsonrpc": "2.0", "method": "get_fork_block", "params": [ "0xdca341a42890536551f99357612cef7148ed471e3b6419d0844a4e400be6ee94" ] } ``` ---------------------------------------- TITLE: Submit Block RPC Request (JSON) DESCRIPTION: JSON request payload for the `submit_block` RPC method. It includes a `work_id` and the block structure containing header, proposals, transactions, and uncles. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_89 LANGUAGE: json CODE: ``` { "id": 42, "jsonrpc": "2.0", "method": "submit_block", "params": [ "work_id_example", { "header": { "compact_target": "0x1e083126", "dao": "0xb5a3e047474401001bc476b9ee573000c0c387962a38000000febffacf030000", "epoch": "0x7080018000001", "extra_hash": "0x0000000000000000000000000000000000000000000000000000000000000000", "nonce": "0x0", "number": "0x400", "parent_hash": "0xae003585fa15309b30b31aed3dcf385e9472c3c3e93746a6c4540629a6a1ed2d", "proposals_hash": "0x0000000000000000000000000000000000000000000000000000000000000000", "timestamp": "0x5cd2b117", "transactions_root": "0xc47d5b78b3c4c4c853e2a32810818940d0ee403423bea9ec7b8e566d9595206c", "version": "0x0" }, "proposals": [], "transactions": [ { "cell_deps": [], "header_deps": [], "inputs": [ { "previous_output": { "index": "0xffffffff", "tx_hash": "0x0000000000000000000000000000000000000000000000000000000000000000" }, "since": "0x400" } ], "outputs": [ { "capacity": "0x18e64b61cf", "lock": { "code_hash": "0x28e83a1277d48add8e72fadaa9248559e1b632bab2bd60b27955ebc4c03800a5", "hash_type": "data", "args": "0x" }, "type": null } ], "outputs_data": [ "0x" ], "version": "0x0", "witnesses": [ "0x450000000c000000410000003500000010000000300000003100000028e83a1277d48add8e72fadaa9248559e1b632bab2bd60b27955ebc4c03800a5000000000000000000" ] } ], "uncles": [] } ] } ``` ---------------------------------------- TITLE: Requesting CKB Integration Test Process Block (JSON) DESCRIPTION: This JSON snippet illustrates how to make a request to the CKB Integration Test module's `process_block_without_verify` RPC method. It includes the RPC version, request ID, method name, and parameters: the block data structure (header, proposals, transactions, uncles) and a boolean flag indicating whether to broadcast the block. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_70 LANGUAGE: JSON CODE: ``` { "id": 42, "jsonrpc": "2.0", "method": "process_block_without_verify", "params": [ { "header": { "compact_target": "0x1e083126", "dao": "0xb5a3e047474401001bc476b9ee573000c0c387962a38000000febffacf030000", "epoch": "0x7080018000001", "extra_hash": "0x0000000000000000000000000000000000000000000000000000000000000000", "nonce": "0x0", "number": "0x400", "parent_hash": "0xae003585fa15309b30b31aed3dcf385e9472c3c3e93746a6c4540629a6a1ed2d", "proposals_hash": "0x0000000000000000000000000000000000000000000000000000000000000000", "timestamp": "0x5cd2b117", "transactions_root": "0xc47d5b78b3c4c4c853e2a32810818940d0ee403423bea9ec7b8e566d9595206c", "version": "0x0" }, "proposals": [], "transactions": [{ "cell_deps": [], "header_deps": [], "inputs": [{ "previous_output": { "index": "0xffffffff", "tx_hash": "0x0000000000000000000000000000000000000000000000000000000000000000" }, "since": "0x400" }], "outputs": [{ "capacity": "0x18e64b61cf", "lock": { "code_hash": "0x28e83a1277d48add8e72fadaa9248559e1b632bab2bd60b27955ebc4c03800a5", "hash_type": "data", "args": "0x" }, "type": null }], "outputs_data": [ "0x" ], "version": "0x0", "witnesses": [ "0x450000000c000000410000003500000010000000300000003100000028e83a1277d48add8e72fadaa9248559e1b632bab2bd60b27955ebc4c03800a5000000000000000000" ] }], "uncles": [] }, true ] } ``` ---------------------------------------- TITLE: Configuration File Changes for Notifier Service DESCRIPTION: This diff shows the configuration file changes introduced by the new notify service. It renames the `[alert_notifier]` section to `[notifier]` and adds new options (`new_block_notify_script`, `network_alert_notify_script`) for executing scripts on new block tips and network alerts, replacing the old `notify_script`. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/CHANGELOG.md#_snippet_2 LANGUAGE: Configuration Diff CODE: ``` -# [alert_notifier] -# # Script will be notified when node received an alert, first arg is alert message string. -# notify_script = "echo" +# [notifier] +# # Execute command when the new tip block changes, first arg is block struct in json format string. +# new_block_notify_script = "your_new_block_notify_script.sh" +# # Execute command when node received an network alert, first arg is alert message string. +# network_alert_notify_script = "your_network_alert_notify_script.sh" ``` ---------------------------------------- TITLE: Calling sync_state RPC Method - JSON Request DESCRIPTION: Example JSON RPC request to call the `sync_state` method. This method returns the current chain synchronization state of the node. It requires no parameters. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_95 LANGUAGE: json CODE: ``` { "id": 42, "jsonrpc": "2.0", "method": "sync_state", "params": [] } ``` ---------------------------------------- TITLE: Example CellWithStatus Unknown State (JSON) DESCRIPTION: This JSON snippet provides a simple example of a CellWithStatus object when the cell's status is "unknown". It shows a null cell and the unknown status. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_142 LANGUAGE: json CODE: ``` { "cell": null, "status": "unknown" } ``` ---------------------------------------- TITLE: ping_peers RPC Method - JSON Response DESCRIPTION: Example JSON RPC response for a successful call to the `ping_peers` method. A successful operation returns `null` in the result field. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_104 LANGUAGE: json CODE: ``` { "id": 42, "jsonrpc": "2.0", "result": null } ``` ---------------------------------------- TITLE: Configure Dummy PoW Engine (TOML) DESCRIPTION: Sets the Proof-of-Work function to 'Dummy'. This engine is primarily used for development or testing purposes and requires a specific miner worker configuration. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/docs/configure.md#_snippet_6 LANGUAGE: TOML CODE: ``` [pow] func = "Dummy" ``` ---------------------------------------- TITLE: Configure Dummy Miner Worker (TOML) DESCRIPTION: Configures a miner worker using the 'Dummy' type with a constant delay. This setting is required in `ckb-miner.toml` when using the 'Dummy' PoW engine. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/docs/configure.md#_snippet_7 LANGUAGE: TOML CODE: ``` [[miner.workers]] worker_type = "Dummy" delay_type = "Constant" value = 5000 ``` ---------------------------------------- TITLE: Calling ping_peers RPC Method - JSON Request DESCRIPTION: Example JSON RPC request to call the `ping_peers` method. This method requests that a ping is sent to all connected peers to measure latency. It requires no parameters. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_103 LANGUAGE: json CODE: ``` { "id": 42, "jsonrpc": "2.0", "method": "ping_peers", "params": [] } ``` ---------------------------------------- TITLE: CKB RPC Alert Type Example - JSON DESCRIPTION: Example JSON representation of the `Alert` RPC type. An alert is used to broadcast critical messages via the P2P network and includes fields like ID, version range, priority, message, expiration time, and signatures. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_135 LANGUAGE: json CODE: ``` { "id": "0x1", "cancel": "0x0", "min_version": "0.1.0", "max_version": "1.0.0", "priority": "0x1", "message": "An example alert message!", "notice_until": "0x24bcca57c00", "signatures": [ "0xbd07059aa9a3d057da294c2c4d96fa1e67eeb089837c87b523f124239e18e9fc7d11bb95b720478f7f937d073517d0e4eb9a91d12da5c88a05f750362f4c214dd0", "0x0242ef40bb64fe3189284de91f981b17f4d740c5e24a3fc9b70059db6aa1d198a2e76da4f84ab37549880d116860976e0cf81cd039563c452412076ebffa2e4453" ] } ``` ---------------------------------------- TITLE: Example ProposalShortId Hex String (Text) DESCRIPTION: An example of a 10-byte fixed-length binary value encoded as a 0x-prefixed hex string, representing a ProposalShortId. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_150 LANGUAGE: text CODE: ``` 0xa0ef4eb5f4ceeb08a4c8 ``` ---------------------------------------- TITLE: Control CKB Miner Limit (Bash) DESCRIPTION: Demonstrates how to use the `ckb miner` command with the `--limit` or `-l` option to control the number of nonces found before the miner exits. Examples show setting a specific limit, using the short option, and running indefinitely. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/CHANGELOG.md#_snippet_1 LANGUAGE: bash CODE: ``` ckb miner -C . --limit 10 # Exit after 10 nonces found ckb miner -C . -l 5 # Exit after 5 nonces found ckb miner -C . # Run forever ckb miner -C . --limit 0 # Run forever, too ``` ---------------------------------------- TITLE: Sending an Alert (JSON Request) DESCRIPTION: This JSON object represents a request to the `send_alert` RPC method in the CKB Alert module. It includes parameters like a unique `id`, `cancel` flag, `priority`, the alert `message`, `notice_until` timestamp, and required `signatures` from authorized keys. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_0 LANGUAGE: JSON CODE: ``` { "jsonrpc": "2.0", "method": "send_alert", "params": [ { "id": "0x1", "cancel": "0x0", "priority": "0x1", "message": "An example alert message!", "notice_until": "0x24bcca57c00", "signatures": [ "0xbd07059aa9a3d057da294c2c4d96fa1e67eeb089837c87b523f124239e18e9fc7d11bb95b720478f7f937d073517d0e4eb9a91d12da5c88a05f750362f4c214dd0", "0x0242ef40bb64fe3189284de91f981b17f4d740c5e24a3fc9b70059db6aa1d198a2e76da4f84ab37549880d116860976e0cf81cd039563c452412076ebffa2e4453" ] } ], "id": 42 } ``` ---------------------------------------- TITLE: Configure CKB Logger Filter - All Info (Text) DESCRIPTION: Example configuration string for the `filter` field of `ExtraLoggerConfig`. Sets the log level to 'info' for all modules in the CKB node. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_144 LANGUAGE: text CODE: ``` info ``` ---------------------------------------- TITLE: Generate CKB Epochs RPC Response (JSON) DESCRIPTION: JSON RPC response payload for a successful `generate_epochs` method call. The result is the updated epoch number after generation. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_78 LANGUAGE: json CODE: ``` { "id": 42, "jsonrpc": "2.0", "result": "0xa0001000003" } ``` ---------------------------------------- TITLE: Generate CKB Epochs RPC Request (JSON) - Integer Input DESCRIPTION: JSON RPC request payload to call the `generate_epochs` method with an integer number of epochs to generate. The integer input is normalized to `EpochNumberWithFraction`. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_76 LANGUAGE: json CODE: ``` { "id": 42, "jsonrpc": "2.0", "method": "generate_epochs", "params": ["0x2"] } ``` ---------------------------------------- TITLE: RPC Response for send_test_transaction (JSON) DESCRIPTION: This JSON object represents the successful response payload for the `send_test_transaction` RPC method. It returns the transaction hash of the sent test transaction in the `result` field. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_86 LANGUAGE: json CODE: ``` { "id": 42, "jsonrpc": "2.0", "result": "0xa0ef4eb5f4ceeb08a4c8524d84c5da95dce2f608e0ca2ec8091191b0f330c6e3" } ``` ---------------------------------------- TITLE: Calling clear_tx_verify_queue RPC (JSON Request) DESCRIPTION: Example JSON request payload to invoke the `clear_tx_verify_queue` RPC method, which removes all transactions from the verification queue. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_116 LANGUAGE: JSON CODE: ``` { "id": 42, "jsonrpc": "2.0", "method": "clear_tx_verify_queue", "params": [] } ``` ---------------------------------------- TITLE: Calculating CKB Transaction Fee Rate DESCRIPTION: This formula shows how the transaction fee rate is calculated within the CKB network. It is used by the transaction pool to enforce the minimum fee rate requirement. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_152 LANGUAGE: text CODE: ``` fee / (1000 * tx_serialization_size_in_block_in_bytes) ``` ---------------------------------------- TITLE: set_network_active RPC Method - JSON Response DESCRIPTION: Example JSON RPC response for a successful call to the `set_network_active` method. A successful operation returns `null` in the result field. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_98 LANGUAGE: json CODE: ``` { "id": 42, "jsonrpc": "2.0", "result": null } ``` ---------------------------------------- TITLE: add_node RPC Method - JSON Response DESCRIPTION: Example JSON RPC response for a successful call to the `add_node` method. A successful operation returns `null` in the result field. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_100 LANGUAGE: json CODE: ``` { "id": 42, "jsonrpc": "2.0", "result": null } ``` ---------------------------------------- TITLE: remove_node RPC Method - JSON Response DESCRIPTION: Example JSON RPC response for a successful call to the `remove_node` method. A successful operation returns `null` in the result field. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_102 LANGUAGE: json CODE: ``` { "id": 42, "jsonrpc": "2.0", "result": null } ``` ---------------------------------------- TITLE: Reinstalling Rust Stable Toolchain DESCRIPTION: Instructions to update `rustup` and reinstall the stable Rust toolchain after upgrading to Rust 2018 edition, which is a breaking change in v0.2.0. This is necessary to compile the project. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/CHANGELOG.md#_snippet_9 LANGUAGE: Shell CODE: ``` rustup self update rustup toolchain uninstall stable rustup toolchain install stable ``` ---------------------------------------- TITLE: Truncate CKB Chain RPC Response (JSON) DESCRIPTION: JSON RPC response payload for a successful `truncate` method call. The result is null upon success. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_73 LANGUAGE: json CODE: ``` { "id": 42, "jsonrpc": "2.0", "result": null } ``` ---------------------------------------- TITLE: Enable CKB node service on boot DESCRIPTION: Configures the systemd service for the CKB node to automatically start when the system boots. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/devtools/init/linux-systemd/README.md#_snippet_4 LANGUAGE: bash CODE: ``` sudo systemctl enable ckb.service ``` ---------------------------------------- TITLE: Truncate CKB Chain RPC Request (JSON) DESCRIPTION: JSON RPC request payload to call the `truncate` method, which truncates the CKB chain to a specified block hash. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_72 LANGUAGE: json CODE: ``` { "id": 42, "jsonrpc": "2.0", "method": "truncate", "params": [ "0xa5f5c85987a15de25661e5a214f2c1449cd803f071acc7999820f25246471f40" ] } ``` ---------------------------------------- TITLE: CKB v0.7.0 Breaking Change: Network Config Changes DESCRIPTION: This snippet shows the breaking changes to the network configuration section in CKB v0.7.0. It highlights the renaming and modification of several network-related options, such as changing `reserved_nodes` to `reserved_peers` and adding new options like `max_outbound_peers` and various timeout/interval settings. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/CHANGELOG.md#_snippet_7 LANGUAGE: diff CODE: ``` [network] - reserved_nodes = [] -only_reserved_peers = false -max_peers = 8 -min_peers = 4 -secret_file = "secret_key" -peer_store_path = "peer_store.db" +reserved_peers = [] +reserved_only = false +max_peers = 125 +max_outbound_peers = 30 +config_dir_path = "default/network" +ping_interval_secs = 15 +ping_timeout_secs = 20 +connect_outbound_interval_secs = 15 ``` ---------------------------------------- TITLE: Generate Fuzz Test Coverage Report DESCRIPTION: Generates a coverage profile from the fuzz test run and then uses `cargo-cov` to produce an HTML coverage report, filtering for lines with coverage greater than 1 and saving it to a temporary file. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/script/fuzz/README.md#_snippet_3 LANGUAGE: Shell CODE: ``` cargo +nightly fuzz coverage transaction_scripts_verifier_data1 cargo +nightly cov -- show fuzz/target/target-tuples/release/transaction_scripts_verifier_data1 --Xdemangler=rustfilt --format=html -instr-profile=fuzz/coverage/transaction_scripts_verifier_data1/coverage.profdata --name=ckb --line-coverage-gt=1> /tmp/report.html ``` ---------------------------------------- TITLE: Run Specific CKB Integration Tests DESCRIPTION: Runs only the specified integration test specifications (e.g., `spec1`, `spec2`) using `cargo run`. Requires specifying the path to the CKB debug binary. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/test/README.md#_snippet_1 LANGUAGE: bash CODE: ``` cargo run -- --bin ../target/debug/ckb spec1 spec2 ``` ---------------------------------------- TITLE: Requesting Deprecated Fee Rate Statistics (get_fee_rate_statics) - JSON DESCRIPTION: Provides a sample JSON request body for the deprecated `get_fee_rate_statics` RPC method. This method was used to retrieve fee rate statistics for confirmed blocks. The request takes no parameters in this example. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_45 LANGUAGE: json CODE: ``` { "id": 42, "jsonrpc": "2.0", "method": "get_fee_rate_statics", "params": [] } ``` ---------------------------------------- TITLE: Response for Deprecated Fee Rate Statistics (get_fee_rate_statics) - JSON DESCRIPTION: Shows a sample JSON response from the deprecated `get_fee_rate_statics` RPC method. The response contains the mean and median fee rates in shannons per kilo-weight under the `result` field. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_46 LANGUAGE: json CODE: ``` { "id": 42, "jsonrpc": "2.0", "result": { "mean": "0xe79d", "median": "0x14a8" } } ``` ---------------------------------------- TITLE: CKB Integration Test Process Block Response (JSON) DESCRIPTION: This JSON snippet provides an example response from the CKB Integration Test module's `process_block_without_verify` RPC method. It includes the RPC version, request ID, and the result, which is the hash (H256) of the block that was processed. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md#_snippet_71 LANGUAGE: JSON CODE: ``` { "id": 42, "jsonrpc": "2.0", "result": "0xa5f5c85987a15de25661e5a214f2c1449cd803f071acc7999820f25246471f40" } ``` ---------------------------------------- TITLE: View CKB Integration Test Options DESCRIPTION: Displays all available command-line options for running the CKB integration tests using `cargo run`. SOURCE: https://github.com/nervosnetwork/ckb/blob/develop/test/README.md#_snippet_2 LANGUAGE: bash CODE: ``` cargo run -- --help ```