Skip to content

Transaction Receipt

eth_rpc.TransactionReceipt #

Bases: Request, TransactionReceipt, Generic[Network]

model_config class-attribute instance-attribute #

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

transaction_hash instance-attribute #

transaction_hash

block_hash instance-attribute #

block_hash

block_number instance-attribute #

block_number

logs instance-attribute #

logs

contract_address instance-attribute #

contract_address

effective_gas_price instance-attribute #

effective_gas_price

cumulative_gas_used instance-attribute #

cumulative_gas_used

from_ class-attribute instance-attribute #

from_ = Field(alias='from')

gas_used instance-attribute #

gas_used

logs_bloom instance-attribute #

logs_bloom

status class-attribute instance-attribute #

status = None

to instance-attribute #

to

transaction_index instance-attribute #

transaction_index

type instance-attribute #

type

has_log #

has_log(topic)

Checks is a transaction has a topic in it

Source code in eth_rpc/models/transaction_receipt.py
def has_log(self, topic: HexStr):
    """Checks is a transaction has a topic in it"""
    t = bytes.fromhex(topic.replace("0x", ""))

    return t in BloomFilter(self.logs_bloom)

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_by_hash classmethod #

get_by_hash(tx_hash)
Source code in eth_rpc/transaction.py
@classmethod
def get_by_hash(
    self, tx_hash: HexStr
) -> RPCResponseModel[TransactionRequest, Optional[TransactionReceiptModel]]:
    return RPCResponseModel(
        self.rpc().get_tx_receipt,
        TransactionRequest(
            tx_hash=tx_hash,
        ),
    )

get_block_receipts classmethod #

get_block_receipts(block_number=None, block_hash=None)
Source code in eth_rpc/transaction.py
@classmethod
def get_block_receipts(
    self,
    block_number: Optional[int] = None,
    block_hash: Optional[HexStr] = None,
) -> RPCResponseModel[list[HexStr], list[TransactionReceiptModel]]:
    if block_number:
        param = hex(block_number)
    elif block_hash:
        param = block_hash
    return RPCResponseModel(
        self.rpc().get_block_receipts,
        [HexStr(param)],
    )

alchemy_get_block_receipts classmethod #

alchemy_get_block_receipts(
    block_number=None, block_hash=None
)
Source code in eth_rpc/transaction.py
@classmethod
def alchemy_get_block_receipts(
    self,
    block_number: Optional[int] = None,
    block_hash: Optional[HexStr] = None,
) -> RPCResponseModel[AlchemyBlockReceipt, "AlchemyReceiptsResponse"]:
    return RPCResponseModel(
        self.rpc().alchemy_get_block_receipts,
        AlchemyBlockReceipt(
            params=AlchemyParams(
                block_number=HexInteger(block_number) if block_number else None,
                block_hash=block_hash,
            )
        ),
    )