Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

create-web3-provider

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

create-web3-provider

Easily create a web3 provider from scratch.

  • 1.6.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

npm package

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 constructor.

Installation

npm install create-web3-provider
# or
yarn install create-web3-provider

Example Usage

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

Keywords

FAQs

Package last updated on 04 Aug 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc