[go: up one dir, main page]

web3-stream-provider

5.1.0 • Public • Published

web3-stream-provider

Utility for creating an Ethereum web3 provider that forwards payloads through a stream. Only works for async payloads.

For connecting to a remote eth rpc handler

const StreamProvider = require('web3-stream-provider')

var streamProvider = new StreamProvider()
var web3 = new Web3(streamProvider)

streamProvider.pipe(remoteRpcHandler).pipe(streamProvider)

For handling incoming rpc payloads

const handleRequestsFromStream = require('web3-stream-provider/handler')

handleRequestsFromStream(remoteStream, provider, /* optional */ onRequest, onResponse)

function onRequest(request){
  // can modify the request if needed
  console.log(arguments)
}

function onResponse(err, request, response){
  console.log(arguments)
}

Package Sidebar

Install

npm i web3-stream-provider

Weekly Downloads

1,408

Version

5.1.0

License

ISC

Unpacked Size

3.79 kB

Total Files

5

Last publish

Collaborators

  • danfinlay
  • kumavis
  • mcmire
  • rekmarks
  • metamaskbot
  • gudahtt
  • nicholasellul
  • sethkfman
  • naugtur