Skip to content

Latest commit

 

History

History
479 lines (316 loc) · 13.1 KB

web3.main.rst

File metadata and controls

479 lines (316 loc) · 13.1 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_modules() method.

To instantiate the Web3 instance with external modules:

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

# `return_zero`, in this case, is an example attribute of the `ModuleClass1` object
>>> w3.module1.return_zero
0
>>> w3.module2.submodule1.return_one
1
>>> w3.module2.submodule2.submodule2a.return_two
2