Home

Awesome

<br> <div align="center"> <img src="/asset/header.png?raw=true" alt="eth-provider" height="400"/> </div> <br> <br> <h3 align="center">A Universal Ethereum Provider Client</h3> <p align="center">Seamlessly connect to <b>HTTP</b>, <b>WebSocket</b>, <b>IPC</b> and <b>Injected</b> RPC transports in <b>Node</b> and the <b>Browser</b>!</p> <br> <br>

Goals

Install

npm install eth-provider --save

Use

const provider = require('eth-provider')
const web3 = new Web3(provider())
const provider = require('eth-provider')
const web3 = new Web3(provider('wss://sepolia.infura.io/ws/v3/${INFURA_ID}))
const provider = require('eth-provider')
const web3 = new Web3(provider(['injected', 'wss://sepolia.infura.io/ws/v3/${INFURA_ID}']))
const provider = require('eth-provider')
const web3 = new Web3(provider('direct'))

Presets

View all possible presets here

If you do not pass any targets, eth-provider will use default targets ['injected', 'frame'] in the Browser and ['frame', 'direct'] in Node and Electron.

Options

When creating the provider you can also pass an options object

provider('infura', { infuraId: '123abc' }) or provider({ origin: 'DappName', infuraId: '123abc' })

The origin setting will only be applied when a dapp is connecting to from outside of a browser env.