@avnsystems/web3-providers-ws
v1.0.0
Published
This is a fork of web3-providers-ws that uses @avnsystems/websocket-node
Downloads
2
Maintainers
Readme
Overview
This is a websocket provider sub-package for web3.js.
Please read the documentation for more.
Installation
Node.js
npm install @avnsystems/web3-providers-ws
Usage
const AVNWeb3ProvidersWs = require('@avnsystems/web3-providers-ws');
const options = {
// Enable keepalive
clientConfig: {
keepalive: true,
keepaliveInterval: 60000,
keepaliveForce: true
},
// Enable auto reconnection
reconnect: {
auto: true,
delay: 5000, // ms
maxAttempts: 5,
onTimeout: false
}
};
const wsProvider = new AVNWeb3ProvidersWs('ws://localhost:8546', options);
Usage with Web3
const Web3 = require('web3');
const web3 = new Web3(wsProvider);
Usage with Ethers.js
const ethers = require('ethers');
const provider = new ethers.providers.Web3Provider(wsProvider);
Additional client config options can be found here.
Types
All the TypeScript typings are placed in the types
folder.