syncing
Action for checking if the Starknet node is currently syncing.
Import
import { syncing } from "starkweb/core";
Usage
index.ts
import { syncing } from "starkweb/core";
import { config } from "./config";
const syncStatus = await syncing(config);
console.log("Sync status:", syncStatus);
Parameters
import { type SyncingParameters } from "starkweb/core";
chainId (optional)
Hex | undefined
The chain ID to check sync status for. If not provided, uses the current chain.
index.ts
import { syncing } from "starkweb/core";
import { mainnet } from "starkweb/chains";
import { config } from "./config";
const syncStatus = await syncing(config, {
chainId: mainnet.chain_id,
});
Return Type
import { type SyncingReturnTypes } from "starkweb/core";
Returns the syncing status object containing:
chainId
Hex
The chain ID of the network.
starting_block_hash
Hex
Hash of the starting block in the sync range.
current_block_hash
Hex
Hash of the current block in the sync process.
highest_block_hash
Hex
Hash of the highest known block to sync to.
Example
example.ts
import { syncing } from "starkweb/core";
import { mainnet, testnet } from "starkweb/chains";
import { config } from "./config";
// Check sync status for current chain
const currentStatus = await syncing(config);
console.log("Current chain sync status:", currentStatus);
// Check sync status for specific chain
const mainnetStatus = await syncing(config, {
chainId: mainnet.chain_id,
});
console.log("Mainnet sync status:", {
current: mainnetStatus.current_block_hash,
target: mainnetStatus.highest_block_hash,
});
Error
import { type SyncingErrorType } from "starkweb/core";