Minamlist RPC Module
npm install backbone-rpc
const BackBone = require('backbone-rpc/ipc');
// pass in the ipc socket path
const eth = new BackBone('/tmp/parity.sock');
// call methods
await eth.blockNumber();
// to close the underlying socket/rpc when all
// current requests are done do
await eth.end();
For a list of supported methods see https://wiki.parity.io/JSONRPC-eth-module.html
If you are using Parity you can also use the pubsub module, to subscribe to changes:
const unsubscribe = await eth.subscribe(
eth.getBlockByNumber('latest', false),
function (err, block) {
if (err) return;
if (parseInt(block.timestamp) > Date.now() - 1000 * 60)
return unsubscribe();
console.log(block);
}
);
The following RPC providers are included
backbone/metamask
backbone/ipc
backbone/ws
backbone/http
Create a new pubsub subscription to a "Request". Requests are other method calls
that have not yet been awaited. subscribe
resolves once the subscription has
been confirmed by the node. unlisten
is a method that can be called to
unsubscribe. listener
is called with (err, data)
.
End the client gracefully
End the client forcefully
Flag whether the client has been destroyed
MIT