LogResult

Documentation for eth_defi.event_reader.logresult.LogResult Python class.

class LogResult[source]

One emitted Solidity event.

  • Type mappings for a raw Python dict object

  • Designed for high performance at the cost of readability and usability

  • The values are untranslated hex strings to maximize the reading speed of events

  • See decode_event() how to turn to ABI converted data

  • See eth_defi.event_reader.reader for more information

Example data (PancakeSwap swap):

{
    'address': '0xc91cd2b9c9aafe494cf3ccc8bee7795deb17231a',
    'blockHash': '0x3bc60abea8fca30516f48b0374542b9c8fa554061c8802d7bcd4211fffbf6caf',
    'blockNumber': 30237147,
    'chunk_id': 30237147,
    'context': None,
    'data': '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000de90d34e1f2e65c0000000000000000000000000000000000000000000018e627902bfb974416f90000000000000000000000000000000000000000000000000000000000000000',
    'event': <class 'web3._utils.datatypes.Swap'>,
    'logIndex': '0x3',
    'removed': False,
    'timestamp': 1690184818,
    'topics': ['0xd78ad95fa46c994b6551d0da85fc275fe613ce37657fb8d5e3d130840159d822',
            '0x00000000000000000000000064c425b6fa04873ea460cda049b340d79cf859d7',
            '0x000000000000000000000000ad1fedfb04377c4b849cef6ef9627bca41955fa0'],
    'transactionHash': '0xf2287653559f01d8afba9ae00386d453b731699b784851f7a8504d41dee7503b',
    'transactionIndex': '0x1'
}

Attributes summary

context

User passed context for the event reader

event

Contract event matches for this raw log

address

Smart contract address

blockHash

Block where the event was

blockNumber

Block number as hex string

timestamp

UNIX timestamp of the block number.

transactionHash

Transaction where the event occred

logIndex

Log index as a hex number

topics

Topics in this receipt.

removed

Block reorg helper

data

Data related to the event

Methods summary

__init__(*args, **kwargs)

clear()

copy()

fromkeys([value])

Create a new dictionary with keys from iterable and values set to value.

get(key[, default])

Return the value for key if key is in the dictionary, else default.

items()

keys()

pop(k[,d])

If the key is not found, return the default if given; otherwise, raise a KeyError.

popitem()

Remove and return a (key, value) pair as a 2-tuple.

setdefault(key[, default])

Insert key with a value of default if key is not in the dictionary.

update([E, ]**F)

If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]

values()

context: eth_defi.event_reader.logresult.LogContext

User passed context for the event reader

event: web3.contract.contract.ContractEvent

Contract event matches for this raw log

To use web3.py helpers to decode this log.

This event instance is just a class reference and does not contain any bound data.

address: str

Smart contract address

blockHash: str

Block where the event was

blockNumber: str

Block number as hex string

timestamp: Optional[int]

UNIX timestamp of the block number. Synthesized by block reader code, not present in the receipt. May be None if timestamp fetching is disabled for the speed reasons.

transactionHash: str

Transaction where the event occred

logIndex: str

Log index as a hex number

topics: List[str]

Topics in this receipt. topics[0] is always the event signature.

TODO: Whether these are strings or HexBytes depends on the EVM backend and Web3 version. Resolve this so that results are normalised to one type.

See eth_defi.reader.conversion how to get Python values out of this.

removed: bool

Block reorg helper

data: str

Data related to the event

As raw hex dump from the JSON-RPC.

See eth_defi.reader.conversion.decode_data() to split to args.