{"id":18674122,"url":"https://github.com/nervosnetwork/ckb-light-client","last_synced_at":"2026-01-02T04:54:26.589Z","repository":{"id":37175865,"uuid":"468280444","full_name":"nervosnetwork/ckb-light-client","owner":"nervosnetwork","description":"CKB light client reference implementation","archived":false,"fork":false,"pushed_at":"2025-04-11T09:51:32.000Z","size":1110,"stargazers_count":16,"open_issues_count":16,"forks_count":16,"subscribers_count":5,"default_branch":"develop","last_synced_at":"2025-04-11T11:51:21.753Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nervosnetwork.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-03-10T09:44:00.000Z","updated_at":"2025-03-20T00:43:15.000Z","dependencies_parsed_at":"2023-12-21T05:22:08.805Z","dependency_job_id":"6678be4c-9c14-42b5-9fbb-87b84c2067e6","html_url":"https://github.com/nervosnetwork/ckb-light-client","commit_stats":{"total_commits":224,"total_committers":5,"mean_commits":44.8,"dds":0.65625,"last_synced_commit":"9a02b23c3c62d0c89adc6257a581ea4143a17923"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nervosnetwork%2Fckb-light-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nervosnetwork%2Fckb-light-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nervosnetwork%2Fckb-light-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nervosnetwork%2Fckb-light-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nervosnetwork","download_url":"https://codeload.github.com/nervosnetwork/ckb-light-client/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248400057,"owners_count":21097299,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-07T09:17:35.477Z","updated_at":"2026-01-02T04:54:26.547Z","avatar_url":"https://github.com/nervosnetwork.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CKB light client reference implementation\n\n[![License]](#license)\n[![GitHub Actions]](https://github.com/nervosnetwork/ckb-light-client/actions)\n[![Codecov]](https://codecov.io/gh/nervosnetwork/ckb-light-client)\n\nA CKB light client based on [RFC 44] and [RFC 45].\n\n[License]: https://img.shields.io/badge/License-MIT-blue.svg\n[GitHub Actions]: https://github.com/nervosnetwork/ckb-light-client/workflows/CI/badge.svg\n[Codecov]: https://img.shields.io/codecov/c/gh/nervosnetwork/ckb-light-client/develop\n\n## Wasm\n\nFor browsers, please refer to README in `wasm` folder.\n\n## How to run\n\n1. Run your own full node, this is an optional step, you may use the public bootnodes instead.\n\nDownload ckb [v0.106.0 or above](https://github.com/nervosnetwork/ckb/releases/tag/v0.106.0), init and run ckb in a new folder:\n```\nckb init -c mainnet\nckb run\n```\n\nGet full node peer id\n```\ncurl http://localhost:8114/ -X POST -H \"Content-Type: application/json\" -d '{\"jsonrpc\": \"2.0\", \"method\":\"local_node_info\", \"params\": [], \"id\": 1}'\n```\n\n2. Build a light client with [this branch](https://github.com/nervosnetwork/ckb-light-client/tree/develop) or download the prebuilt binary.\n\n```\ngit clone https://github.com/nervosnetwork/ckb-light-client.git\ngit checkout develop\ncargo build --release\n```\n\n3. Run light client\n\nCopy the `ckb-light-client` binary and `config/mainnet.toml` to a new folder, if you want to connect to the full node you just build in step 1, modify the `bootnodes` section's peer address to full node peer's ip (should be 127.0.0.1 if you run the full node on localhost) and peer id.\n\nStart light client:\n```\nRUST_LOG=info,ckb_light_client=info ./ckb-light-client run --config-file ./mainnet.toml\n```\n\n## RPC\n\n### `set_scripts`\n\nSet some scripts to filter\n\n#### Parameters\n    Vec\u003cScriptStatus\u003e: Array of script status\n        script - Script\n        script_type - Enum \"lock\" or \"type\"\n        block_number - Filter start number\n    SetScriptCommand: An optional enum parameter to control the behavior of set_scripts\n        \"all\" - Replace all existing scripts with new scripts, non-exist scripts will be deleted, this is the default behavior\n        \"partial\" - Update partial scripts with new scripts, non-exist scripts will be ignored\n        \"delete\" - Delete scripts by `script` and `script_type`, the `block_number` field will be ignored\n\n#### Returns\n\n    null\n\n#### Examples\n\nSet a new script to filter and replace all existing scripts:\n```\ncurl http://localhost:9000/ -X POST -H \"Content-Type: application/json\" -d '{\"jsonrpc\": \"2.0\", \"method\":\"set_scripts\", \"params\": [[{\"script\": {\"code_hash\": \"0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8\", \"hash_type\": \"type\", \"args\": \"0x50878ce52a68feb47237c29574d82288f58b5d21\"}, \"script_type\": \"lock\", \"block_number\": \"0x0\"}]], \"id\": 1}'\n```\n\nAdd a new script to filter:\n```\ncurl http://localhost:9000/ -X POST -H \"Content-Type: application/json\" -d '{\"jsonrpc\": \"2.0\", \"method\":\"set_scripts\", \"params\": [[{\"script\": {\"code_hash\": \"0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8\", \"hash_type\": \"type\", \"args\": \"0xd7c521f77cae39e7083d1cd664a893395fe25fdb\"}, \"script_type\": \"lock\", \"block_number\": \"0x64\"}], \"partial\"], \"id\": 1}'\n```\n\nDelete a script from filter:\n```\ncurl http://localhost:9000/ -X POST -H \"Content-Type: application/json\" -d '{\"jsonrpc\": \"2.0\", \"method\":\"set_scripts\", \"params\": [[{\"script\": {\"code_hash\": \"0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8\", \"hash_type\": \"type\", \"args\": \"0xd7c521f77cae39e7083d1cd664a893395fe25fdb\"}, \"script_type\": \"lock\", \"block_number\": \"0x0\"}], \"delete\"], \"id\": 1}'\n```\n\n### `get_scripts`\n\nGet filter scripts status\n\n#### Parameters\n\n    null\n\n#### Returns\n\n    script - Script\n    script_type - Enum \"lock\" or \"type\"\n    block_number - Filtered block number\n\n#### Examples\n\n```\ncurl http://localhost:9000/ -X POST -H \"Content-Type: application/json\" -d '{\"jsonrpc\": \"2.0\", \"method\":\"get_scripts\", \"params\": [], \"id\": 1}'\n```\n\n### `send_transaction`\n\nSubmits a new transaction and broadcast it to network peers\n\n#### Parameters\n\n    tx - Transaction\n\n#### Returns\n\n    tx_hash - H256\n\n#### Examples\n\n```\ncurl http://localhost:9000/ -X POST -H \"Content-Type: application/json\" -d '{\"jsonrpc\": \"2.0\", \"method\": \"send_transaction\", \"params\": [{\"cell_deps\":[{\"dep_type\":\"dep_group\",\"out_point\":{\"index\":\"0x0\",\"tx_hash\":\"0xf8de3bb47d055cdf460d93a2a6e1b05f7432f9777c8c474abf4eec1d4aee5d37\"}}],\"header_deps\":[],\"inputs\":[{\"previous_output\":{\"index\":\"0x7\",\"tx_hash\":\"0x8f8c79eb6671709633fe6a46de93c0fedc9c1b8a6527a18d3983879542635c9f\"},\"since\":\"0x0\"}],\"outputs\":[{\"capacity\":\"0x470de4df820000\",\"lock\":{\"args\":\"0xff5094c2c5f476fc38510018609a3fd921dd28ad\",\"code_hash\":\"0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8\",\"hash_type\":\"type\"},\"type\":null},{\"capacity\":\"0xb61134e5a35e800\",\"lock\":{\"args\":\"0x64257f00b6b63e987609fa9be2d0c86d351020fb\",\"code_hash\":\"0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8\",\"hash_type\":\"type\"},\"type\":null}],\"outputs_data\":[\"0x\",\"0x\"],\"version\":\"0x0\",\"witnesses\":[\"0x5500000010000000550000005500000041000000af34b54bebf8c5971da6a880f2df5a186c3f8d0b5c9a1fe1a90c95b8a4fb89ef3bab1ccec13797dcb3fee80400f953227dd7741227e08032e3598e16ccdaa49c00\"]}], \"id\": 1}'\n```\n\n### `estimate_cycles`\n\nThis RPC method is the same as CKB's, please refer to [CKB JSON-RPC Protocols](https://github.com/nervosnetwork/ckb/tree/develop/rpc#method-estimate_cycles).\n\n### `get_tip_header`\n\nReturns the header with the highest block number in the canonical chain\n\n#### Parameters\n\n    null\n\n#### Returns\n\n    header - HeaderView\n\n#### Examples\n\n```\ncurl http://localhost:9000/ -X POST -H \"Content-Type: application/json\" -d '{\"jsonrpc\": \"2.0\", \"method\": \"get_tip_header\", \"params\": [], \"id\": 1}'\n```\n\n### `get_genesis_block`\n\nReturns the genesis block\n\n#### Parameters\n\n    null\n\n#### Returns\n\n    block - BlockView\n\n#### Examples\n\n```\ncurl http://localhost:9000/ -X POST -H \"Content-Type: application/json\" -d '{\"jsonrpc\": \"2.0\", \"method\": \"get_genesis_block\", \"params\": [], \"id\": 1}'\n```\n\n### `get_header`\n\nReturns the information about a block header by hash.\n\n#### Parameters\n\n    block_hash - the block hash\n\n#### Returns\n\n    header - HeaderView\n\n#### Examples\n\n```\ncurl http://localhost:9000/ -X POST -H \"Content-Type: application/json\" -d '{\"jsonrpc\": \"2.0\", \"method\": \"get_header\", \"params\": [\"0xa5f5c85987a15de25661e5a214f2c1449cd803f071acc7999820f25246471f40\"], \"id\": 1}'\n```\n\n### `get_transaction`\n\nReturns the information about a transaction by hash, the block header is also returned.\n\n#### Parameters\n\n    transaction_hash - the transaction hash\n\n#### Returns\n    TransactionWithStatus struct fields:\n\n    transaction -  TransactionView\n    cycles - a optional field, cycles used by this transaction\n    tx_status:\n        status - enum \"pending\", \"committed\" or \"unknown\"\n        block_hash - the block hash which contains this transaction, only available when status is \"committed\"\n\n#### Examples\n\n```\ncurl http://localhost:9000/ -X POST -H \"Content-Type: application/json\" -d '{\"jsonrpc\": \"2.0\", \"method\": \"get_transaction\", \"params\": [\"0xa0ef4eb5f4ceeb08a4c8524d84c5da95dce2f608e0ca2ec8091191b0f330c6e3\"], \"id\": 1}'\n```\n\n### `fetch_header`\n\nFetch a header from remote node. If return status is `not_found` will re-sent fetching request immediately.\n\n#### Parameters\n\n    block_hash  - the block hash\n\n#### Returns\n\n    {\"status\": \"fetched\", \"data\": HeaderView }\n    {\"status\": \"fetching\", \"first_sent\": Uint64 }\n    {\"status\": \"added\", \"timestamp\": Uint64 }\n    {\"status\": \"not_found\" }\n\n### `fetch_transaction`\n\nFetch a transaction from remote node. If return status is `not_found` will re-sent fetching request immediately.\n\n#### Parameters\n\n    tx_hash  - the transaction hash\n\n#### Returns\n\n    {\"status\": \"fetched\", \"data\": TransactionWithStatus } // TransactionWithStatus is same as get_transaction rpc response\n    {\"status\": \"fetching\", \"first_sent\": Uint64 }\n    {\"status\": \"added\", \"timestamp\": Uint64 }\n    {\"status\": \"not_found\" }\n\n### `get_peers`\n\nReturns the connected peers' information.\n\n#### Parameters\n\n    null\n\n#### Returns\n\n    version - the remote node version\n    node_id - the remote node ID\n    addresses: array of remote node addresses\n        address - the remote node address in multiaddr format\n        score - the remote node score, a higher score means a higher probability of a successful connection\n    connected_duration: elapsed time in milliseconds since the remote node is connected\n    sync_state: an optional parameter indicates sync state, null means chain sync has not started with this remote node yet\n        requested_best_known_header - requested best known header of remote peer, null means no request is sent yet, HeaderView struct\n        proved_best_known_header - proved best known header of remote peer, null means no proof is received yet, HeaderView struct\n    protocols: array of active running protocols\n        id - the protocol id\n        version - the protocol version\n\n### `local_node_info`\n\nTo facilitate code migration, the rpc is same as ckb fullnode's `local_node_info`, please refer to ckb rpc [doc](https://github.com/nervosnetwork/ckb/tree/develop/rpc#method-local_node_info)\n\n### `get_cells`\n\nTo facilitate code migration, the rpc is same as ckb-indexer, please refer to ckb-indexer rpc [doc](https://github.com/nervosnetwork/ckb-indexer#get_cells)\n\n### `get_transactions`\n\nTo facilitate code migration, the rpc is similar as ckb-indexer, the only difference is the returning data, light client will return a full transaction struct, please refer to ckb-indexer rpc [doc](https://github.com/nervosnetwork/ckb-indexer#get_transactions)\n\n### `get_cells_capacity`\n\nTo facilitate code migration, the rpc is same as ckb-indexer, please refer to ckb-indexer rpc [doc](https://github.com/nervosnetwork/ckb-indexer#get_cells_capacity)\n\n## License\n\nLicensed under [MIT License].\n\n[RFC 44]: https://github.com/nervosnetwork/rfcs/pull/370\n[RFC 45]: https://github.com/nervosnetwork/rfcs/pull/375\n[MIT License]: LICENSE\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnervosnetwork%2Fckb-light-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnervosnetwork%2Fckb-light-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnervosnetwork%2Fckb-light-client/lists"}