https://github.com/merklejerk/create-web3-provider
Easily create a web3 provider from scratch
https://github.com/merklejerk/create-web3-provider
easy es2017 ethereum infura nodejs provider simple web3
Last synced: 26 days ago
JSON representation
Easily create a web3 provider from scratch
- Host: GitHub
- URL: https://github.com/merklejerk/create-web3-provider
- Owner: merklejerk
- License: apache-2.0
- Created: 2018-07-23T22:19:13.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2023-01-23T21:57:43.000Z (over 2 years ago)
- Last Synced: 2025-04-10T23:37:57.517Z (6 months ago)
- Topics: easy, es2017, ethereum, infura, nodejs, provider, simple, web3
- Language: JavaScript
- Size: 532 KB
- Stars: 7
- Watchers: 3
- Forks: 4
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README

# create-web3-provider
Create a web3 provider from scratch, with minimal to no configuration.You can then pass the created provider directly into the [Web3](https://web3js.readthedocs.io) constructor.
## Installation
```bash
npm install create-web3-provider
# or
yarn install create-web3-provider
```## Example Usage
```js
const cw3p = require('create-web3-provider');
// Create an infura-backed provider on the mainnet.
let provider = cw3p();
// Create an infura-backed provider on the ropsten network.
provider = cw3p({network: 'ropsten'});
// Same, but use websockets.
provider = cw3p({ws: true, network: 'ropsten'});
// Create an infura-backed provider using your own API key.
provider = cw3p({infuraKey: 'MySecretInfuraKey'});
// Create a provider connected to 'http://localhost:8545'
provider = cw3p({uri: 'http://localhost:8545'});
// Create a provider connected to a websocket.
provider = cw3p({uri: 'ws://mydomain.com/path'});
// Create a provider connected to an IPC path.
provider = cw3p({uri: '/path/to/provider.ipc', net: require('net')});// Full options:
cw3p({
// Network to connect to. May be 'main', ''mainnet', 'ropsten', or 'rinkeby'.
network: String,
// Infura project ID, if not connecting to a custom provider.
infuraKey: String,
// Use websocket infura endpoint instead of HTTP.
ws: Boolean,
// Connect to a custom provider.
// May be an http://, https://, ws://, wss:// or IPC path.
// IPC paths require the 'net' option as well.
uri: String,
// If using an IPC path, set this to `require('net')`
net: Object,
// Array of {name: ..., value: ...} HTTP or websocket headers.
headers: Array,
// Timeout for HTTP or websocket requests, in ms.
timeout: Number
});
```