Hi,
I started a testnet node based on documentation https://docs.nervos.org/dev-guide/testnet.html and the node version is 0.26.0.
According to API documentation https://docs.nervos.org/api/rpc.html#get_live_cells_by_lock_hash , I tried the following request but got “method not found” response. Is there anything missing from the testnet node or the API is wrong? Thank you.
Request:
POST {
“id”: 2,
“jsonrpc”: “2.0”,
“method”: “get_live_cells_by_lock_hash”,
“params”: [
“0xe41953d3569a50376143fd930d3ad28512054cfc6515d6626db5baea85b76655”,
“0xa”,
“0xe”
]
}
Response:
return {
“jsonrpc”: “2.0”,
“error”: {
“code”: -32601,
“message”: “Method not found”
},
“id”: 2
}
jjy
December 30, 2019, 2:59am
2
You need to enable RPC module Indexer
to use this API.
# Allowing arbitrary machines to access the JSON-RPC port is dangerous and strongly discouraged.
# Please strictly limit the access to only trusted machines.
listen_address = "127.0.0.1:8114" # {{
# _ => listen_address = "127.0.0.1:{rpc_port}"
# }}
# Default is 10MiB = 10 * 1024 * 1024
max_request_body_size = 10485760
# List of API modules: ["Net", "Pool", "Miner", "Chain", "Stats", "Indexer", "Experiment"]
modules = ["Net", "Pool", "Miner", "Chain", "Stats", "Experiment"] # {{
# integration => modules = ["Net", "Pool", "Miner", "Chain", "Experiment", "Stats", "Indexer", "IntegrationTest"]
# }}
# By default RPC only binds to HTTP service, you can bind it to TCP and WebSocket.
# tcp_listen_address = "127.0.0.1:18114"
# ws_listen_address = "127.0.0.1:28114"
[tx_pool]
max_mem_size = 20_000_000 # 20mb
max_cycles = 200_000_000_000
Thank you. The API works but it returns an empty array. The other API “get_cells_by_lock_hash” returns array with data but it requires block number range as parameters. Which API do you recommend for getting live cells by lock hash or address without block number required? Since there is no way for my system to know that the deposit address has cells in which blocks.
doitian
December 31, 2019, 12:19am
4
get_live_cells_by_lock_hash
requires creating the index via index_lock_hash
first