@nixjs23n6/block-tracker
v2.2.14-alpha.0
Published
A JS module for keeping track of the latest Aptos/SUI/EVM Base block
Downloads
82
Maintainers
Readme
@nixjs23n6/aptos-block-tracker
Assets
Install
yarn add @nixjs23n6/aptos-block-tracker
Usage
Aptos
import { PollingAptosTracker } from '@nixjs23n6/aptos-block-tracker'
const blockTracker = new PollingAptosTracker({
address: '0xb1ab189ee69f9c4f7e99d3b3595aed20670098367c18d5a65234ce97596feb4e',
nodeURL: 'https://indexer-testnet.staging.gcp.aptosdev.com/v1/graphql',
})
blockTracker.on('sync', ({ newBlock, oldBlock }) => {
if (oldBlock) {
console.log(`sync #${Number(oldBlock)} -> #${Number(newBlock)}`)
} else {
console.log(`first sync #${Number(newBlock)}`)
}
})
SUI
import { PollingSUITracker } from '@nixjs23n6/aptos-block-tracker'
const blockTracker = new PollingSUITracker({
address: '0x1058a41ebe92ff069b65b692e20e51874a431e8b',
nodeURL: 'https://fullnode.devnet.sui.io/',
})
blockTracker.on('sync', ({ newBlock, oldBlock }) => {
if (oldBlock) {
console.log(`sync`, oldBlock, newBlock)
} else {
console.log(`first sync`, newBlock)
}
})