Skip to content

Latest commit

 

History

History
475 lines (313 loc) · 12.6 KB

web3.main.rst

File metadata and controls

475 lines (313 loc) · 12.6 KB

Web3 API

local

Each Web3 instance exposes the following APIs.

Providers

Attributes

Encoding and Decoding Helpers

Currency Conversions

Addresses

Cryptographic Hashing

Check Encodability

RPC APIS

Each Web3 instance also exposes these namespaced APIs.

Attaching Modules

Modules that inherit from the web3.module.Module class may be attached to the Web3 instance either at instantiation or by making use of the attach_module() method.

To instantiate the Web3 instance with external modules:

>>> from web3 import Web3, EthereumTesterProvider
>>> w3 = Web3(
...     EthereumTesterProvider(),
...     external_modules={
...         'module1': ModuleClass1,  # ModuleClass objects inherit from the `web3.module.Module` class
...         'module2': (ModuleClass2, {
...             'submodule1': ModuleClass3,
...             'submodule2': (ModuleClass4, {
...                 'submodule2a': ModuleClass5  # submodule children may be nested farther, if necessary
...             })
...         })
... })

# These are simply example attributes of the attached module classes (i.e. return_zero)
>>> w3.module1.return_zero
0
>>> w3.module2.submodule1.return_one
1
>>> w3.module2.submodule2.submodule2a.return_two
2