Connection

Connect to a node to start interacting with the chain.

>>> from cheb3 import Connection
>>> conn = Connection('http://localhost:8545')
class cheb3.Connection(endpoint_uri: str)

Creates a connection to an HTTP provider.

Parameters:

endpoint_uri (str) – The full URI to the RPC endpoint.

account(private_key: Optional[str] = None) Account

Creates an account associated with this connection.

Parameters:

private_key (str) – The private key of the account, defaults to None. A new account will be created if not provided.

Return type:

Account

contract(signer: Optional[Account] = None, contract_name: str = '', address: Optional[str] = None, **kwargs: Any) Contract

Creates a contract instance associated with this connection.

Parameters:
  • signer (<cheb3.account.Account>) – The account that will sign the following transactions interacting with the contract, defaults to None.

  • contract_name (str) – The name of the contract, defaults to "".

  • address – Set the address of the contract if it is deployed, defaults to None.

Keyword Arguments:
  • abi (ABI) – The ABI of the contract.

  • bytecode (HexStr) – The bytecode of the contract.

Return type:

Contract

get_balance(address: str) int

Returns the balance of the given account.

Parameters:

address (str) – The address of the account.

Return type:

int

get_code(address: str) HexBytes

Returns the code at the given account.

Parameters:

address (str) – The address of the account.

Return type:

HexBytes

get_storage_at(address: str, slot: int) HexBytes

Returns the value from a storage position for the given account.

Parameters:
  • address (str) – The address of the account.

  • slot (int) – The storage slot.

Return type:

HexBytes