### 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 } ```