### Start CKB Node (shell) Source: https://github.com/nervosnetwork/ckb/blob/develop/docs/quick-start.md 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. ```shell ckb run ``` -------------------------------- ### Start CKB Miner (shell) Source: https://github.com/nervosnetwork/ckb/blob/develop/docs/quick-start.md 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. ```shell ckb miner ``` -------------------------------- ### Initialize CKB Node Directory (shell) Source: https://github.com/nervosnetwork/ckb/blob/develop/docs/quick-start.md Initializes the current directory with default CKB configuration files (`ckb.toml`). This command prepares the directory for running a CKB node. ```shell ckb init ``` -------------------------------- ### Create and Navigate CKB Directory (shell) Source: https://github.com/nervosnetwork/ckb/blob/develop/docs/quick-start.md 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. ```shell mkdir ckb-dev cd ckb-dev ``` -------------------------------- ### Install Rust Components and Tools Source: https://github.com/nervosnetwork/ckb/blob/develop/script/fuzz/README.md Installs necessary Rust components (`llvm-tools-preview`) and cargo tools (`cargo-binutils`, `rustfilt`) required for fuzz testing and coverage analysis. ```Shell rustup component add llvm-tools-preview cargo install cargo-binutils cargo install rustfilt ``` -------------------------------- ### Install and start CKB node systemd service Source: https://github.com/nervosnetwork/ckb/blob/develop/devtools/init/linux-systemd/README.md 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. ```bash 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 ``` -------------------------------- ### Install and start CKB miner systemd service Source: https://github.com/nervosnetwork/ckb/blob/develop/devtools/init/linux-systemd/README.md 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. ```bash 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 ``` -------------------------------- ### Example ProposalWindow Object (Text) Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md An example representation of the ProposalWindow structure, showing the `closest` and `farthest` fields with example values. ```text ProposalWindow { closest: 2, farthest: 10 } ``` -------------------------------- ### Install cargo-fuzz Source: https://github.com/nervosnetwork/ckb/blob/develop/script/fuzz/README.md Installs the `cargo-fuzz` tool, which is used to integrate fuzz testing into Rust projects. ```Shell cargo install cargo-fuzz ``` -------------------------------- ### TCP RPC Subscription Example (Bash) Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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. ```bash 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} ``` -------------------------------- ### Example JSON for EpochView Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md This JSON snippet provides an example representation of the EpochView structure, showing the format and typical values for its fields. ```JSON { "compact_target": "0x1e083126", "length": "0x708", "number": "0x1", "start_number": "0x3e8" } ``` -------------------------------- ### MainLoggerConfig Filter Examples Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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. ```Text info ``` ```Text info,ckb-rpc=debug,ckb-sync=debug,ckb-relay=debug,ckb-tx-pool=debug,ckb-network=debug ``` -------------------------------- ### Query CKB Node RPC (shell) Source: https://github.com/nervosnetwork/ckb/blob/develop/docs/quick-start.md 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. ```shell curl -d '{"id": 1, "jsonrpc": "2.0", "method":"get_tip_header","params": []}' \ -H 'content-type:application/json' 'http://localhost:8114' ``` -------------------------------- ### Install and configure CKB binary Source: https://github.com/nervosnetwork/ckb/blob/develop/devtools/init/linux-systemd/README.md Copies the CKB binary to a system directory and sets appropriate ownership and permissions for execution. ```bash sudo cp /path/to/ckb /usr/local/bin sudo chown root:root /usr/local/bin/ckb sudo chmod 755 /usr/local/bin/ckb ``` -------------------------------- ### Example ProposalShortId Hex String (Text) Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md An example of a 10-byte fixed-length binary value encoded as a 0x-prefixed hex string, representing a ProposalShortId. ```text 0xa0ef4eb5f4ceeb08a4c8 ``` -------------------------------- ### Starting CKB Node (Shell) Source: https://github.com/nervosnetwork/ckb/blob/develop/docs/dev-miner.md Starts the CKB node process. This command launches the configured dev chain, making it ready to accept connections and process blocks. ```Shell ckb run ``` -------------------------------- ### Example CellWithStatus Live State (JSON) Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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. ```json { "cell": { "data": { "content": "0x7f454c460201010000000000000000000200f3000100000078000100000000004000000000000000980000000000000005000000400038000100400003000200010000000500000000000000000000000000010000000000000001000000000082000000000000008200000000000000001000000000000001459308d00573000000002e7368737472746162002e74657874000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000b000000010000000600000000000000780001000000000078000000000000000a0000000000000000000000000000000200000000000000000000000000000001000000030000000000000000000000000000000000000082000000000000001100000000000000000000000000000001000000000000000000000000000000", "hash": "0x28e83a1277d48add8e72fadaa9248559e1b632bab2bd60b27955ebc4c03800a5" }, "output": { "capacity": "0x802665800", "lock": { "args": "0x", "code_hash": "0x0000000000000000000000000000000000000000000000000000000000000000", "hash_type": "data" }, "type": null } }, "status": "live" } ``` -------------------------------- ### Response get_epoch_by_number JSON Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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. ```JSON { "id": 42, "jsonrpc": "2.0", "result": { "compact_target": "0x20010000", "length": "0x3e8", "number": "0x0", "start_number": "0x0" } } ``` -------------------------------- ### Example CellOutput JSON Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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. ```json { "capacity": "0x2540be400", "lock": { "code_hash": "0x28e83a1277d48add8e72fadaa9248559e1b632bab2bd60b27955ebc4c03800a5", "hash_type": "data", "args": "0x" }, "type": null } ``` -------------------------------- ### Running CKB with Rich-Indexer (SQLite) Source: https://github.com/nervosnetwork/ckb/blob/develop/util/rich-indexer/README.md 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. ```bash ckb run -C --rich-indexer ``` -------------------------------- ### Example CKB Block Header JSON Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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. ```json { "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" } ``` -------------------------------- ### CKB Indexer get_cells RPC Response Example Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md An example of the JSON response structure returned by the CKB Indexer get_cells RPC method, showing a list of cell objects. ```json { "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 } ``` -------------------------------- ### Enable CKB node service on boot Source: https://github.com/nervosnetwork/ckb/blob/develop/devtools/init/linux-systemd/README.md Configures the systemd service for the CKB node to automatically start when the system boots. ```bash sudo systemctl enable ckb.service ``` -------------------------------- ### Example CellInfo JSON Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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. ```json { "data": { "content": "0x7f454c460201010000000000000000000200f3000100000078000100000000004000000000000000980000000000000005000000400038000100400003000200010000000500000000000000000000000000010000000000000001000000000082000000000000008200000000000000001000000000000001459308d00573000000002e7368737472746162002e74657874000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000b000000010000000600000000000000780001000000000078000000000000000a0000000000000000000000000000000200000000000000000000000000000001000000030000000000000000000000000000000000000082000000000000001100000000000000000000000000000001000000000000000000000000000000", "hash": "0x28e83a1277d48add8e72fadaa9248559e1b632bab2bd60b27955ebc4c03800a5" }, "output": { "capacity": "0x802665800", "lock": { "args": "0x", "code_hash": "0x0000000000000000000000000000000000000000000000000000000000000000", "hash_type": "data" }, "type": null } } ``` -------------------------------- ### Example CellInput JSON Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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. ```json { "previous_output": { "index": "0x0", "tx_hash": "0x365698b50ca0da75dca2c87f9e7b563811d3b5813736b8cc62cc3b106faceb17" }, "since": "0x0" } ``` -------------------------------- ### Get Transaction and Witness Proof RPC Request (JSON) Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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. ```json { "id": 42, "jsonrpc": "2.0", "method": "get_transaction_and_witness_proof", "params": [ [ "0xa4037a893eb48e18ed4ef61034ce26eba9c585f15c9cee102ae58505565eccc3" ] ] } ``` -------------------------------- ### Get Transaction and Witness Proof RPC Response (JSON) Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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. ```json { "jsonrpc": "2.0", "result": { "block_hash": "0x7978ec7ce5b507cfb52e149e36b1a23f6062ed150503c85bbf825da3599095ed", "transactions_proof": { "indices": [ "0x0" ], "lemmas": [] }, "witnesses_proof": { "indices": [ "0x0" ], "lemmas": [] } }, "id": 42 } ``` -------------------------------- ### Setup CKB user, group, and permissions Source: https://github.com/nervosnetwork/ckb/blob/develop/devtools/init/linux-systemd/README.md 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. ```bash 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 ``` -------------------------------- ### Example CellData JSON Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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. ```json { "content": "0x7f454c460201010000000000000000000200f3000100000078000100000000004000000000000000980000000000000005000000400038000100400003000200010000000500000000000000000000000000010000000000000001000000000082000000000000008200000000000000001000000000000001459308d00573000000002e7368737472746162002e74657874000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000b000000010000000600000000000000780001000000000078000000000000000a0000000000000000000000000000000200000000000000000000000000000001000000030000000000000000000000000000000000000082000000000000001100000000000000000000000000000001000000000000000000000000000000", "hash": "0x28e83a1277d48add8e72fadaa9248559e1b632bab2bd60b27955ebc4c03800a5" } ``` -------------------------------- ### Subscription Push Message Example (JSON) Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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. ```json { "jsonrpc": "2.0", "method": "subscribe", "params": { "result": { ... }, "subscription": "0x2a" } } ``` -------------------------------- ### Running CKB with Rich-Indexer (PostgreSQL) Source: https://github.com/nervosnetwork/ckb/blob/develop/util/rich-indexer/README.md 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. ```bash ckb run -C --rich-indexer ``` -------------------------------- ### Enable CKB miner service on boot Source: https://github.com/nervosnetwork/ckb/blob/develop/devtools/init/linux-systemd/README.md Configures the systemd service for the CKB miner to automatically start when the system boots. ```bash sudo systemctl enable ckb-miner.service ``` -------------------------------- ### Request estimate_fee_rate CKB RPC (JSON) Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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. ```json { "id": 42, "jsonrpc": "2.0", "method": "estimate_fee_rate", "params": [] } ``` -------------------------------- ### Example CellWithStatus Unknown State (JSON) Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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. ```json { "cell": null, "status": "unknown" } ``` -------------------------------- ### Starting CKB Built-in Miner (Shell) Source: https://github.com/nervosnetwork/ckb/blob/develop/docs/dev-miner.md 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. ```Shell ckb miner ``` -------------------------------- ### Example CellDep JSON Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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. ```json { "dep_type": "code", "out_point": { "index": "0x0", "tx_hash": "0xa4037a893eb48e18ed4ef61034ce26eba9c585f15c9cee102ae58505565eccc3" } } ``` -------------------------------- ### Subscribe to CKB RPC Topic - JSON Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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. ```json { "id": 42, "jsonrpc": "2.0", "method": "subscribe", "params": [ "new_tip_header" ] } ``` -------------------------------- ### Response get_deployments_info RPC (JSON) Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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. ```json { "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" } } } } } ``` -------------------------------- ### Configure CKB Logger Filter - All Info (Text) Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md Example configuration string for the `filter` field of `ExtraLoggerConfig`. Sets the log level to 'info' for all modules in the CKB node. ```text info ``` -------------------------------- ### WebSocket RPC Subscription Example (JavaScript) Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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. ```javascript 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"]}`) ``` -------------------------------- ### Run CKB Fuzz Test Source: https://github.com/nervosnetwork/ckb/blob/develop/script/fuzz/README.md Executes a specific fuzz test target (`transaction_scripts_verifier_data1`) using `cargo-fuzz` with the nightly Rust toolchain, utilizing all available CPU cores. ```Shell cargo +nightly fuzz run -j $(nproc) transaction_scripts_verifier_data1 ``` -------------------------------- ### CKB RPC Alert Type Example - JSON Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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. ```json { "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" ] } ``` -------------------------------- ### Request get_indexer_tip CKB Indexer RPC (JSON) Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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. ```json { "id": 2, "jsonrpc": "2.0", "method": "get_indexer_tip" } ``` -------------------------------- ### Example OutPoint JSON Object Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md Illustrates the structure and typical values of the `OutPoint` JSON object, which references a cell by its transaction hash and output index. ```JSON { "index": "0x0", "tx_hash": "0x365698b50ca0da75dca2c87f9e7b563811d3b5813736b8cc62cc3b106faceb17" } ``` -------------------------------- ### Example LocalNode JSON Object Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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. ```JSON { "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)" } ``` -------------------------------- ### Request get_deployments_info RPC (JSON) Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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. ```json { "id": 42, "jsonrpc": "2.0", "method": "get_deployments_info", "params": [] } ``` -------------------------------- ### Calling get_pool_tx_detail_info RPC (JSON Request) Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md Example JSON request payload to invoke the `get_pool_tx_detail_info` RPC method, querying details for a specific transaction hash in the pool. ```JSON { "id": 42, "jsonrpc": "2.0", "method": "get_pool_tx_detail_info", "params": [ "0xa0ef4eb5f4ceeb08a4c8524d84c5da95dce2f608e0ca2ec8091191b0f330c6e3" ] } ``` -------------------------------- ### Calling set_network_active RPC Method - JSON Request Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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`. ```json { "id": 42, "jsonrpc": "2.0", "method": "set_network_active", "params": [ false ] } ``` -------------------------------- ### Verify Transaction and Witness Proof RPC Request (JSON) Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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`. ```json { "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": [] } } ] } ``` -------------------------------- ### Calling tx_pool_ready RPC (JSON Request) Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md Example JSON request payload to invoke the `tx_pool_ready` RPC method, which checks if the transaction pool service is ready. ```JSON { "id": 42, "jsonrpc": "2.0", "method": "tx_pool_ready", "params": [] } ``` -------------------------------- ### Response for get_fork_block (JSON) Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md Example JSON response received from the `get_fork_block` RPC method. It contains detailed information about the requested block, including header, transactions, and uncles. ```json { "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": [] } } ``` -------------------------------- ### get_pool_tx_detail_info RPC Result (JSON Response) Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md Example JSON response received after calling the `get_pool_tx_detail_info` RPC method, providing detailed information about a specific transaction in the pool. ```JSON { "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 } ``` -------------------------------- ### Response get_indexer_tip CKB Indexer RPC (JSON) Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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. ```json { "jsonrpc": "2.0", "result": { "block_hash": "0x4959d6e764a2edc6038dbf03d61ebcc99371115627b186fdcccb2161fbd26edc", "block_number": "0x5b513e" }, "id": 2 } ``` -------------------------------- ### Request JSON for get_block_template Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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. ```json { "id": 42, "jsonrpc": "2.0", "method": "get_block_template", "params": [ null, null, null ] } ``` -------------------------------- ### clear_tx_verify_queue RPC Result (JSON Response) Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md Example JSON response received after successfully calling the `clear_tx_verify_queue` RPC method. The result is `null`. ```JSON { "id": 42, "jsonrpc": "2.0", "result": null } ``` -------------------------------- ### Requesting a Block by Number (JSON) Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md Example JSON request payload for the `get_block_by_number` RPC method, specifying the block number '0x400' to retrieve details for. ```json { "id": 42, "jsonrpc": "2.0", "method": "get_block_by_number", "params": [ "0x400" ] } ``` -------------------------------- ### Response get_transaction_proof JSON Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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. ```JSON { "id": 42, "jsonrpc": "2.0", "result": { "block_hash": "0x7978ec7ce5b507cfb52e149e36b1a23f6062ed150503c85bbf825da3599095ed", "proof": { "indices": [ "0x0" ], "lemmas": [] }, "witnesses_root": "0x2bb631f4a251ec39d943cc238fc1e39c7f0e99776e8a1e7be28a03c70c4f4853" } } ``` -------------------------------- ### Calling set_ban RPC Method - JSON Request Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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. ```json { "id": 42, "jsonrpc": "2.0", "method": "set_ban", "params": [ "192.168.0.2", "insert", "0x1ac89236180", true, "set_ban example" ] } ``` -------------------------------- ### Generate Fuzz Test Coverage Report Source: https://github.com/nervosnetwork/ckb/blob/develop/script/fuzz/README.md 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. ```Shell 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 ``` -------------------------------- ### Response for get_block_by_number (Verbosity 2, JSON) Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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. ```json { "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": [] } } ``` -------------------------------- ### ping_peers RPC Method - JSON Response Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md Example JSON RPC response for a successful call to the `ping_peers` method. A successful operation returns `null` in the result field. ```json { "id": 42, "jsonrpc": "2.0", "result": null } ``` -------------------------------- ### Response for get_fork_block (Verbosity 0) Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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. ```text { "id": 42, "jsonrpc": "2.0", "result": "0x..." } ``` -------------------------------- ### add_node RPC Method - JSON Response Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md Example JSON RPC response for a successful call to the `add_node` method. A successful operation returns `null` in the result field. ```json { "id": 42, "jsonrpc": "2.0", "result": null } ``` -------------------------------- ### CKB Indexer Cells Capacity Response (JSON) Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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. ```JSON { "jsonrpc": "2.0", "result": { "block_hash": "0xbc52444952dc5eb01a7826aaf6bb1b660db0179797414e259e7a6e6d636de8fc7c", "block_number": "0x5b727a", "capacity": "0xf0e8e4b4a0" }, "id": 2 } ``` -------------------------------- ### Requesting a Block by Hash (get_block) - JSON Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md Example JSON request payload for calling the `get_block` RPC method with a specific block hash to retrieve block information. ```JSON { "id": 42, "jsonrpc": "2.0", "method": "get_block", "params": [ "0xa5f5c85987a15de25661e5a214f2c1449cd803f071acc7999820f25246471f40" ] } ``` -------------------------------- ### Calling sync_state RPC Method - JSON Request Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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. ```json { "id": 42, "jsonrpc": "2.0", "method": "sync_state", "params": [] } ``` -------------------------------- ### Calling clear_tx_verify_queue RPC (JSON Request) Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md Example JSON request payload to invoke the `clear_tx_verify_queue` RPC method, which removes all transactions from the verification queue. ```JSON { "id": 42, "jsonrpc": "2.0", "method": "clear_tx_verify_queue", "params": [] } ``` -------------------------------- ### Request get_blockchain_info RPC (JSON) Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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. ```json { "id": 42, "jsonrpc": "2.0", "method": "get_blockchain_info", "params": [] } ``` -------------------------------- ### set_network_active RPC Method - JSON Response Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md Example JSON RPC response for a successful call to the `set_network_active` method. A successful operation returns `null` in the result field. ```json { "id": 42, "jsonrpc": "2.0", "result": null } ``` -------------------------------- ### Response JSON for get_block_template Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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. ```json { "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" } } ``` -------------------------------- ### Verify Transaction Proof RPC Response (JSON) Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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. ```json { "id": 42, "jsonrpc": "2.0", "result": [ "0xa4037a893eb48e18ed4ef61034ce26eba9c585f15c9cee102ae58505565eccc3" ] } ``` -------------------------------- ### tx_pool_ready RPC Result (JSON Response) Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md Example JSON response received after calling the `tx_pool_ready` RPC method, indicating whether the transaction pool service is ready (`true` or `false`). ```JSON { "id": 42, "jsonrpc": "2.0", "result": true } ``` -------------------------------- ### Calling get_raw_tx_pool RPC (JSON Request) Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md Example JSON request payload to invoke the `get_raw_tx_pool` RPC method with `verbose` set to `true`, requesting detailed transaction pool information. ```JSON { "id": 42, "jsonrpc": "2.0", "method": "get_raw_tx_pool", "params": [true] } ``` -------------------------------- ### Requesting a Fork Block (JSON) Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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. ```json { "id": 42, "jsonrpc": "2.0", "method": "get_fork_block", "params": [ "0xdca341a42890536551f99357612cef7148ed471e3b6419d0844a4e400be6ee94" ] } ``` -------------------------------- ### Response get_blockchain_info RPC (JSON) Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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. ```json { "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" } } ``` -------------------------------- ### Requesting Fee Rate Statistics (get_fee_rate_statistics) - JSON Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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. ```json { "id": 42, "jsonrpc": "2.0", "method": "get_fee_rate_statistics", "params": [] } ``` -------------------------------- ### Verify Transaction Proof RPC Request (JSON) Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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. ```json { "id": 42, "jsonrpc": "2.0", "method": "verify_transaction_proof", "params": [ { "block_hash": "0x7978ec7ce5b507cfb52e149e36b1a23f6062ed150503c85bbf825da3599095ed", "proof": { "indices": [ "0x0" ], "lemmas": [] }, "witnesses_root": "0x2bb631f4a251ec39d943cc238fc1e39c7f0e99776e8a1e7be28a03c70c4f4853" } ] } ``` -------------------------------- ### Initialize CKB data directory and config Source: https://github.com/nervosnetwork/ckb/blob/develop/devtools/init/linux-systemd/README.md Creates the data directory for CKB and initializes the configuration files for joining the mainnet, directing logs to stdout. ```bash sudo mkdir /var/lib/ckb sudo /usr/local/bin/ckb init -C /var/lib/ckb --chain mainnet --log-to stdout ``` -------------------------------- ### get_raw_tx_pool RPC Result (JSON Response) Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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. ```JSON { "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": {} } } ``` -------------------------------- ### set_ban RPC Method - JSON Response Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md Example JSON RPC response for a successful call to the `set_ban` method. A successful operation returns `null` in the result field. ```json { "id": 42, "jsonrpc": "2.0", "result": null } ``` -------------------------------- ### Request get_transaction_proof JSON Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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. ```JSON { "id": 42, "jsonrpc": "2.0", "method": "get_transaction_proof", "params": [ [ "0xa4037a893eb48e18ed4ef61034ce26eba9c585f15c9cee102ae58505565eccc3" ] ] } ``` -------------------------------- ### Calling ping_peers RPC Method - JSON Request Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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. ```json { "id": 42, "jsonrpc": "2.0", "method": "ping_peers", "params": [] } ``` -------------------------------- ### Verify Transaction and Witness Proof RPC Response (JSON) Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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. ```json { "id": 42, "jsonrpc": "2.0", "result": [ "0xa4037a893eb48e18ed4ef61034ce26eba9c585f15c9cee102ae58505565eccc3" ] } ``` -------------------------------- ### Response Format for get_block_by_number (with_cycles, JSON) Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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. ```json { "id": 42, "jsonrpc": "2.0", "result": { "block": " or \"0x...\"", "cycles": [] } } ``` -------------------------------- ### sync_state RPC Method - JSON Response Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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. ```json { "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" } } ``` -------------------------------- ### Configure CKB Logger Filter - Specific Debug (Text) Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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. ```text info,ckb-rpc=debug,ckb-sync=debug,ckb-relay=debug,ckb-tx-pool=debug,ckb-network=debug ``` -------------------------------- ### Successful get_block Response (with_cycles) - JSON Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md Example JSON response structure returned by the `get_block` RPC method when `with_cycles` is true, including the block data and transaction cycles. ```JSON { "id": 42, "jsonrpc": "2.0", "result": { "block": " or \"0x...\"", "cycles": [] } } ``` -------------------------------- ### CKB RPC Subscribe Response - JSON Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md Example JSON response received after successfully subscribing to a CKB RPC topic. The `result` field contains the subscription ID, which is a string. ```json { "id": 42, "jsonrpc": "2.0", "result": "0xf3" } ``` -------------------------------- ### Request get_block_economic_state JSON Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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. ```JSON { "id": 42, "jsonrpc": "2.0", "method": "get_block_economic_state", "params": [ "0x02530b25ad0ff677acc365cb73de3e8cc09c7ddd58272e879252e199d08df83b" ] } ``` -------------------------------- ### Response Format for get_block_by_number (Verbosity 0, JSON) Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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. ```json { "id": 42, "jsonrpc": "2.0", "result": "0x..." } ``` -------------------------------- ### CKB Integration Test Process Block Response (JSON) Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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. ```JSON { "id": 42, "jsonrpc": "2.0", "result": "0xa5f5c85987a15de25661e5a214f2c1449cd803f071acc7999820f25246471f40" } ``` -------------------------------- ### Request get_epoch_by_number JSON Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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. ```JSON { "id": 42, "jsonrpc": "2.0", "method": "get_epoch_by_number", "params": [ "0x0" ] } ``` -------------------------------- ### Successful get_block Response (verbosity 2) - JSON Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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. ```JSON { "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": [] } } ``` -------------------------------- ### Response get_block_economic_state JSON Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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. ```JSON { "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" } } ``` -------------------------------- ### Requesting Deprecated Fee Rate Statistics (get_fee_rate_statics) - JSON Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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. ```json { "id": 42, "jsonrpc": "2.0", "method": "get_fee_rate_statics", "params": [] } ``` -------------------------------- ### Initialize CKB with Secp256k1 Block Assembler (Shell) Source: https://github.com/nervosnetwork/ckb/blob/develop/CHANGELOG.md 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. ```Shell ckb init $(ckb cli secp256k1-lock --format cmd) ``` -------------------------------- ### remove_node RPC Method - JSON Response Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md Example JSON RPC response for a successful call to the `remove_node` method. A successful operation returns `null` in the result field. ```json { "id": 42, "jsonrpc": "2.0", "result": null } ``` -------------------------------- ### CKB Indexer get_cells RPC Response - Filter by Capacity Range Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md An example response for a get_cells request filtered by output capacity range, showing a cell object with a capacity within the requested range. ```json { "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 } ``` -------------------------------- ### View CKB Integration Test Options Source: https://github.com/nervosnetwork/ckb/blob/develop/test/README.md Displays all available command-line options for running the CKB integration tests using `cargo run`. ```bash cargo run -- --help ``` -------------------------------- ### CKB RPC Unsubscribe Response - JSON Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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. ```json { "id": 42, "jsonrpc": "2.0", "result": true } ``` -------------------------------- ### Successful get_block Response (verbosity 0) - JSON Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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. ```JSON { "id": 42, "jsonrpc": "2.0", "result": "0x..." } ``` -------------------------------- ### Calling add_node RPC Method - JSON Request Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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. ```json { "id": 42, "jsonrpc": "2.0", "method": "add_node", "params": [ "QmUsZHPbjjzU627UZFt4k8j6ycEcNvXRnVGxCPKqwbAfQS", "/ip4/192.168.2.100/tcp/8114" ] } ``` -------------------------------- ### Unsubscribe from CKB RPC Topic - JSON Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md Example JSON request to unsubscribe from a previously subscribed CKB RPC topic. The `params` array contains the subscription ID obtained from the subscribe response. ```json { "id": 42, "jsonrpc": "2.0", "method": "unsubscribe", "params": [ "0xf3" ] } ``` -------------------------------- ### Export Testnet Configuration (Shell) Source: https://github.com/nervosnetwork/ckb/blob/develop/docs/configure.md Initializes the current directory with configuration files specifically tailored for the Pudge testnet. Use this to set up a testnet node. ```Shell ckb init --chain testnet ``` -------------------------------- ### Response estimate_fee_rate CKB RPC (JSON) Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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. ```json { "id": 42, "jsonrpc": "2.0", "result": "0x3e8" } ``` -------------------------------- ### Control CKB Miner Limit (Bash) Source: https://github.com/nervosnetwork/ckb/blob/develop/CHANGELOG.md 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. ```bash 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 ``` -------------------------------- ### Alert Send Failure Response (JSON) Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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. ```JSON { "error": { "code": -1000, "data": "SigNotEnough", "message":"AlertFailedToVerifySignatures: The count of sigs is less than threshold." }, "jsonrpc": "2.0", "result": null, "id": 42 } ``` -------------------------------- ### CKB Indexer get_cells RPC Response - Filter by Script Length Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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. ```json { "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 } ``` -------------------------------- ### Submitting Transaction to Pool (send_transaction) - CKB RPC - JSON Request Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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". ```JSON { "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" ] } ``` -------------------------------- ### Requesting calculate_dao_maximum_withdraw RPC (JSON) Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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. ```JSON { "id": 42, "jsonrpc": "2.0", "method": "calculate_dao_maximum_withdraw", "params": [ { "index": "0x0", "tx_hash": "0xa4037a893eb48e18ed4ef61034ce26eba9c585f15c9cee102ae58505565eccc3" }, "0xa5f5c85987a15de25661e5a214f2c1449cd803f071acc7999820f25246471f40" ] } ``` -------------------------------- ### Generating CKB Peer IDs via Command Line Source: https://github.com/nervosnetwork/ckb/blob/develop/CHANGELOG.md 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. ```Shell ckb peer-id gen --secret_path ./a.txt ckb peer-id from-secret --secret-path ./a.txt ``` -------------------------------- ### Submitting Transaction to Pool (send_transaction) - CKB RPC - JSON Response Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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. ```JSON { "id": 42, "jsonrpc": "2.0", "result": "0xa0ef4eb5f4ceeb08a4c8524d84c5da95dce2f608e0ca2ec8091191b0f330c6e3" } ``` -------------------------------- ### Response: Get Cells by Lock and Type Script (CKB RPC) Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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. ```json { "jsonrpc": "2.0", "result": { "last_cursor": "0x4058c5f491aba6d61678b7cf7edf4910b1f5e00ec0cde2f42e0abb4fd9aff25a63012a49720e721553d0614dff29454ee4e1f07d070700000000002adf870000000100000001", "objects": [ { "block_number": "0x2adf87", "out_point": { "index": "0x1", ``` -------------------------------- ### RPC Request: get_block_median_time (JSON) Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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. ```json { "id": 42, "jsonrpc": "2.0", "method": "get_block_median_time", "params": [ "0xa5f5c85987a15de25661e5a214f2c1449cd803f071acc7999820f25246471f40" ] } ``` -------------------------------- ### Initialize CKB Configuration Files (Shell) Source: https://github.com/nervosnetwork/ckb/blob/develop/docs/configure.md Exports the bundled default CKB configuration files into the current working directory. This is the first step to customize node settings. ```Shell ckb init ``` -------------------------------- ### Response: Get Cells by Lock Script (CKB RPC) Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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. ```json { "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 } ``` -------------------------------- ### Calling remove_node RPC Method - JSON Request Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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. ```json { "id": 42, "jsonrpc": "2.0", "method": "remove_node", "params": [ "QmUsZHPbjjzU627UZFt4k8j6ycEcNvXRnVGxCPKqwbAfQS" ] } ``` -------------------------------- ### Request: Get Cells by Lock and Type Script (CKB RPC) Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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. ```json { "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" ] } ``` -------------------------------- ### Response for Get Transactions by Lock Script - CKB RPC - JSON Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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`. ```json { "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" } ``` -------------------------------- ### List Supported CKB Chains (Shell) Source: https://github.com/nervosnetwork/ckb/blob/develop/docs/configure.md Displays a list of all supported chain specifications that can be used with the `ckb init` command to export specific chain configurations. ```Shell ckb init --list-chains ``` -------------------------------- ### Request: Get Cells by Lock Script (CKB RPC) Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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'). ```json { "id": 2, "jsonrpc": "2.0", "method": "get_cells", "params": [ { "script": { "code_hash": "0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8", "hash_type": "type", "args": "0x5989ae415bb667931a99896e5fbbfad9ba53a223" }, "script_type": "lock" }, "asc", "0x64" ] } ``` -------------------------------- ### Configuring CKB Rich-Indexer for PostgreSQL (TOML) Source: https://github.com/nervosnetwork/ckb/blob/develop/util/rich-indexer/README.md Configuration settings in ckb.toml to specify connection parameters for using a PostgreSQL database with the CKB Rich-Indexer instead of the default SQLite. ```toml # 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" ``` -------------------------------- ### Run Multiple CKB Nodes (Shell) Source: https://github.com/nervosnetwork/ckb/blob/develop/docs/configure.md 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. ```Shell 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 ``` -------------------------------- ### Initializing CKB Dev Chain for Mining Test (Shell) Source: https://github.com/nervosnetwork/ckb/blob/develop/docs/dev-miner.md 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. ```Shell mkdir ckb-dev-miner-test cd ckb-dev-miner-test ckb init --chain dev --ba-arg 0x470dcdc5e44064909650113a274b3b36aecb6dc7 ``` -------------------------------- ### Configuring CKB Rich-Indexer Filters (TOML) Source: https://github.com/nervosnetwork/ckb/blob/develop/util/rich-indexer/README.md 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. ```toml # 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" ``` -------------------------------- ### Configure Dummy PoW Engine (TOML) Source: https://github.com/nervosnetwork/ckb/blob/develop/docs/configure.md 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. ```TOML [pow] func = "Dummy" ``` -------------------------------- ### Build CKB Test Scripts with Docker Source: https://github.com/nervosnetwork/ckb/blob/develop/script/testdata/README.md This command uses the Makefile within a Docker environment to build all test scripts for the CKB project. It assumes dependencies have been downloaded. ```shell make all-in-docker ``` -------------------------------- ### Run CKB Integration Tests (Default) Source: https://github.com/nervosnetwork/ckb/blob/develop/test/README.md 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. ```bash cargo run ``` -------------------------------- ### Requesting CKB Integration Test Process Block (JSON) Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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. ```JSON { "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 ] } ``` -------------------------------- ### Configuring PostgreSQL Shared Buffers Source: https://github.com/nervosnetwork/ckb/blob/develop/util/rich-indexer/README.md Recommended PostgreSQL configuration parameter to adjust the amount of memory dedicated to shared memory buffers, improving query performance for the CKB Rich-Indexer. ```conf #------------------------------------------------------------------------------ # RESOURCE USAGE (except WAL) #------------------------------------------------------------------------------ # - Memory - shared_buffers = 2GB # min 128kB ``` -------------------------------- ### Requesting CKB Indexer Cells Capacity (JSON) Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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'). ```JSON { "id": 2, "jsonrpc": "2.0", "method": "get_cells_capacity", "params": [ { "script": { "code_hash": "0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8", "hash_type": "type", "args": "0x5989ae415bb667931a99896e5fbbfad9ba53a223" }, "script_type": "lock" } ] } ``` -------------------------------- ### Calling test_tx_pool_accept RPC (JSON) - Request Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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". ```json { "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" ] } ``` -------------------------------- ### Response for Fee Rate Statistics (get_fee_rate_statistics) - JSON Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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. ```json { "id": 42, "jsonrpc": "2.0", "result": { "mean": "0xe79d", "median": "0x14a8" } } ``` -------------------------------- ### Requesting dry_run_transaction RPC (JSON) Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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. ```JSON { "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": [] } ] } ``` -------------------------------- ### Configure Eaglesong PoW Engine (TOML) Source: https://github.com/nervosnetwork/ckb/blob/develop/docs/configure.md Sets the Proof-of-Work function to 'Eaglesong' in the CKB configuration file. This is typically used for the mainnet (Mirana). ```TOML [pow] func = "Eaglesong" ``` -------------------------------- ### Response for Transaction Cycle Estimation (estimate_cycles) - JSON Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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. ```json { "id": 42, "jsonrpc": "2.0", "result": { "cycles": "0x219" } } ``` -------------------------------- ### Header Response by Hash (JSON, Verbosity 1) Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md JSON response payload for the `get_header` RPC method when verbosity is 1, showing a detailed block header object. ```json { "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" } } ``` -------------------------------- ### Configuring CKB Built-in Miner (Diff) Source: https://github.com/nervosnetwork/ckb/blob/develop/docs/dev-miner.md 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. ```Diff - worker_type = "Dummy" - delay_type = "Constant" - value = 9500 + worker_type = "EaglesongSimple" + threads = 1 ``` -------------------------------- ### Configure EaglesongBlake2b PoW Engine (TOML) Source: https://github.com/nervosnetwork/ckb/blob/develop/docs/configure.md Sets the Proof-of-Work function to 'EaglesongBlake2b'. This variant is commonly used for the testnet (Pudge) and requires corresponding miner worker configuration. ```TOML [pow] func = "EaglesongBlake2b" ``` -------------------------------- ### Response for Deprecated Fee Rate Statistics (get_fee_rate_statics) - JSON Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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. ```json { "id": 42, "jsonrpc": "2.0", "result": { "mean": "0xe79d", "median": "0x14a8" } } ``` -------------------------------- ### Configuration File Changes for Notifier Service Source: https://github.com/nervosnetwork/ckb/blob/develop/CHANGELOG.md 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`. ```Configuration Diff -# [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" ``` -------------------------------- ### Header Response by Hash (Text, Verbosity 0) Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md Text response payload for the `get_header` RPC method when verbosity is 0, showing a simplified result as a hex string. ```text { "id": 42, "jsonrpc": "2.0", "result": "0x..." } ``` -------------------------------- ### Sending an Alert (JSON Request) Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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. ```JSON { "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 } ``` -------------------------------- ### View CKB node service logs Source: https://github.com/nervosnetwork/ckb/blob/develop/devtools/init/linux-systemd/README.md Shows the journal logs for the CKB node systemd service since the last boot, useful for debugging issues. ```bash sudo journalctl --boot -u ckb.service ``` -------------------------------- ### Modifying CKB Dev Chain PoW Algorithm (Diff) Source: https://github.com/nervosnetwork/ckb/blob/develop/docs/dev-miner.md 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. ```Diff - func = "Dummy" + func = "Eaglesong" ``` -------------------------------- ### Local Node Info RPC Request (JSON) Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md JSON request payload for the `local_node_info` RPC method. This method requires no parameters. ```json { "id": 42, "jsonrpc": "2.0", "method": "local_node_info", "params": [] } ``` -------------------------------- ### Run Rust Tests with Failpoints (Shell) Source: https://github.com/nervosnetwork/ckb/blob/develop/freezer/README.md 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. ```Shell cargo test --features fail/failpoints -- --test-threads=1 ``` -------------------------------- ### RPC Response: get_consensus (JSON) Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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. ```json { "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" } } ``` -------------------------------- ### Run Specific CKB Integration Tests Source: https://github.com/nervosnetwork/ckb/blob/develop/test/README.md Runs only the specified integration test specifications (e.g., `spec1`, `spec2`) using `cargo run`. Requires specifying the path to the CKB debug binary. ```bash cargo run -- --bin ../target/debug/ckb spec1 spec2 ``` -------------------------------- ### Requesting Header by Hash (JSON) Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md JSON request payload for the `get_header` RPC method, querying a block header using its hash. ```json { "id": 42, "jsonrpc": "2.0", "method": "get_header", "params": [ "0xa5f5c85987a15de25661e5a214f2c1449cd803f071acc7999820f25246471f40" ] } ``` -------------------------------- ### Generate CKB Epochs RPC Request (Text) - Fractional Input Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md Text RPC request payload to call the `generate_epochs` method with a fractional epoch number input, represented as a hex string in `EpochNumberWithFraction` format. ```text { "id": 42, "jsonrpc": "2.0", "method": "generate_epochs", "params": ["0x20001000000"] } ``` -------------------------------- ### Check CKB Daemon Status (Bash) Source: https://github.com/nervosnetwork/ckb/blob/develop/devtools/init/README.md Checks the current status of the CKB daemon process to see if it is running. ```bash ckb daemon --check ``` -------------------------------- ### Configure Dummy Miner Worker (TOML) Source: https://github.com/nervosnetwork/ckb/blob/develop/docs/configure.md 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. ```TOML [[miner.workers]] worker_type = "Dummy" delay_type = "Constant" value = 5000 ``` -------------------------------- ### test_tx_pool_accept RPC (JSON) - Success Response Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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. ```json { "id": 42, "jsonrpc": "2.0", "result": { "cycles": "0x219", "fee": "0x2a66f36e90" } } ``` -------------------------------- ### Generate CKB Epochs RPC Request (JSON) - Integer Input Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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`. ```json { "id": 42, "jsonrpc": "2.0", "method": "generate_epochs", "params": ["0x2"] } ``` -------------------------------- ### Requesting Transaction Cycle Estimation (estimate_cycles) - JSON Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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. ```json { "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": [] } ] } ``` -------------------------------- ### Local Node Info RPC Response (JSON) Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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. ```json { "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)" } } ``` -------------------------------- ### Requesting Transaction Details - CKB RPC - JSON Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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. ```json { "id": 42, "jsonrpc": "2.0", "method": "get_transaction", "params": [ "0xa0ef4eb5f4ceeb08a4c8524d84c5da95dce2f608e0ca2ec8091191b0f330c6e3" ] } ``` -------------------------------- ### Calling tx_pool_info RPC (JSON) - Request Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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. ```json { "id": 42, "jsonrpc": "2.0", "method": "tx_pool_info", "params": [] } ``` -------------------------------- ### Run CKB in Daemon Mode (Bash) Source: https://github.com/nervosnetwork/ckb/blob/develop/devtools/init/README.md Runs the CKB node process in daemon mode, detaching it from the terminal. This mode is specifically for Linux/MacOS systems. ```bash ckb run --daemon ``` -------------------------------- ### Header Response by Number (JSON, Verbosity 1) Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md JSON response payload for the `get_header_by_number` RPC method when verbosity is 1, showing a detailed block header object. ```json { "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" } } ``` -------------------------------- ### Reinstalling Rust Stable Toolchain Source: https://github.com/nervosnetwork/ckb/blob/develop/CHANGELOG.md 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. ```Shell rustup self update rustup toolchain uninstall stable rustup toolchain install stable ``` -------------------------------- ### CKB Indexer get_cells RPC Request - Filter by Capacity Range Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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. ```json { "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" ] } ``` -------------------------------- ### Header Response by Number (Text, Verbosity 0) Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md Text response payload for the `get_header_by_number` RPC method when verbosity is 0, showing a simplified result as a hex string. ```text { "id": 42, "jsonrpc": "2.0", "result": "0x..." } ``` -------------------------------- ### Disabling PostgreSQL JIT Compilation Source: https://github.com/nervosnetwork/ckb/blob/develop/util/rich-indexer/README.md 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. ```conf #------------------------------------------------------------------------------ # QUERY TUNING #------------------------------------------------------------------------------ # - Other Planner Options - jit = off # allow JIT compilation ``` -------------------------------- ### tx_pool_info RPC (JSON) - Response Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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. ```json { "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" } } ``` -------------------------------- ### RPC Response: generate_block_with_template (JSON) Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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. ```json { "id": 42, "jsonrpc": "2.0", "result": "0x899541646ae412a99fdbefc081e1a782605a7815998a096af16e51d4df352c75" } ``` -------------------------------- ### Importing CKB PGP Public Key (gpg) Source: https://github.com/nervosnetwork/ckb/blob/develop/docs/integrity-check.md 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. ```Shell gpg --recv-keys E21C4F2E34FF2E93 ``` -------------------------------- ### RPC Request: generate_block_with_template (JSON) Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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. ```json { "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" } ] } ``` -------------------------------- ### RPC Response: get_block_median_time (JSON) Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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. ```json { "id": 42, "jsonrpc": "2.0", "result": "0x5cd2b105" } ``` -------------------------------- ### Requesting Block Hash by Number - CKB RPC - JSON Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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. ```json { "id": 42, "jsonrpc": "2.0", "method": "get_block_hash", "params": [ "0x400" ] } ``` -------------------------------- ### Stop CKB Daemon Process (Bash) Source: https://github.com/nervosnetwork/ckb/blob/develop/devtools/init/README.md Sends a signal to the running CKB daemon process to stop it gracefully. ```bash ckb daemon --stop ``` -------------------------------- ### Add Fields to tx_pool_info RPC Output (JSON) Source: https://github.com/nervosnetwork/ckb/blob/develop/CHANGELOG.md 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. ```JSON + "total_tx_cycles": "2", + "total_tx_size": "156", ``` -------------------------------- ### Requesting Block Filter by Hash (JSON) Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md JSON request payload for the `get_block_filter` RPC method, querying a block filter using its block hash. ```json { "id": 42, "jsonrpc": "2.0", "method": "get_block_filter", "params": [ "0xa5f5c85987a15de25661e5a214f2c1449cd803f071acc7999820f25246471f40" ] } ``` -------------------------------- ### Check CKB node service status Source: https://github.com/nervosnetwork/ckb/blob/develop/devtools/init/linux-systemd/README.md Displays the current status of the CKB node systemd service, showing whether it is active and recent log output. ```bash sudo systemctl status ckb.service ``` -------------------------------- ### Response for dry_run_transaction RPC (JSON) Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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. ```JSON { "id": 42, "jsonrpc": "2.0", "result": { "cycles": "0x219" } } ``` -------------------------------- ### RPC Request for send_test_transaction (JSON) Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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. ```json { "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" ] } ``` -------------------------------- ### Receiving Transaction Details (Verbosity 2) - CKB RPC - JSON Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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. ```json { "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 } } } ``` -------------------------------- ### Block Filter Response by Hash (Text, Non-Null Result) Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md Text response payload for the `get_block_filter` RPC method when a block filter is found, showing the data and hash. ```text { "id": 42, "jsonrpc": "2.0", "result": { "data": "0x...", "hash": "0x..." } } ``` -------------------------------- ### Verifying CKB Binary Signature (gpg) Source: https://github.com/nervosnetwork/ckb/blob/develop/docs/integrity-check.md 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. ```Shell gpg --verify ckb_v0.43.0_x86_64-apple-darwin.zip.asc ckb_v0.43.0_x86_64-apple-darwin.zip ``` -------------------------------- ### Generate CKB Block RPC Request (JSON) Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md JSON RPC request payload to call the `generate_block` method, which generates a new block and broadcasts it. ```json { "id": 42, "jsonrpc": "2.0", "method": "generate_block", "params": [] } ``` -------------------------------- ### RPC Request: calculate_dao_field (JSON) Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md This JSON object represents a request to the `calculate_dao_field` RPC method, providing detailed block header information as parameters. ```JSON { "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" } ] } ``` -------------------------------- ### Requesting Transactions by Lock Script - CKB RPC - JSON Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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'). ```json { "id": 2, "jsonrpc": "2.0", "method": "get_transactions", "params": [ { "script": { "code_hash": "0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8", "hash_type": "type", "args": "0x5989ae415bb667931a99896e5fbbfad9ba53a223" }, "script_type": "lock" }, "asc", "0x64" ] } ``` -------------------------------- ### CKB Indexer get_cells RPC Request - Filter by Script Length Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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. ```json { "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" ] } ``` -------------------------------- ### Configure EaglesongSimple Miner Worker (TOML) Source: https://github.com/nervosnetwork/ckb/blob/develop/docs/configure.md 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. ```TOML [[miner.workers]] worker_type = "EaglesongSimple" threads = 1 extra_hash_function = "Blake2b" ``` -------------------------------- ### test_tx_pool_accept RPC (JSON) - Error Response Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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. ```json { "id": 42, "jsonrpc": "2.0", "result": null, "error": { "code": -1107, "data": "Duplicated(Byte32(0xa0ef4eb5f4ceeb08a4c8524d84c5da95dce2f608e0ca2ec8091191b0f330c6e3))", "message": "PoolRejectedDuplicatedTransaction: Transaction(Byte32(0xa0ef4eb5f4ceeb08a4c8524d84c5da95dce2f608e0ca2ec8091191b0f330c6e3)) already exists in transaction_pool" } } ``` -------------------------------- ### Requesting Header by Number (JSON) Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md JSON request payload for the `get_header_by_number` RPC method, querying a block header using its block number. ```json { "id": 42, "jsonrpc": "2.0", "method": "get_header_by_number", "params": [ "0x400" ] } ``` -------------------------------- ### Submit Block RPC Request (JSON) Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md JSON request payload for the `submit_block` RPC method. It includes a `work_id` and the block structure containing header, proposals, transactions, and uncles. ```json { "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": [] } ] } ``` -------------------------------- ### RPC Request: get_consensus (JSON) Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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. ```json { "id": 42, "jsonrpc": "2.0", "method": "get_consensus", "params": [] } ``` -------------------------------- ### Block Filter Response by Hash (JSON, Null Result) Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md JSON response payload for the `get_block_filter` RPC method when no block filter is found for the given hash, returning null. ```json { "id": 42, "jsonrpc": "2.0", "result": null } ``` -------------------------------- ### Receiving Transaction Details (Verbosity 0) - CKB RPC - JSON Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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. ```json { "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 } } } ``` -------------------------------- ### Submit Block RPC Response (JSON) Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md JSON response payload for the `submit_block` RPC method. It typically returns a result hash upon successful submission. ```json { "id": 42, "jsonrpc": "2.0", "result": "0xa5f5c85987a15de25661e5a214f2c1449cd803f071acc7999820f25246471f40" } ``` -------------------------------- ### RPC Response for send_test_transaction (JSON) Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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. ```json { "id": 42, "jsonrpc": "2.0", "result": "0xa0ef4eb5f4ceeb08a4c8524d84c5da95dce2f608e0ca2ec8091191b0f330c6e3" } ``` -------------------------------- ### Update CKB tx_pool Configuration (Config) Source: https://github.com/nervosnetwork/ckb/blob/develop/CHANGELOG.md 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. ```Config [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 ``` -------------------------------- ### Generate CKB Epochs RPC Response (JSON) Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md JSON RPC response payload for a successful `generate_epochs` method call. The result is the updated epoch number after generation. ```json { "id": 42, "jsonrpc": "2.0", "result": "0xa0001000003" } ``` -------------------------------- ### Generate CKB Block RPC Response (JSON) Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md JSON RPC response payload for a successful `generate_block` method call. The result is the hash of the newly generated block. ```json { "id": 42, "jsonrpc": "2.0", "result": "0x60dd3fa0e81db3ee3ad41cf4ab956eae7e89eb71cd935101c26c4d0652db3029" } ``` -------------------------------- ### CKB v0.8.0 Breaking Change: ckb.toml Config Changes Source: https://github.com/nervosnetwork/ckb/blob/develop/CHANGELOG.md 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. ```diff 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. ``` -------------------------------- ### Receiving Block Hash - CKB RPC - JSON Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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. ```json { "id": 42, "jsonrpc": "2.0", "result": "0xa5f5c85987a15de25661e5a214f2c1449cd803f071acc7999820f25246471f40" } ``` -------------------------------- ### Calculating CKB Transaction Fee Rate Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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. ```text fee / (1000 * tx_serialization_size_in_block_in_bytes) ``` -------------------------------- ### Response for calculate_dao_maximum_withdraw RPC (JSON) Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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. ```JSON { "id": 42, "jsonrpc": "2.0", "result": "0x4a8b4e8a4" } ``` -------------------------------- ### RPC Response: calculate_dao_field (JSON) Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md This JSON object represents the successful response from the `calculate_dao_field` RPC method, containing the calculated DAO field value. ```JSON { "id": 42, "jsonrpc": "2.0", "result": "0xd495a106684401001e47c0ae1d5930009449d26e32380000000721efd0030000" } ``` -------------------------------- ### Notify CKB Transaction RPC Request (JSON) Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md JSON RPC request payload to call the `notify_transaction` method, which adds a specified transaction to the transaction pool. Includes a detailed transaction structure. ```json { "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": [] } ] } ``` -------------------------------- ### Truncate CKB Chain RPC Response (JSON) Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md JSON RPC response payload for a successful `truncate` method call. The result is null upon success. ```json { "id": 42, "jsonrpc": "2.0", "result": null } ``` -------------------------------- ### Calling clear_tx_pool RPC (JSON) - Request Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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. ```json { "id": 42, "jsonrpc": "2.0", "method": "clear_tx_pool", "params": [] } ``` -------------------------------- ### Truncate CKB Chain RPC Request (JSON) Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md JSON RPC request payload to call the `truncate` method, which truncates the CKB chain to a specified block hash. ```json { "id": 42, "jsonrpc": "2.0", "method": "truncate", "params": [ "0xa5f5c85987a15de25661e5a214f2c1449cd803f071acc7999820f25246471f40" ] } ``` -------------------------------- ### Notify CKB Transaction RPC Response (JSON) Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md JSON RPC response payload for a successful `notify_transaction` method call. The result is the hash of the added transaction. ```json { "id": 42, "jsonrpc": "2.0", "result": "0xa0ef4eb5f4ceeb08a4c8524d84c5da95dce2f608e0ca2ec8091191b0f330c6e3" } ``` -------------------------------- ### CKB v0.7.0 Breaking Change: Network Config Changes Source: https://github.com/nervosnetwork/ckb/blob/develop/CHANGELOG.md 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. ```diff [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 ``` -------------------------------- ### Updating CKB DB Configuration in JSON Source: https://github.com/nervosnetwork/ckb/blob/develop/CHANGELOG.md 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. ```JSON { + "db": { + "path": "db" + } } ``` -------------------------------- ### clear_tx_pool RPC (JSON) - Response Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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. ```json { "id": 42, "jsonrpc": "2.0", "result": null } ``` -------------------------------- ### Calling remove_transaction RPC (JSON) - Request Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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. ```json { "id": 42, "jsonrpc": "2.0", "method": "remove_transaction", "params": [ "0xa0ef4eb5f4ceeb08a4c8524d84c5da95dce2f608e0ca2ec8091191b0f330c6e3" ] } ``` -------------------------------- ### remove_transaction RPC (JSON) - Response Source: https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md 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`). ```json { "id": 42, "jsonrpc": "2.0", "result": true } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.