Skip to content

Account

eth_rpc.Account #

Bases: Request, Account, Generic[NetworkT]

model_config class-attribute instance-attribute #

model_config = ConfigDict(
    alias_generator=to_camel,
    populate_by_name=True,
    from_attributes=True,
)

code_hash instance-attribute #

code_hash

storage_root instance-attribute #

storage_root

balance instance-attribute #

balance

nonce instance-attribute #

nonce

set_network #

set_network(network)
Source code in eth_rpc/utils/model.py
def set_network(self, network: type[Network] | None):
    object.__setattr__(self, "_network", network)

model_post_init #

model_post_init(__context)
Source code in eth_rpc/_request.py
def model_post_init(self, __context):
    network = self.__class__._network
    object.__setattr__(self, "_network", network)
    # overwrite the .rpc() classmethod
    object.__setattr__(self, "rpc", self._rpc)

rpc classmethod #

rpc()

This uses the default network, unless a network has been provided

Source code in eth_rpc/_request.py
@classmethod
def rpc(cls) -> "RPC":
    """
    This uses the default network, unless a network has been provided
    """
    from ._transport import _force_get_global_rpc

    if cls._network is None:
        return _force_get_global_rpc()
    response = _force_get_global_rpc(cls._network)
    return response

get_balance classmethod #

get_balance(address, block_number='latest')
Source code in eth_rpc/account.py
@classmethod
def get_balance(
    self, address: HexAddress, block_number: int | BLOCK_STRINGS = "latest"
) -> RPCResponseModel[GetAccountArgs, HexInteger]:
    return RPCResponseModel(
        self.rpc().get_balance,
        GetAccountArgs(
            address=address,
            block_number=(
                HexInteger(block_number)
                if isinstance(block_number, int)
                else block_number
            ),
        ),
    )

get_account classmethod #

get_account(address, block_number='latest')
Source code in eth_rpc/account.py
@classmethod
def get_account(
    self, address: HexAddress, block_number: int | BLOCK_STRINGS = "latest"
) -> RPCResponseModel[GetAccountArgs, AccountModel]:
    return RPCResponseModel(
        self.rpc().get_account,
        GetAccountArgs(
            address=address,
            block_number=(
                HexInteger(block_number)
                if isinstance(block_number, int)
                else block_number
            ),
        ),
    )