agent0.ethpy.base.web3_setup

Functions and classes for setting up a web3py interface

Functions

initialize_web3_with_http_provider(→ web3.Web3)

Initialize a Web3 instance using an HTTP provider and inject a geth Proof of Authority (poa) middleware.

Module Contents

agent0.ethpy.base.web3_setup.initialize_web3_with_http_provider(ethereum_node: eth_typing.URI | str, request_kwargs: dict | None = None, reset_provider: bool = False) web3.Web3

Initialize a Web3 instance using an HTTP provider and inject a geth Proof of Authority (poa) middleware.

Note

The geth_poa_middleware is required to connect to geth –dev or the Goerli public network. It may also be needed for other EVM compatible blockchains like Polygon or BNB Chain (Binance Smart Chain). See more here.

Parameters:
  • ethereum_node (URI | str) – Address of the http provider

  • request_kwargs (dict | None, optional) – The HTTPProvider uses the python requests library for making requests. If you would like to modify how requests are made, you can use the request_kwargs to do so.

  • reset_provider (bool, optional) – If true, will call anvil_reset before returning the Web3 instance.

Returns:

The connected web3 instance

Return type:

Web3