curl --request POST \
--url https://nd-422-757-666.p2pify.com/0a9d79d93fb2f4a4b1e04695da2b77a7 \
--header 'Content-Type: application/json' \
--data '{
"id": 1,
"jsonrpc": "2.0",
"method": "eth_syncing",
"params": []
}'
{
"jsonrpc": "<string>",
"id": 123,
"result": {}
}
curl --request POST \
--url https://nd-422-757-666.p2pify.com/0a9d79d93fb2f4a4b1e04695da2b77a7 \
--header 'Content-Type: application/json' \
--data '{
"id": 1,
"jsonrpc": "2.0",
"method": "eth_syncing",
"params": []
}'
{
"jsonrpc": "<string>",
"id": 123,
"result": {}
}
false
if the node is fully synced. This method can track the progress of a node’s synchronization with the Ethereum blockchain. The returned object contains data such as the starting block, current block, and highest block of the node, allowing developers to monitor and estimate the time remaining for the node to sync fully.
none
result
— the boolean value false
when not syncing or a JSON object when syncing:
startingBlock
— the block number where the synchronization process started, encoded as hexadecimal.currentBlock
— the block number that the node has currently processed, same as eth_blockNumber
, encoded as hexadecimal.highestBlock
— the block number of the latest block in the blockchain known to the node.eth_syncing
code examplesChainstackProvider
in ethers.js
: ethers ChainstackProvider Documentation.const ethers = require("ethers");
// Create a ChainstackProvider instance for Ethereum mainnet
const chainstack = new ethers.ChainstackProvider("mainnet");
const syncStatus = async () => {
const status = await chainstack.send("eth_syncing", []);
console.log(status);
};
syncStatus();
eth_syncing
method on Ethereum can be useful for developers building applications that interact with the Ethereum blockchain. For example, you may want to provide feedback to your application’s user about the status of the Ethereum node the application is connecting to.
Here is a code example using the ethers.js library and the ChainstackProvider
:
const ethers = require("ethers");
// Create a ChainstackProvider instance for Ethereum mainnet
const chainstack = new ethers.ChainstackProvider("mainnet");
async function syncstatus() {
try {
// Query the sync status
const syncing = await chainstack.send("eth_syncing", []);
if (syncing) {
console.log(
`Node is syncing. Current block: ${syncing.currentBlock}. Highest block: ${syncing.highestBlock}`
);
} else {
console.log("Node is fully synced.");
}
} catch (error) {
console.error(error);
}
}
syncstatus();
chainstack
instance and connects to the node. Then, it calls eth_syncing
to get the current synchronization status of the node. If the node is fully synced, the function logs a message to the console indicating that the node is fully synced.
If the node is still syncing, the function logs the current and highest block numbers known to the node.Syncing information
The response is of type object
.
Was this page helpful?