TypeScript client for subscribing to real-time action streams from a Roborovski actionindex service.
npm install @wharfkit/actionstream
# or
yarn add @wharfkit/actionstreamimport {ActionStreamClient} from '@wharfkit/actionstream'
const client = new ActionStreamClient('wss://example.com/v1/actionstream', {
contracts: ['eosio.token'],
})
client.connect()
for await (const action of client) {
console.log(String(action.globalSeq), String(action.contract) + '::' + String(action.action))
console.log(action.data)
}const client = new ActionStreamClient('wss://example.com/v1/actionstream', {
contracts: ['eosio.token'],
receivers: ['myaccount'],
})
client.connect()
const action = await client.next()
const actionOrNull = await client.nextWithTimeout(5000)const client = new ActionStreamClient(url, filter, {
startSeq: '48000000000', // resume from a specific sequence number
decode: true, // request ABI-decoded action data (default: true)
reconnectDelay: 1000, // initial reconnect delay in ms (default: 1000)
reconnectMaxDelay: 30000, // max reconnect delay in ms (default: 30000)
ackInterval: 1000, // actions between ack messages (default: 1000)
})client.onConnect = () => {}
client.onDisconnect = () => {}
client.onHeartbeat = (state) => {
console.log('head:', String(state.headSeq), 'lib:', String(state.libSeq))
}
client.onCatchupComplete = (state) => {}
client.onError = (code, message) => {}client.headSeq // UInt64 - latest sequence on the server
client.libSeq // UInt64 - last irreversible sequence
client.connected // boolean
client.catchupComplete // booleanSubscriptions accept three optional filter dimensions. An action matches if it satisfies all specified dimensions. Omitted dimensions are unconstrained.
{
contracts: ['eosio.token'], // contract account names
receivers: ['myaccount'], // notification receivers
actions: ['transfer', 'issue'], // action names
}make # build
make test # run tests
make check # lint
BSD-3-Clause