eth_syncing - Base
Example code for the eth_syncing JSON-RPC method. Complete guide on how to use eth_syncing JSON-RPC in GetBlock Web3 documentation.
Parameters
Request
curl --location --request POST 'https://go.getblock.io/<ACCESS-TOKEN>/' \
--header 'Content-Type: application/json' \
--data-raw '{
"jsonrpc": "2.0",
"method": "eth_syncing",
"params": [],
"id": "getblock.io"
}'const axios = require('axios');
const response = await axios.post('https://go.getblock.io/<ACCESS-TOKEN>/', {
jsonrpc: '2.0',
method: 'eth_syncing',
params: [],
id: 'getblock.io'
}, {
headers: { 'Content-Type': 'application/json' }
});
const syncStatus = response.data.result;
if (syncStatus === false) {
console.log('Node is fully synced');
} else {
console.log('Syncing...');
console.log('Current Block:', parseInt(syncStatus.currentBlock, 16));
console.log('Highest Block:', parseInt(syncStatus.highestBlock, 16));
}Response (Synced)
{
"jsonrpc": "2.0",
"id": "getblock.io",
"result": false
}{
"jsonrpc": "2.0",
"id": "getblock.io",
"result": {
"startingBlock": "0x0",
"currentBlock": "0x12d6800",
"highestBlock": "0x12d687f"
}
}Response Parameters
Parameter
Type
Description
Sync Status Object
Field
Type
Description
Use Cases
Error Handling
Error Code
Message
Description
Web3 Integration
Last updated
Was this helpful?