For the complete documentation index, see llms.txt. This page is also available as Markdown.

sync_state - Nervos

Example code for the sync_state JSON-RPC method. Complete guide on how to use sync_state JSON-RPC in GetBlock Web3 documentation.

Returns the chain synchronization state of this node — total best known header, currently fast-syncing block, in-flight blocks, current low time.

Parameters

  • None

Request Example

curl --location --request POST 'https://go.getblock.io/<ACCESS-TOKEN>/' \
--header 'Content-Type: application/json' \
--data-raw '{
    "jsonrpc": "2.0",
    "method": "sync_state",
    "params": [],
    "id": "getblock.io"
}'
import axios from 'axios';

const data = JSON.stringify({
    "jsonrpc": "2.0",
    "method": "sync_state",
    "params": [],
    "id": "getblock.io"
});

const config = {
    method: 'post',
    url: 'https://go.getblock.io/<ACCESS-TOKEN>/',
    headers: {
        'Content-Type': 'application/json'
    },
    data: data
};

axios(config)
    .then(response => console.log(JSON.stringify(response.data, null, 2)))
    .catch(error => console.log(error));

Response Example

{
    "jsonrpc": "2.0",
    "id": "getblock.io",
    "result": {
        "best_known_block_number": "0xe5a45f",
        "best_known_block_timestamp": "0x18f3b8d2a3c",
        "fast_time": "0x1f4",
        "ibd": false,
        "inflight_blocks_count": "0x0",
        "low_time": "0x9c4",
        "normal_time": "0x3e8",
        "orphan_blocks_count": "0x0",
        "tip_hash": "0x02530b25ad0ff677acc365cb73de3e8cc09c7ddd58272e879252e199d08df83b",
        "tip_number": "0xe5a45f",
        "unverified_tip_hash": "0x02530b25ad0ff677acc365cb73de3e8cc09c7ddd58272e879252e199d08df83b",
        "unverified_tip_number": "0xe5a45f"
    }
}

Response Parameters

Field
Type
Description

result.ibd

boolean

true if the node is in Initial Block Download mode

result.best_known_block_number

Uint64

Highest block number known across all peers

result.tip_number

Uint64

Local tip block number

result.inflight_blocks_count

Uint64

Blocks currently being downloaded from peers

result.orphan_blocks_count

Uint64

Orphan blocks in local storage

result.normal_time

Uint64

Median time for block download (ms)

result.low_time

Uint64

p25 time for block download (ms)

result.fast_time

Uint64

p75 time for block download (ms)

Use Cases

  • Detecting that a node is still in IBD before serving reads

  • Monitoring sync progress in node dashboards

  • Failover logic that prefers fully-synced nodes

Error Handling

Status Code
Error Message
Cause

403

Forbidden

Missing or invalid <ACCESS-TOKEN>

-32602

Invalid params

Request parameters are missing or malformed

-32601

Method not found

Method does not exist or is not enabled on this node

-32603

Internal error

Server-side error while processing the request

429

Too Many Requests

Rate limit exceeded for your plan

SDK Integration

Was this helpful?