Skip to content

Latest commit

 

History

History
63 lines (38 loc) · 1.76 KB

File metadata and controls

63 lines (38 loc) · 1.76 KB

@tevm/decorators


@tevm/decorators / NetworkSync

Type Alias: NetworkSync

NetworkSync = object

Defined in: eip1193/NetworkSync.ts:43

Information about the Ethereum client's sync status. Returned by the eth_syncing JSON-RPC method when synchronization is in progress.

Example

import { NetworkSync } from '@tevm/decorators'
import { createTevmNode } from 'tevm'
import { requestEip1193 } from '@tevm/decorators'

const node = createTevmNode().extend(requestEip1193())
const syncStatus = await node.request({ method: 'eth_syncing' })

if (syncStatus !== false) {
  const networkSync: NetworkSync = syncStatus
  console.log(`Syncing: ${networkSync.currentBlock} of ${networkSync.highestBlock}`)
  console.log(`Progress: ${(parseInt(networkSync.currentBlock, 16) / parseInt(networkSync.highestBlock, 16) * 100).toFixed(2)}%`)
} else {
  console.log('Node is fully synced')
}

Properties

currentBlock

currentBlock: Quantity

Defined in: eip1193/NetworkSync.ts:45

The current block number


highestBlock

highestBlock: Quantity

Defined in: eip1193/NetworkSync.ts:47

Number of latest block on the network


startingBlock

startingBlock: Quantity

Defined in: eip1193/NetworkSync.ts:49

Block number at which syncing started