Skip to content

creates an Ethereum web3 provider that forwards payloads through a stream

Notifications You must be signed in to change notification settings

rekmarks/web3-stream-provider

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

creates an Ethereum web3 provider that forwards payloads through a stream

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%