Tiny RPC module to request methods on an ETH node
npm install nanoeth
const NanoETH = require('nanoeth/ipc')
// pass in the ipc socket path
const eth = new NanoETH('/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
nanoeth/metamask
nanoeth/ipc
nanoeth/ws
nanoeth/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