Skip to content

Latest commit

 

History

History
132 lines (81 loc) · 2.88 KB

web3.rst

File metadata and controls

132 lines (81 loc) · 2.88 KB

Web3

This is the main (or 'umbrella') class of the web3.js library.

var Web3 = require('web3');

> Web3.utils
> Web3.version
> Web3.givenProvider
> Web3.providers
> Web3.modules

Web3.modules

Web3.modules

Will return an object with the classes of all major sub modules, to be able to instantiate them manually.

Returns

Object: A list of module constructors:
  • Eth - Constructor: The Eth module for interacting with the Ethereum network (web3.eth <eth>).
  • Net - Constructor: The Net module for interacting with network properties (web3.eth.net <eth-net>).
  • Personal - Constructor: The Personal module for interacting with the Ethereum accounts (web3.eth.personal <personal>).
  • Shh - Constructor: The Shh module for interacting with the whisper protocol (web3.shh <shh>).
  • Bzz - Constructor: The Bzz module for interacting with the swarm network (web3.bzz <bzz>).

Example

Web3.modules
> {
    Eth: Eth(provider),
    Net: Net(provider),
    Personal: Personal(provider),
    Shh: Shh(provider),
    Bzz: Bzz(provider),
}

Web3 Instance

The Web3 class is an umbrella package to house all Ethereum related modules.

var Web3 = require('web3');

// "Web3.providers.givenProvider" will be set if in an Ethereum supported browser.
var web3 = new Web3(Web3.givenProvider || 'ws://some.local-or-remote.node:8546');

> web3.eth
> web3.shh
> web3.bzz
> web3.utils
> web3.version

version

Static accessible property of the Web3 class and property of the instance as well.

Web3.version
web3.version

Contains the current package version of the web3.js library.

Returns

String: The current version.

Example

web3.version;
> "1.2.3"

utils

Static accessible property of the Web3 class and property of the instance as well.

Web3.utils
web3.utils

Utility functions are also exposes on the Web3 class object directly.

See web3.utils <utils> for more.