0.1.2 • Published 2 months ago

@eosswedenorg/thalos-client v0.1.2

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

Thalos Nodejs Client

Nodejs bindings for thalos

Install

npm install --save @eosswedenorg/thalos-client

Usage

Pure javascript:

const thalos = require('@eosswedenorg/thalos-client');

// Create client.
const client = thalos.createRedisClient({
    // url: "redis://localhost:6379",
    // prefix: "ship",
    ns: "1064487b3cd1a897ce03ae5b6a865651747e2e152090f99c1d19d44e01aea5a4" // wax mainnet
})

// Listen to heartbeat events.
client.onHeartbeat(hb => {
    console.log("Hearbeat: Blockno", hb.blocknum, "HEAD", hb.head_blocknum, "LIB", hb.last_irreversible_blocknum);
});

With typescript:

import * as thalos from '@eosswedenorg/thalos-client';

// Create client.
const client = thalos.createRedisClient({
    // url: "redis://localhost:6379",
    // prefix: "ship",
    ns: "1064487b3cd1a897ce03ae5b6a865651747e2e152090f99c1d19d44e01aea5a4" // wax mainnet
})

// Listen to heartbeat events.
client.onHeartbeat((hb:thalos.HeartBeat) => {
    console.log("Hearbeat: Blockno", hb.blocknum, "HEAD", hb.head_blocknum, "LIB", hb.last_irreversible_blocknum);
});

Events

More examples on how to use different event callback below:

Listening on transactions

// Listen on transactions
client.onTransaction(transaction => {
    console.log("Transaction", transaction.id);
});
// Listen to one action.
client.onAction({contract: "m.federation", name: "mine"}, action => {
    console.log("Mine Action", action);
});
// Listening on multiple actions.
client.onAction([ {contract: "eosio"}, {name: "mine"} ], action => {
    console.log("Action", action);
});

Author

Henrik Hautakoski - henrik@eossweden.org

0.1.2

2 months ago

0.1.1-0

4 months ago

0.1.0

4 months ago