web3-stream-provider

    4.0.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)
    }

    Install

    npm i web3-stream-provider

    DownloadsWeekly Downloads

    1,118

    Version

    4.0.0

    License

    ISC

    Unpacked Size

    3.72 kB

    Total Files

    4

    Last publish

    Collaborators

    • sethkfman
    • brad.decker
    • danfinlay
    • kumavis
    • rekmarks
    • metamaskbot
    • gudahtt