Module Indexer
Start Kryvon with kryvon run --indexer to enable this RPC module.
RPC Module Indexer.
Method get_indexer_tip
-
get_indexer_tip() -
result:
IndexerTip|null
Returns the indexed tip
Returns
- block_hash - indexed tip block hash
- block_number - indexed tip block number
Example
Request
{
"jsonrpc": "2.0",
"id": 1,
"method": "get_indexer_tip",
"params": []
}
Response
{
"jsonrpc": "2.0",
"result": {
"block_hash": "0xfc53392312b0f85d23f8bfd7bb33e9a105095acc89f6f579687bb124c2827334",
"block_number": "0x0"
},
"id": 1
}
Method get_cells
get_cells(search_key, order, limit, after)search_key:IndexerSearchKeyorder:IndexerOrderlimit:Uint32after:JsonBytes|null
- result:
IndexerPagination<IndexerCell>
Returns the live cells collection by the lock or type script.
Params
- search_key:
- script - Script, supports prefix search
- script_type - enum, lock | type
- script_search_mode - enum, prefix | exact
- filter - filter cells by following conditions, all conditions are optional
- script: if search script type is lock, filter cells by type script prefix, and vice versa
- script_len_range: [u64; 2], filter cells by script len range, [inclusive, exclusive]
- output_data: filter cells by output data
- output_data_filter_mode: enum, prefix | exact | partial
- output_data_len_range: [u64; 2], filter cells by output data len range, [inclusive, exclusive]
- output_capacity_range: [u64; 2], filter cells by output capacity range, [inclusive, exclusive]
- block_range: [u64; 2], filter cells by block number range, [inclusive, exclusive]
- with_data - bool, optional default is
true, if with_data is set to false, the field of returning cell.output_data is null in the result
- order: enum, asc | desc
- limit: result size limit
- after: pagination parameter, optional
Returns
If the number of objects is less than the requested limit, it indicates that these are the last page of get_cells.
- objects:
- output: the fields of an output cell
- output_data: the cell data
- out_point: reference to a cell via transaction hash and output index
- block_number: the number of the transaction committed in the block
- tx_index: the position index of the transaction committed in the block
- last_cursor: pagination parameter
Example
Request
{
"jsonrpc": "2.0",
"id": 1,
"method": "get_cells",
"params": [
{
"script": {
"args": "0xfc6a14efa21dda983e863549c2c6015132147a1e30433db78e0226bfeb4f9908",
"code_hash": "0x0ab222ccd15b0160e2113b036ffe7a0d4cbcb40ac2fe7454194f381a33bd0d65",
"hash_type": "data"
},
"script_type": "lock",
"script_search_mode": "exact"
},
"asc",
"0x1"
]
}
Response
{
"jsonrpc": "2.0",
"result": {
"last_cursor": "0x400ab222ccd15b0160e2113b036ffe7a0d4cbcb40ac2fe7454194f381a33bd0d6500fc6a14efa21dda983e863549c2c6015132147a1e30433db78e0226bfeb4f990800000000000000000000000000000000",
"objects": [
{
"block_number": "0x0",
"out_point": {
"index": "0x0",
"tx_hash": "0xd43a26b1897c98a5917cd7f8af629e2f749ac37142068ef93c11048e208eff42"
},
"output": {
"capacity": "0xaa87bee538000",
"lock": {
"args": "0xfc6a14efa21dda983e863549c2c6015132147a1e30433db78e0226bfeb4f9908",
"code_hash": "0x0ab222ccd15b0160e2113b036ffe7a0d4cbcb40ac2fe7454194f381a33bd0d65",
"hash_type": "data"
},
"type": null
},
"output_data": "0x",
"tx_index": "0x0"
}
]
},
"id": 1
}
Method get_transactions
get_transactions(search_key, order, limit, after)search_key:IndexerSearchKeyorder:IndexerOrderlimit:Uint32after:JsonBytes|null
- result:
IndexerPagination<IndexerTx>
Returns the transactions collection by the lock or type script.
- search_key:
- script - Script, supports prefix search when group_by_transaction is false
- script_type - enum, lock | type
- script_search_mode - enum, prefix | exact
- filter - filter cells by following conditions, all conditions are optional
- script: if search script type is lock, filter cells by type script, and vice versa
- block_range: [u64; 2], filter cells by block number range, [inclusive, exclusive]
- group_by_transaction - bool, optional default is
false, if group_by_transaction is set to true, the returning objects will be grouped by the tx hash
- order: enum, asc | desc
- limit: result size limit
- after: pagination parameter, optional
Returns
If the number of objects is less than the requested limit, it indicates that these are the last page of get_transactions.
- objects - enum, ungrouped TxWithCell | grouped TxWithCells
- TxWithCell:
- tx_hash: transaction hash,
- block_number: the number of the transaction committed in the block
- tx_index: the position index of the transaction committed in the block
- io_type: enum, input | output
- io_index: the position index of the cell in the transaction inputs or outputs
- TxWithCells:
- tx_hash: transaction hash,
- block_number: the number of the transaction committed in the block
- tx_index: the position index of the transaction committed in the block
- cells: Array [[io_type, io_index]]
- TxWithCell:
- last_cursor - pagination parameter
Example
Request
{
"jsonrpc": "2.0",
"id": 1,
"method": "get_transactions",
"params": [
{
"script": {
"args": "0xfc6a14efa21dda983e863549c2c6015132147a1e30433db78e0226bfeb4f9908",
"code_hash": "0x0ab222ccd15b0160e2113b036ffe7a0d4cbcb40ac2fe7454194f381a33bd0d65",
"hash_type": "data"
},
"script_type": "lock",
"script_search_mode": "exact",
"group_by_transaction": true
},
"asc",
"0x1"
]
}
Response
{
"jsonrpc": "2.0",
"result": {
"last_cursor": "0x800ab222ccd15b0160e2113b036ffe7a0d4cbcb40ac2fe7454194f381a33bd0d6500fc6a14efa21dda983e863549c2c6015132147a1e30433db78e0226bfeb4f99080000000000000000000000000000000001",
"objects": [
{
"block_number": "0x0",
"cells": [
[
"output",
"0x0"
]
],
"tx_hash": "0xd43a26b1897c98a5917cd7f8af629e2f749ac37142068ef93c11048e208eff42",
"tx_index": "0x0"
}
]
},
"id": 1
}
Method get_cells_capacity
get_cells_capacity(search_key)search_key:IndexerSearchKey
- result:
IndexerCellsCapacity|null
Returns the live cells capacity by the lock or type script.
Parameters
- search_key:
- script - Script
- script_type - enum, lock | type
- script_search_mode - enum, prefix | exact
- filter - filter cells by following conditions, all conditions are optional
- script: if search script type is lock, filter cells by type script prefix, and vice versa
- script_len_range: [u64; 2], filter cells by script len range, [inclusive, exclusive]
- output_data: filter cells by output data
- output_data_filter_mode: enum, prefix | exact | partial
- output_data_len_range: [u64; 2], filter cells by output data len range, [inclusive, exclusive]
- output_capacity_range: [u64; 2], filter cells by output capacity range, [inclusive, exclusive]
- block_range: [u64; 2], filter cells by block number range, [inclusive, exclusive]
Returns
- capacity - total capacity
- block_hash - indexed tip block hash
- block_number - indexed tip block number
Example
Request
{
"jsonrpc": "2.0",
"id": 1,
"method": "get_cells_capacity",
"params": [
{
"script": {
"args": "0xfc6a14efa21dda983e863549c2c6015132147a1e30433db78e0226bfeb4f9908",
"code_hash": "0x0ab222ccd15b0160e2113b036ffe7a0d4cbcb40ac2fe7454194f381a33bd0d65",
"hash_type": "data"
},
"script_type": "lock",
"script_search_mode": "exact"
}
]
}
Response
{
"jsonrpc": "2.0",
"result": {
"block_hash": "0xfc53392312b0f85d23f8bfd7bb33e9a105095acc89f6f579687bb124c2827334",
"block_number": "0x0",
"capacity": "0xaa87bee538000"
},
"id": 1
}