agent0.ethpy.base ================= .. py:module:: agent0.ethpy.base .. autoapi-nested-parse:: Base utilities for working with contracts via web3 .. !! processed by numpydoc !! Submodules ---------- .. toctree:: :maxdepth: 1 /autoapi/agent0/ethpy/base/rpc_interface/index /autoapi/agent0/ethpy/base/transactions/index /autoapi/agent0/ethpy/base/web3_setup/index Attributes ---------- .. autoapisummary:: agent0.ethpy.base.ETH_CONTRACT_ADDRESS agent0.ethpy.base.EARLIEST_BLOCK_LOOKUP Functions --------- .. autoapisummary:: agent0.ethpy.base.get_account_balance agent0.ethpy.base.set_account_balance agent0.ethpy.base.async_wait_for_transaction_receipt agent0.ethpy.base.initialize_web3_with_http_provider Package Contents ---------------- .. py:function:: get_account_balance(web3: web3.Web3, account_address: str) -> int | None Get the balance for an account deployed on the web3 provider. :param web3: The instantiated web3 provider. :type web3: Web3 :param account_address: The address of the account to fund. :type account_address: str :returns: The balance of the account in wei, or None if the rpc call failed. :rtype: int | None .. !! processed by numpydoc !! .. py:function:: set_account_balance(web3: web3.Web3, account_address: str, amount_wei: int) -> web3.types.RPCResponse Set the eth balance of the the account using the web3 provider. :param web3: The instantiated web3 provider. :type web3: Web3 :param account_address: The address of the account to fund. :type account_address: str :param amount_wei: Amount_wei to fund, in wei. :type amount_wei: int :returns: success can be checked by inspecting `rpc_response.error` :rtype: RPCResponse .. !! processed by numpydoc !! .. py:function:: async_wait_for_transaction_receipt(contract_function: pypechain.core.PypechainContractFunction, transaction_hash: hexbytes.HexBytes, timeout: float | None = None, start_latency: float = 0.01, backoff_multiplier: float = 2, validate_transaction: bool = False) -> web3.types.TxReceipt :async: Retrieve the transaction receipt asynchronously, retrying with exponential backoff. This function is copied from `web3.eth.wait_for_transaction_receipt`, but using exponential backoff and async await. This function also takes the place of `sign_transact_and_wait`, except it uses async await. This is due to agent0 using the sync version of web3py, but we wrap things in async calls. :param contract_function: The contract function that was called. :type contract_function: PypechainContractFunction :param transaction_hash: The hash of the transaction. :type transaction_hash: HexBytes :param timeout: The amount of time in seconds to time out the connection. Default is 30. :type timeout: float | None, optional :param start_latency: The starting amount of time in seconds to wait between polls. :type start_latency: float :param backoff_multiplier: The backoff factor for the exponential backoff. :type backoff_multiplier: float :param validate_transaction: Whether to validate the transaction. If True, will throw an exception if the resulting tx_receipt returned a failure status. :type validate_transaction: bool, optional :returns: The transaction receipt :rtype: TxReceipt .. !! processed by numpydoc !! .. py:function:: 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 `_. :param ethereum_node: Address of the http provider :type ethereum_node: URI | str :param request_kwargs: 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. :type request_kwargs: dict | None, optional :param reset_provider: If true, will call anvil_reset before returning the Web3 instance. :type reset_provider: bool, optional :returns: The connected web3 instance :rtype: Web3 .. !! processed by numpydoc !! .. py:data:: ETH_CONTRACT_ADDRESS :value: '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE' .. py:data:: EARLIEST_BLOCK_LOOKUP