A monitoring library for Substrate based chain. It is more lightweight and generic, and has some unique features for low level data handling e.g. handle and decode batch calls.
Install it via
yarn add @open-web3/scanner
yarn add @polkadot/api
If you are scanning a particular substrate chain that has custom types, you might need to install its types. In the example given below, please add this to dependencies.
"@acala-network/type-definitions": "0.4.0-beta.32"
import Scanner from '@open-web3/scanner';
import { types, typesBundle } from '@acala-network/type-definitions';
import { WsProvider } from '@polkadot/rpc-provider';
const provider = new WsProvider('wss://node-6714447553777491968.jm.onfinality.io/ws');
await provider.isReady
const scanner = new Scanner({ wsProvider: provider, types, typesBundle });
scanner
.subscribe({
start: 0,
end: 1000,
confirmation: 4,
concurrent: 10 // batch call
})
.subscribe((result) => {
console.log(result.result.events);
});
Scans for events, transactions, and other data within the specified block height range.
Options passed to scanner
Height of the starting block of the scan. The default is 0.
Height of the ending block of the scan. If null, listen for the latest block.
If it is finalize, only finalized blocks are scanned
The number of blocks that are resolved concurrently.
If a block resolution event exceeds timeout, an error is thrown
Block height of resolved block.
Block height of resolved block.
The error message
Block of raw data
Block height of resolved block.
Block hash of resolved block.
All the transaction data for this block.
All the events data for this block.