evmspec.structs package

Subpackages

Submodules

evmspec.structs.block module

class evmspec.structs.block.BaseBlock[source]

Bases: MinedBlock

Represents a base Ethereum block with base fee per gas.

See also

get(key, default=None)

Get the value associated with a key, or a default value if the key is not present.

Parameters:
  • key (str) – The key to look up.

  • default (optional) – The value to return if the key is not present.

Return type:

Any

Example

>>> class MyStruct(DictStruct):
...     field1: str
>>> s = MyStruct(field1="value")
>>> s.get('field1')
'value'
>>> s.get('field2', 'default')
'default'
items()

Returns an iterator over the struct’s field name and value pairs.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.items())
[('field1', 'value'), ('field2', 42)]
Return type:

Iterator[Tuple[str, Any]]

keys()

Returns an iterator over the field names of the struct.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.keys())
['field1', 'field2']
Return type:

Iterator[str]

values()

Returns an iterator over the struct’s field values.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.values())
['value', 42]
Return type:

Iterator[Any]

baseFeePerGas: Wei

The base fee per gas.

difficulty: uint

The difficulty at this block.

Examples

>>> mined_block = MinedBlock(...)
>>> mined_block.difficulty
uint(123456789)
extraData: HexBytes

The “extra data” field of this block.

gasLimit: Wei

The maximum gas allowed in this block.

gasUsed: Wei

The total used gas by all transactions in this block.

hash: BlockHash

The hash of the block.

logsBloom: HexBytes

The bloom filter for the logs of the block.

miner: Address

The address of the miner receiving the reward.

mixHash: HexBytes

A string of a 256-bit hash encoded as a hexadecimal.

nonce: Nonce

Hash of the generated proof-of-work.

number: BlockNumber

The block number.

parentHash: HexBytes

Hash of the parent block.

receiptsRoot: HexBytes

The root of the receipts trie of the block.

sha3Uncles: HexBytes

SHA3 of the uncles data in the block.

size: uint

The size of the block, in bytes.

stateRoot: HexBytes

The root of the final state trie of the block.

timestamp: UnixTimestamp

The Unix timestamp for when the block was collated.

totalDifficulty: uint

The total difficulty of the chain until this block.

Examples

>>> mined_block = MinedBlock(...)
>>> mined_block.totalDifficulty
uint(987654321)
property transactions: Tuple[TransactionHash, ...] | Tuple[TransactionLegacy | Transaction2930 | Transaction1559 | Transaction4844, ...]

Decodes and returns the transactions in the block.

Returns:

A tuple of transaction objects or transaction hashes.

Examples

>>> block = TinyBlock(timestamp=..., _transactions=...)
>>> transactions = block.transactions
transactionsRoot: HexBytes

The root of the transaction trie of the block.

uncles: Tuple[HexBytes, ...]

An array of uncle hashes.

class evmspec.structs.block.Block[source]

Bases: TinyBlock

Represents a full Ethereum block with all standard fields.

See also

get(key, default=None)

Get the value associated with a key, or a default value if the key is not present.

Parameters:
  • key (str) – The key to look up.

  • default (optional) – The value to return if the key is not present.

Return type:

Any

Example

>>> class MyStruct(DictStruct):
...     field1: str
>>> s = MyStruct(field1="value")
>>> s.get('field1')
'value'
>>> s.get('field2', 'default')
'default'
items()

Returns an iterator over the struct’s field name and value pairs.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.items())
[('field1', 'value'), ('field2', 42)]
Return type:

Iterator[Tuple[str, Any]]

keys()

Returns an iterator over the field names of the struct.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.keys())
['field1', 'field2']
Return type:

Iterator[str]

values()

Returns an iterator over the struct’s field values.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.values())
['value', 42]
Return type:

Iterator[Any]

extraData: HexBytes

The “extra data” field of this block.

gasLimit: Wei

The maximum gas allowed in this block.

gasUsed: Wei

The total used gas by all transactions in this block.

hash: BlockHash

The hash of the block.

logsBloom: HexBytes

The bloom filter for the logs of the block.

miner: Address

The address of the miner receiving the reward.

mixHash: HexBytes

A string of a 256-bit hash encoded as a hexadecimal.

nonce: Nonce

Hash of the generated proof-of-work.

number: BlockNumber

The block number.

parentHash: HexBytes

Hash of the parent block.

receiptsRoot: HexBytes

The root of the receipts trie of the block.

sha3Uncles: HexBytes

SHA3 of the uncles data in the block.

size: uint

The size of the block, in bytes.

stateRoot: HexBytes

The root of the final state trie of the block.

timestamp: UnixTimestamp

The Unix timestamp for when the block was collated.

property transactions: Tuple[TransactionHash, ...] | Tuple[TransactionLegacy | Transaction2930 | Transaction1559 | Transaction4844, ...]

Decodes and returns the transactions in the block.

Returns:

A tuple of transaction objects or transaction hashes.

Examples

>>> block = TinyBlock(timestamp=..., _transactions=...)
>>> transactions = block.transactions
transactionsRoot: HexBytes

The root of the transaction trie of the block.

uncles: Tuple[HexBytes, ...]

An array of uncle hashes.

class evmspec.structs.block.MinedBlock[source]

Bases: Block

Represents a mined Ethereum block with difficulty fields.

See also

get(key, default=None)

Get the value associated with a key, or a default value if the key is not present.

Parameters:
  • key (str) – The key to look up.

  • default (optional) – The value to return if the key is not present.

Return type:

Any

Example

>>> class MyStruct(DictStruct):
...     field1: str
>>> s = MyStruct(field1="value")
>>> s.get('field1')
'value'
>>> s.get('field2', 'default')
'default'
items()

Returns an iterator over the struct’s field name and value pairs.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.items())
[('field1', 'value'), ('field2', 42)]
Return type:

Iterator[Tuple[str, Any]]

keys()

Returns an iterator over the field names of the struct.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.keys())
['field1', 'field2']
Return type:

Iterator[str]

values()

Returns an iterator over the struct’s field values.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.values())
['value', 42]
Return type:

Iterator[Any]

difficulty: uint

The difficulty at this block.

Examples

>>> mined_block = MinedBlock(...)
>>> mined_block.difficulty
uint(123456789)
extraData: HexBytes

The “extra data” field of this block.

gasLimit: Wei

The maximum gas allowed in this block.

gasUsed: Wei

The total used gas by all transactions in this block.

hash: BlockHash

The hash of the block.

logsBloom: HexBytes

The bloom filter for the logs of the block.

miner: Address

The address of the miner receiving the reward.

mixHash: HexBytes

A string of a 256-bit hash encoded as a hexadecimal.

nonce: Nonce

Hash of the generated proof-of-work.

number: BlockNumber

The block number.

parentHash: HexBytes

Hash of the parent block.

receiptsRoot: HexBytes

The root of the receipts trie of the block.

sha3Uncles: HexBytes

SHA3 of the uncles data in the block.

size: uint

The size of the block, in bytes.

stateRoot: HexBytes

The root of the final state trie of the block.

timestamp: UnixTimestamp

The Unix timestamp for when the block was collated.

totalDifficulty: uint

The total difficulty of the chain until this block.

Examples

>>> mined_block = MinedBlock(...)
>>> mined_block.totalDifficulty
uint(987654321)
property transactions: Tuple[TransactionHash, ...] | Tuple[TransactionLegacy | Transaction2930 | Transaction1559 | Transaction4844, ...]

Decodes and returns the transactions in the block.

Returns:

A tuple of transaction objects or transaction hashes.

Examples

>>> block = TinyBlock(timestamp=..., _transactions=...)
>>> transactions = block.transactions
transactionsRoot: HexBytes

The root of the transaction trie of the block.

uncles: Tuple[HexBytes, ...]

An array of uncle hashes.

class evmspec.structs.block.ShanghaiCapellaBlock[source]

Bases: Block

Represents a block from the Ethereum Shanghai or Capella upgrades, which includes staking withdrawals.

get(key, default=None)

Get the value associated with a key, or a default value if the key is not present.

Parameters:
  • key (str) – The key to look up.

  • default (optional) – The value to return if the key is not present.

Return type:

Any

Example

>>> class MyStruct(DictStruct):
...     field1: str
>>> s = MyStruct(field1="value")
>>> s.get('field1')
'value'
>>> s.get('field2', 'default')
'default'
items()

Returns an iterator over the struct’s field name and value pairs.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.items())
[('field1', 'value'), ('field2', 42)]
Return type:

Iterator[Tuple[str, Any]]

keys()

Returns an iterator over the field names of the struct.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.keys())
['field1', 'field2']
Return type:

Iterator[str]

values()

Returns an iterator over the struct’s field values.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.values())
['value', 42]
Return type:

Iterator[Any]

extraData: HexBytes

The “extra data” field of this block.

gasLimit: Wei

The maximum gas allowed in this block.

gasUsed: Wei

The total used gas by all transactions in this block.

hash: BlockHash

The hash of the block.

logsBloom: HexBytes

The bloom filter for the logs of the block.

miner: Address

The address of the miner receiving the reward.

mixHash: HexBytes

A string of a 256-bit hash encoded as a hexadecimal.

nonce: Nonce

Hash of the generated proof-of-work.

number: BlockNumber

The block number.

parentHash: HexBytes

Hash of the parent block.

receiptsRoot: HexBytes

The root of the receipts trie of the block.

sha3Uncles: HexBytes

SHA3 of the uncles data in the block.

size: uint

The size of the block, in bytes.

stateRoot: HexBytes

The root of the final state trie of the block.

timestamp: UnixTimestamp

The Unix timestamp for when the block was collated.

property transactions: Tuple[TransactionHash, ...] | Tuple[TransactionLegacy | Transaction2930 | Transaction1559 | Transaction4844, ...]

Decodes and returns the transactions in the block.

Returns:

A tuple of transaction objects or transaction hashes.

Examples

>>> block = TinyBlock(timestamp=..., _transactions=...)
>>> transactions = block.transactions
transactionsRoot: HexBytes

The root of the transaction trie of the block.

uncles: Tuple[HexBytes, ...]

An array of uncle hashes.

property withdrawals: Tuple[StakingWithdrawal, ...]

Decodes and returns the staking withdrawals in the block.

Returns:

A tuple of staking withdrawal objects.

Examples

>>> block = ShanghaiCapellaBlock(...)
>>> withdrawals = block.withdrawals
class evmspec.structs.block.StakingWithdrawal[source]

Bases: DictStruct

A Struct representing an Ethereum staking withdrawal.

get(key, default=None)

Get the value associated with a key, or a default value if the key is not present.

Parameters:
  • key (str) – The key to look up.

  • default (optional) – The value to return if the key is not present.

Return type:

Any

Example

>>> class MyStruct(DictStruct):
...     field1: str
>>> s = MyStruct(field1="value")
>>> s.get('field1')
'value'
>>> s.get('field2', 'default')
'default'
items()

Returns an iterator over the struct’s field name and value pairs.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.items())
[('field1', 'value'), ('field2', 42)]
Return type:

Iterator[Tuple[str, Any]]

keys()

Returns an iterator over the field names of the struct.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.keys())
['field1', 'field2']
Return type:

Iterator[str]

values()

Returns an iterator over the struct’s field values.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.values())
['value', 42]
Return type:

Iterator[Any]

address: Address

This field is not always present.

amount: Wei

This field is not always present.

index: IntId
validatorIndex: IntId

This field is not always present.

class evmspec.structs.block.TinyBlock[source]

Bases: LazyDictStruct

Represents a minimal block structure with essential fields.

The _transactions attribute can contain either transaction hashes, full transaction objects, or TransactionRLP objects, depending on the context of the RPC call used to retrieve the block, such as eth_getBlockByHash or eth_getBlockByNumber.

See also

  • evmspec.transaction.Transaction

  • evmspec.transaction.TransactionRLP

get(key, default=None)

Get the value associated with a key, or a default value if the key is not present.

Parameters:
  • key (str) – The key to look up.

  • default (optional) – The value to return if the key is not present.

Return type:

Any

Example

>>> class MyStruct(DictStruct):
...     field1: str
>>> s = MyStruct(field1="value")
>>> s.get('field1')
'value'
>>> s.get('field2', 'default')
'default'
items()

Returns an iterator over the struct’s field name and value pairs.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.items())
[('field1', 'value'), ('field2', 42)]
Return type:

Iterator[Tuple[str, Any]]

keys()

Returns an iterator over the field names of the struct.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.keys())
['field1', 'field2']
Return type:

Iterator[str]

values()

Returns an iterator over the struct’s field values.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.values())
['value', 42]
Return type:

Iterator[Any]

timestamp: UnixTimestamp

The Unix timestamp for when the block was collated.

property transactions: Tuple[TransactionHash, ...] | Tuple[TransactionLegacy | Transaction2930 | Transaction1559 | Transaction4844, ...]

Decodes and returns the transactions in the block.

Returns:

A tuple of transaction objects or transaction hashes.

Examples

>>> block = TinyBlock(timestamp=..., _transactions=...)
>>> transactions = block.transactions
evmspec.structs.block.Transactions

Represents a collection of transactions within a block, which can be either transaction hashes or full transaction objects.

Examples

>>> tx_hashes = (TransactionHash("0x..."), TransactionHash("0x..."))
>>> tx_objects = (Transaction(...), Transaction(...))

See also

  • evmspec.transaction.Transaction

alias of Union[Tuple[TransactionHash, …], Tuple[Union[TransactionLegacy, Transaction2930, Transaction1559, Transaction4844], …]]

evmspec.structs.header module

class evmspec.structs.header.ErigonBlockHeader[source]

Bases: LazyDictStruct

Represents a block header in the Erigon client.

This class inherits from LazyDictStruct, which provides features for handling block header data, ensuring immutability and strictness to known fields. It is currently under development, and specific features may not yet be functional. There may be known issues needing resolution.

See also

  • LazyDictStruct for more details on the underlying structure and its features.

get(key, default=None)

Get the value associated with a key, or a default value if the key is not present.

Parameters:
  • key (str) – The key to look up.

  • default (optional) – The value to return if the key is not present.

Return type:

Any

Example

>>> class MyStruct(DictStruct):
...     field1: str
>>> s = MyStruct(field1="value")
>>> s.get('field1')
'value'
>>> s.get('field2', 'default')
'default'
items()

Returns an iterator over the struct’s field name and value pairs.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.items())
[('field1', 'value'), ('field2', 42)]
Return type:

Iterator[Tuple[str, Any]]

keys()

Returns an iterator over the field names of the struct.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.keys())
['field1', 'field2']
Return type:

Iterator[str]

values()

Returns an iterator over the struct’s field values.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.values())
['value', 42]
Return type:

Iterator[Any]

coinbase: Address

The address of the miner who mined the block.

Examples

>>> header = ErigonBlockHeader(
...     timestamp=UnixTimestamp(1638316800),
...     parentHash=HexBytes("0xabc"),
...     uncleHash=HexBytes("0xdef"),
...     coinbase=Address("0x123"),
...     root=HexBytes("0x456"),
...     difficulty=uint(1000)
... )
>>> header.coinbase
Address('0x123')
difficulty: uint

The difficulty level of the block.

Examples

>>> header = ErigonBlockHeader(
...     timestamp=UnixTimestamp(1638316800),
...     parentHash=HexBytes("0xabc"),
...     uncleHash=HexBytes("0xdef"),
...     coinbase=Address("0x123"),
...     root=HexBytes("0x456"),
...     difficulty=uint(1000)
... )
>>> header.difficulty
uint(1000)
parentHash: HexBytes

The hash of the parent block.

Examples

>>> header = ErigonBlockHeader(
...     timestamp=UnixTimestamp(1638316800),
...     parentHash=HexBytes("0xabc"),
...     uncleHash=HexBytes("0xdef"),
...     coinbase=Address("0x123"),
...     root=HexBytes("0x456"),
...     difficulty=uint(1000)
... )
>>> header.parentHash
HexBytes('0xabc')
root: HexBytes

The root hash of the state trie.

Examples

>>> header = ErigonBlockHeader(
...     timestamp=UnixTimestamp(1638316800),
...     parentHash=HexBytes("0xabc"),
...     uncleHash=HexBytes("0xdef"),
...     coinbase=Address("0x123"),
...     root=HexBytes("0x456"),
...     difficulty=uint(1000)
... )
>>> header.root
HexBytes('0x456')
timestamp: UnixTimestamp

The Unix timestamp for when the block was collated.

Examples

>>> header = ErigonBlockHeader(
...     timestamp=UnixTimestamp(1638316800),
...     parentHash=HexBytes("0xabc"),
...     uncleHash=HexBytes("0xdef"),
...     coinbase=Address("0x123"),
...     root=HexBytes("0x456"),
...     difficulty=uint(1000)
... )
>>> header.timestamp
UnixTimestamp(1638316800)
uncleHash: HexBytes

The hash of the list of uncle headers.

Examples

>>> header = ErigonBlockHeader(
...     timestamp=UnixTimestamp(1638316800),
...     parentHash=HexBytes("0xabc"),
...     uncleHash=HexBytes("0xdef"),
...     coinbase=Address("0x123"),
...     root=HexBytes("0x456"),
...     difficulty=uint(1000)
... )
>>> header.uncleHash
HexBytes('0xdef')

evmspec.structs.log module

class evmspec.structs.log.Data[source]

Bases: HexBytes

Represents data in Ethereum logs, providing utilities for interpreting the data as various types. The data is assumed to be in hexadecimal format as received from the RPC.

Examples

>>> data = Data("0x000000000000000000000000000000000000000000000000000000000000000a")
>>> data.as_uint
10
>>> data.as_address
'0x000000000000000000000000000000000000000a'
static __new__(cls, val)
Parameters:
Return type:

HexBytes

capitalize() copy of B

Return a copy of B with only its first character capitalized (ASCII) and the rest lower-cased.

center(width, fillchar=b' ', /)

Return a centered string of length width.

Padding is done using the specified fill character.

count(sub[, start[, end]]) int

Return the number of non-overlapping occurrences of subsection sub in bytes B[start:end]. Optional arguments start and end are interpreted as in slice notation.

decode(encoding='utf-8', errors='strict')

Decode the bytes using the codec registered for encoding.

encoding

The encoding with which to decode the bytes.

errors

The error handling scheme to use for the handling of decoding errors. The default is ‘strict’ meaning that decoding errors raise a UnicodeDecodeError. Other possible values are ‘ignore’ and ‘replace’ as well as any other name registered with codecs.register_error that can handle UnicodeDecodeErrors.

endswith(suffix[, start[, end]]) bool

Return True if B ends with the specified suffix, False otherwise. With optional start, test B beginning at that position. With optional end, stop comparing B at that position. suffix can also be a tuple of bytes to try.

expandtabs(tabsize=8)

Return a copy where all tab characters are expanded using spaces.

If tabsize is not given, a tab size of 8 characters is assumed.

find(sub[, start[, end]]) int

Return the lowest index in B where subsection sub is found, such that sub is contained within B[start,end]. Optional arguments start and end are interpreted as in slice notation.

Return -1 on failure.

fromhex()

Create a bytes object from a string of hexadecimal numbers.

Spaces between two numbers are accepted. Example: bytes.fromhex(‘B9 01EF’) -> b’\xb9\x01\xef’.

hex()

Create a string of hexadecimal numbers from a bytes object.

sep

An optional single character or byte to separate hex bytes.

bytes_per_sep

How many bytes between separators. Positive values count from the right, negative values count from the left.

Example: >>> value = b’xb9x01xef’ >>> value.hex() ‘b901ef’ >>> value.hex(‘:’) ‘b9:01:ef’ >>> value.hex(‘:’, 2) ‘b9:01ef’ >>> value.hex(‘:’, -2) ‘b901:ef’

index(sub[, start[, end]]) int

Return the lowest index in B where subsection sub is found, such that sub is contained within B[start,end]. Optional arguments start and end are interpreted as in slice notation.

Raises ValueError when the subsection is not found.

isalnum() bool

Return True if all characters in B are alphanumeric and there is at least one character in B, False otherwise.

isalpha() bool

Return True if all characters in B are alphabetic and there is at least one character in B, False otherwise.

isascii() bool

Return True if B is empty or all characters in B are ASCII, False otherwise.

isdigit() bool

Return True if all characters in B are digits and there is at least one character in B, False otherwise.

islower() bool

Return True if all cased characters in B are lowercase and there is at least one cased character in B, False otherwise.

isspace() bool

Return True if all characters in B are whitespace and there is at least one character in B, False otherwise.

istitle() bool

Return True if B is a titlecased string and there is at least one character in B, i.e. uppercase characters may only follow uncased characters and lowercase characters only cased ones. Return False otherwise.

isupper() bool

Return True if all cased characters in B are uppercase and there is at least one cased character in B, False otherwise.

join(iterable_of_bytes, /)

Concatenate any number of bytes objects.

The bytes whose method is called is inserted in between each pair.

The result is returned as a new bytes object.

Example: b’.’.join([b’ab’, b’pq’, b’rs’]) -> b’ab.pq.rs’.

ljust(width, fillchar=b' ', /)

Return a left-justified string of length width.

Padding is done using the specified fill character.

lower() copy of B

Return a copy of B with all ASCII characters converted to lowercase.

lstrip(bytes=None, /)

Strip leading bytes contained in the argument.

If the argument is omitted or None, strip leading ASCII whitespace.

static maketrans(frm, to, /)

Return a translation table useable for the bytes or bytearray translate method.

The returned table will be one where each byte in frm is mapped to the byte at the same position in to.

The bytes objects frm and to must be of the same length.

partition(sep, /)

Partition the bytes into three parts using the given separator.

This will search for the separator sep in the bytes. If the separator is found, returns a 3-tuple containing the part before the separator, the separator itself, and the part after it.

If the separator is not found, returns a 3-tuple containing the original bytes object and two empty bytes objects.

removeprefix(prefix, /)

Return a bytes object with the given prefix string removed if present.

If the bytes starts with the prefix string, return bytes[len(prefix):]. Otherwise, return a copy of the original bytes.

removesuffix(suffix, /)

Return a bytes object with the given suffix string removed if present.

If the bytes ends with the suffix string and that suffix is not empty, return bytes[:-len(prefix)]. Otherwise, return a copy of the original bytes.

replace(old, new, count=-1, /)

Return a copy with all occurrences of substring old replaced by new.

count

Maximum number of occurrences to replace. -1 (the default value) means replace all occurrences.

If the optional argument count is given, only the first count occurrences are replaced.

rfind(sub[, start[, end]]) int

Return the highest index in B where subsection sub is found, such that sub is contained within B[start,end]. Optional arguments start and end are interpreted as in slice notation.

Return -1 on failure.

rindex(sub[, start[, end]]) int

Return the highest index in B where subsection sub is found, such that sub is contained within B[start,end]. Optional arguments start and end are interpreted as in slice notation.

Raise ValueError when the subsection is not found.

rjust(width, fillchar=b' ', /)

Return a right-justified string of length width.

Padding is done using the specified fill character.

rpartition(sep, /)

Partition the bytes into three parts using the given separator.

This will search for the separator sep in the bytes, starting at the end. If the separator is found, returns a 3-tuple containing the part before the separator, the separator itself, and the part after it.

If the separator is not found, returns a 3-tuple containing two empty bytes objects and the original bytes object.

rsplit(sep=None, maxsplit=-1)

Return a list of the sections in the bytes, using sep as the delimiter.

sep

The delimiter according which to split the bytes. None (the default value) means split on ASCII whitespace characters (space, tab, return, newline, formfeed, vertical tab).

maxsplit

Maximum number of splits to do. -1 (the default value) means no limit.

Splitting is done starting at the end of the bytes and working to the front.

rstrip(bytes=None, /)

Strip trailing bytes contained in the argument.

If the argument is omitted or None, strip trailing ASCII whitespace.

split(sep=None, maxsplit=-1)

Return a list of the sections in the bytes, using sep as the delimiter.

sep

The delimiter according which to split the bytes. None (the default value) means split on ASCII whitespace characters (space, tab, return, newline, formfeed, vertical tab).

maxsplit

Maximum number of splits to do. -1 (the default value) means no limit.

splitlines(keepends=False)

Return a list of the lines in the bytes, breaking at line boundaries.

Line breaks are not included in the resulting list unless keepends is given and true.

startswith(prefix[, start[, end]]) bool

Return True if B starts with the specified prefix, False otherwise. With optional start, test B beginning at that position. With optional end, stop comparing B at that position. prefix can also be a tuple of bytes to try.

strip(bytes=None, /)

Strip leading and trailing bytes contained in the argument.

If the argument is omitted or None, strip leading and trailing ASCII whitespace.

swapcase() copy of B

Return a copy of B with uppercase ASCII characters converted to lowercase ASCII and vice versa.

title() copy of B

Return a titlecased version of B, i.e. ASCII words start with uppercase characters, all remaining cased characters have lowercase.

to_0x_hex()

Convert the bytes to a 0x-prefixed hex string

Return type:

str

translate(table, /, delete=b'')

Return a copy with each character mapped by the given translation table.

table

Translation table, which must be a bytes object of length 256.

All characters occurring in the optional argument delete are removed. The remaining characters are mapped through the given translation table.

upper() copy of B

Return a copy of B with all ASCII characters converted to uppercase.

zfill(width, /)

Pad a numeric string with zeros on the left, to fill a field of the given width.

The original string is never truncated.

property as_address: Address

Interprets the data as an Ethereum address.

Raises:

ValueError – If the data does not represent a valid Ethereum address.

Examples

>>> data = Data("0x000000000000000000000000000000000000000a")
>>> data.as_address
'0x000000000000000000000000000000000000000a'
property as_uint: uint

Interprets the data as an unsigned integer.

Examples

>>> data = Data("0x0a")
>>> data.as_uint
10
property as_uint128: uint128

Interprets the data as a 128-bit unsigned integer.

Examples

>>> data = Data("0x0000000000000000000000000000000a")
>>> data.as_uint128
10
property as_uint256: uint256

Interprets the data as a 256-bit unsigned integer.

Examples

>>> data = Data("0x000000000000000000000000000000000000000000000000000000000000000a")
>>> data.as_uint256
10
property as_uint64: uint64

Interprets the data as a 64-bit unsigned integer.

Examples

>>> data = Data("0x000000000000000a")
>>> data.as_uint64
10
property as_uint8: uint8

Interprets the data as an 8-bit unsigned integer.

Examples

>>> data = Data("0x01")
>>> data.as_uint8
1
class evmspec.structs.log.FullLog[source]

Bases: Log

Represents a full log structure with comprehensive block and transaction details.

See also

Log for the comprehensive log structure with transaction details.

get(key, default=None)

Get the value associated with a key, or a default value if the key is not present.

Parameters:
  • key (str) – The key to look up.

  • default (optional) – The value to return if the key is not present.

Return type:

Any

Example

>>> class MyStruct(DictStruct):
...     field1: str
>>> s = MyStruct(field1="value")
>>> s.get('field1')
'value'
>>> s.get('field2', 'default')
'default'
items()

Returns an iterator over the struct’s field name and value pairs.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.items())
[('field1', 'value'), ('field2', 42)]
Return type:

Iterator[Tuple[str, Any]]

keys()

Returns an iterator over the field names of the struct.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.keys())
['field1', 'field2']
Return type:

Iterator[str]

values()

Returns an iterator over the struct’s field values.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.values())
['value', 42]
Return type:

Iterator[Any]

address: Address | None

The address of the contract that generated the log.

property block: BlockNumber | None

A shorthand getter for ‘blockNumber’.

blockHash: BlockHash | None

The hash of the block where the transaction was included where the log originated from. None for pending transactions.

blockNumber: BlockNumber | None

The block where the transaction was included where the log originated from. None for pending transactions.

data: Data | None

Array of 32-bytes non-indexed return data of the log.

logIndex: LogIndex

Index position of the log in the transaction. None for pending transactions.

removed: bool | None

True when the log was removed, due to a chain reorganization. False if it’s a valid log.

property topic0: Topic

Returns the first topic.

property topic1: Topic

Returns the second topic if it exists, otherwise raises an AttributeError.

property topic2: Topic

Returns the third topic if it exists, otherwise raises an AttributeError.

property topic3: Topic

Returns the fourth topic if it exists, otherwise raises an AttributeError.

topics: Tuple[Topic, ...]

An array of 0 to 4 32-byte topics. The first topic is the event signature and the others are indexed filters on the event return data.

transactionHash: TransactionHash

The hash of the transaction that generated the log.

transactionIndex: TransactionIndex

The index of the transaction in the block, where the log originated from.

class evmspec.structs.log.Log[source]

Bases: SmallLog

Represents a comprehensive log structure with additional transaction details.

See also

SmallLog for the log structure with address and data.

get(key, default=None)

Get the value associated with a key, or a default value if the key is not present.

Parameters:
  • key (str) – The key to look up.

  • default (optional) – The value to return if the key is not present.

Return type:

Any

Example

>>> class MyStruct(DictStruct):
...     field1: str
>>> s = MyStruct(field1="value")
>>> s.get('field1')
'value'
>>> s.get('field2', 'default')
'default'
items()

Returns an iterator over the struct’s field name and value pairs.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.items())
[('field1', 'value'), ('field2', 42)]
Return type:

Iterator[Tuple[str, Any]]

keys()

Returns an iterator over the field names of the struct.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.keys())
['field1', 'field2']
Return type:

Iterator[str]

values()

Returns an iterator over the struct’s field values.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.values())
['value', 42]
Return type:

Iterator[Any]

address: Address | None

The address of the contract that generated the log.

property block: BlockNumber | None

A shorthand getter for ‘blockNumber’.

blockNumber: BlockNumber | None

The block where the transaction was included where the log originated from. None for pending transactions.

data: Data | None

Array of 32-bytes non-indexed return data of the log.

logIndex: LogIndex

Index position of the log in the transaction. None for pending transactions.

removed: bool | None

True when the log was removed, due to a chain reorganization. False if it’s a valid log.

property topic0: Topic

Returns the first topic.

property topic1: Topic

Returns the second topic if it exists, otherwise raises an AttributeError.

property topic2: Topic

Returns the third topic if it exists, otherwise raises an AttributeError.

property topic3: Topic

Returns the fourth topic if it exists, otherwise raises an AttributeError.

topics: Tuple[Topic, ...]

An array of 0 to 4 32-byte topics. The first topic is the event signature and the others are indexed filters on the event return data.

transactionHash: TransactionHash

The hash of the transaction that generated the log.

transactionIndex: TransactionIndex

The index of the transaction in the block, where the log originated from.

class evmspec.structs.log.SmallLog[source]

Bases: TinyLog

Represents a log with additional attributes for the contract address and data.

See also

TinyLog for the base log structure.

get(key, default=None)

Get the value associated with a key, or a default value if the key is not present.

Parameters:
  • key (str) – The key to look up.

  • default (optional) – The value to return if the key is not present.

Return type:

Any

Example

>>> class MyStruct(DictStruct):
...     field1: str
>>> s = MyStruct(field1="value")
>>> s.get('field1')
'value'
>>> s.get('field2', 'default')
'default'
items()

Returns an iterator over the struct’s field name and value pairs.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.items())
[('field1', 'value'), ('field2', 42)]
Return type:

Iterator[Tuple[str, Any]]

keys()

Returns an iterator over the field names of the struct.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.keys())
['field1', 'field2']
Return type:

Iterator[str]

values()

Returns an iterator over the struct’s field values.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.values())
['value', 42]
Return type:

Iterator[Any]

address: Address | None

The address of the contract that generated the log.

data: Data | None

Array of 32-bytes non-indexed return data of the log.

property topic0: Topic

Returns the first topic.

property topic1: Topic

Returns the second topic if it exists, otherwise raises an AttributeError.

property topic2: Topic

Returns the third topic if it exists, otherwise raises an AttributeError.

property topic3: Topic

Returns the fourth topic if it exists, otherwise raises an AttributeError.

topics: Tuple[Topic, ...]

An array of 0 to 4 32-byte topics. The first topic is the event signature and the others are indexed filters on the event return data.

class evmspec.structs.log.TinyLog[source]

Bases: LazyDictStruct

Represents a minimal log structure with topics.

Examples

>>> log = TinyLog(topics=(Topic(b''*32),))
>>> log.topic0
Topic('0x0000000000000000000000000000000000000000000000000000000000000000')
get(key, default=None)

Get the value associated with a key, or a default value if the key is not present.

Parameters:
  • key (str) – The key to look up.

  • default (optional) – The value to return if the key is not present.

Return type:

Any

Example

>>> class MyStruct(DictStruct):
...     field1: str
>>> s = MyStruct(field1="value")
>>> s.get('field1')
'value'
>>> s.get('field2', 'default')
'default'
items()

Returns an iterator over the struct’s field name and value pairs.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.items())
[('field1', 'value'), ('field2', 42)]
Return type:

Iterator[Tuple[str, Any]]

keys()

Returns an iterator over the field names of the struct.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.keys())
['field1', 'field2']
Return type:

Iterator[str]

values()

Returns an iterator over the struct’s field values.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.values())
['value', 42]
Return type:

Iterator[Any]

property topic0: Topic

Returns the first topic.

property topic1: Topic

Returns the second topic if it exists, otherwise raises an AttributeError.

property topic2: Topic

Returns the third topic if it exists, otherwise raises an AttributeError.

property topic3: Topic

Returns the fourth topic if it exists, otherwise raises an AttributeError.

topics: Tuple[Topic, ...]

An array of 0 to 4 32-byte topics. The first topic is the event signature and the others are indexed filters on the event return data.

class evmspec.structs.log.Topic[source]

Bases: HexBytes32, Data

Represents a topic in Ethereum logs, providing utilities for interpreting the topic as various EVM types.

See also

Data for more utilities on interpreting data.

static __new__(cls, v)

Create a new HexBytes32 object.

Parameters:

v – A value that can be converted to HexBytes32.

Returns:

A HexBytes32 object.

Raises:

ValueError – If the string representation is not the correct length.

Examples

>>> HexBytes32("0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef")
HexBytes32(0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef)
capitalize() copy of B

Return a copy of B with only its first character capitalized (ASCII) and the rest lower-cased.

center(width, fillchar=b' ', /)

Return a centered string of length width.

Padding is done using the specified fill character.

count(sub[, start[, end]]) int

Return the number of non-overlapping occurrences of subsection sub in bytes B[start:end]. Optional arguments start and end are interpreted as in slice notation.

decode(encoding='utf-8', errors='strict')

Decode the bytes using the codec registered for encoding.

encoding

The encoding with which to decode the bytes.

errors

The error handling scheme to use for the handling of decoding errors. The default is ‘strict’ meaning that decoding errors raise a UnicodeDecodeError. Other possible values are ‘ignore’ and ‘replace’ as well as any other name registered with codecs.register_error that can handle UnicodeDecodeErrors.

endswith(suffix[, start[, end]]) bool

Return True if B ends with the specified suffix, False otherwise. With optional start, test B beginning at that position. With optional end, stop comparing B at that position. suffix can also be a tuple of bytes to try.

expandtabs(tabsize=8)

Return a copy where all tab characters are expanded using spaces.

If tabsize is not given, a tab size of 8 characters is assumed.

find(sub[, start[, end]]) int

Return the lowest index in B where subsection sub is found, such that sub is contained within B[start,end]. Optional arguments start and end are interpreted as in slice notation.

Return -1 on failure.

fromhex()

Create a bytes object from a string of hexadecimal numbers.

Spaces between two numbers are accepted. Example: bytes.fromhex(‘B9 01EF’) -> b’\xb9\x01\xef’.

hex()

Create a string of hexadecimal numbers from a bytes object.

sep

An optional single character or byte to separate hex bytes.

bytes_per_sep

How many bytes between separators. Positive values count from the right, negative values count from the left.

Example: >>> value = b’xb9x01xef’ >>> value.hex() ‘b901ef’ >>> value.hex(‘:’) ‘b9:01:ef’ >>> value.hex(‘:’, 2) ‘b9:01ef’ >>> value.hex(‘:’, -2) ‘b901:ef’

index(sub[, start[, end]]) int

Return the lowest index in B where subsection sub is found, such that sub is contained within B[start,end]. Optional arguments start and end are interpreted as in slice notation.

Raises ValueError when the subsection is not found.

isalnum() bool

Return True if all characters in B are alphanumeric and there is at least one character in B, False otherwise.

isalpha() bool

Return True if all characters in B are alphabetic and there is at least one character in B, False otherwise.

isascii() bool

Return True if B is empty or all characters in B are ASCII, False otherwise.

isdigit() bool

Return True if all characters in B are digits and there is at least one character in B, False otherwise.

islower() bool

Return True if all cased characters in B are lowercase and there is at least one cased character in B, False otherwise.

isspace() bool

Return True if all characters in B are whitespace and there is at least one character in B, False otherwise.

istitle() bool

Return True if B is a titlecased string and there is at least one character in B, i.e. uppercase characters may only follow uncased characters and lowercase characters only cased ones. Return False otherwise.

isupper() bool

Return True if all cased characters in B are uppercase and there is at least one cased character in B, False otherwise.

join(iterable_of_bytes, /)

Concatenate any number of bytes objects.

The bytes whose method is called is inserted in between each pair.

The result is returned as a new bytes object.

Example: b’.’.join([b’ab’, b’pq’, b’rs’]) -> b’ab.pq.rs’.

ljust(width, fillchar=b' ', /)

Return a left-justified string of length width.

Padding is done using the specified fill character.

lower() copy of B

Return a copy of B with all ASCII characters converted to lowercase.

lstrip(bytes=None, /)

Strip leading bytes contained in the argument.

If the argument is omitted or None, strip leading ASCII whitespace.

static maketrans(frm, to, /)

Return a translation table useable for the bytes or bytearray translate method.

The returned table will be one where each byte in frm is mapped to the byte at the same position in to.

The bytes objects frm and to must be of the same length.

partition(sep, /)

Partition the bytes into three parts using the given separator.

This will search for the separator sep in the bytes. If the separator is found, returns a 3-tuple containing the part before the separator, the separator itself, and the part after it.

If the separator is not found, returns a 3-tuple containing the original bytes object and two empty bytes objects.

removeprefix(prefix, /)

Return a bytes object with the given prefix string removed if present.

If the bytes starts with the prefix string, return bytes[len(prefix):]. Otherwise, return a copy of the original bytes.

removesuffix(suffix, /)

Return a bytes object with the given suffix string removed if present.

If the bytes ends with the suffix string and that suffix is not empty, return bytes[:-len(prefix)]. Otherwise, return a copy of the original bytes.

replace(old, new, count=-1, /)

Return a copy with all occurrences of substring old replaced by new.

count

Maximum number of occurrences to replace. -1 (the default value) means replace all occurrences.

If the optional argument count is given, only the first count occurrences are replaced.

rfind(sub[, start[, end]]) int

Return the highest index in B where subsection sub is found, such that sub is contained within B[start,end]. Optional arguments start and end are interpreted as in slice notation.

Return -1 on failure.

rindex(sub[, start[, end]]) int

Return the highest index in B where subsection sub is found, such that sub is contained within B[start,end]. Optional arguments start and end are interpreted as in slice notation.

Raise ValueError when the subsection is not found.

rjust(width, fillchar=b' ', /)

Return a right-justified string of length width.

Padding is done using the specified fill character.

rpartition(sep, /)

Partition the bytes into three parts using the given separator.

This will search for the separator sep in the bytes, starting at the end. If the separator is found, returns a 3-tuple containing the part before the separator, the separator itself, and the part after it.

If the separator is not found, returns a 3-tuple containing two empty bytes objects and the original bytes object.

rsplit(sep=None, maxsplit=-1)

Return a list of the sections in the bytes, using sep as the delimiter.

sep

The delimiter according which to split the bytes. None (the default value) means split on ASCII whitespace characters (space, tab, return, newline, formfeed, vertical tab).

maxsplit

Maximum number of splits to do. -1 (the default value) means no limit.

Splitting is done starting at the end of the bytes and working to the front.

rstrip(bytes=None, /)

Strip trailing bytes contained in the argument.

If the argument is omitted or None, strip trailing ASCII whitespace.

split(sep=None, maxsplit=-1)

Return a list of the sections in the bytes, using sep as the delimiter.

sep

The delimiter according which to split the bytes. None (the default value) means split on ASCII whitespace characters (space, tab, return, newline, formfeed, vertical tab).

maxsplit

Maximum number of splits to do. -1 (the default value) means no limit.

splitlines(keepends=False)

Return a list of the lines in the bytes, breaking at line boundaries.

Line breaks are not included in the resulting list unless keepends is given and true.

startswith(prefix[, start[, end]]) bool

Return True if B starts with the specified prefix, False otherwise. With optional start, test B beginning at that position. With optional end, stop comparing B at that position. prefix can also be a tuple of bytes to try.

strip()

Returns self.hex() with leading zeroes removed.

Examples

>>> hb = HexBytes32("0x0000000000000000000000000000000000000000000000000000000000001234")
>>> hb.strip()
'1234'
Return type:

str

swapcase() copy of B

Return a copy of B with uppercase ASCII characters converted to lowercase ASCII and vice versa.

title() copy of B

Return a titlecased version of B, i.e. ASCII words start with uppercase characters, all remaining cased characters have lowercase.

to_0x_hex()

Convert the bytes to a 0x-prefixed hex string

Return type:

str

translate(table, /, delete=b'')

Return a copy with each character mapped by the given translation table.

table

Translation table, which must be a bytes object of length 256.

All characters occurring in the optional argument delete are removed. The remaining characters are mapped through the given translation table.

upper() copy of B

Return a copy of B with all ASCII characters converted to uppercase.

zfill(width, /)

Pad a numeric string with zeros on the left, to fill a field of the given width.

The original string is never truncated.

property as_address: Address

Interprets the data as an Ethereum address.

Raises:

ValueError – If the data does not represent a valid Ethereum address.

Examples

>>> data = Data("0x000000000000000000000000000000000000000a")
>>> data.as_address
'0x000000000000000000000000000000000000000a'
property as_uint: uint

Interprets the data as an unsigned integer.

Examples

>>> data = Data("0x0a")
>>> data.as_uint
10
property as_uint104

Unsigned 104-bit integer.

Examples

>>> uint104(HexBytes('0xFFFFFFFFFFFFFFFFFFFFFFFFFF'))
uint104(20282409603651670423947251286015)
property as_uint112

Unsigned 112-bit integer.

Examples

>>> uint112(HexBytes('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFF'))
uint112(5192296858534827628530496329220095)
property as_uint120

Unsigned 120-bit integer.

Examples

>>> uint120(HexBytes('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF'))
uint120(1329227995784915872903807060280344575)
property as_uint128: uint128

Interprets the data as a 128-bit unsigned integer.

Examples

>>> data = Data("0x0000000000000000000000000000000a")
>>> data.as_uint128
10
property as_uint136

Unsigned 136-bit integer.

Examples

>>> uint136(HexBytes('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF'))
uint136(87112285931760246646623899502532662132735)
property as_uint144

Unsigned 144-bit integer.

Examples

>>> uint144(HexBytes('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF'))
uint144(22300745198530623141535718272648361505980415)
property as_uint152

Unsigned 152-bit integer.

Examples

>>> uint152(HexBytes('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF'))
uint152(5708990770823839524233143877797980545530986495)
property as_uint16

Unsigned 16-bit integer.

Examples

>>> uint16(HexBytes('0xFFFF'))
uint16(65535)
property as_uint160

Unsigned 160-bit integer.

Examples

>>> uint160(HexBytes('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF'))
uint160(1461501637330902918203684832716283019655932542975)
property as_uint168

Unsigned 168-bit integer.

Examples

>>> uint168(HexBytes('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF'))
uint168(374144419156711147060143317175368453031918731001855)
property as_uint176

Unsigned 176-bit integer.

Examples

>>> uint176(HexBytes('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF'))
uint176(95780971304118053647396689196894323976171195136475135)
property as_uint184

Unsigned 184-bit integer.

Examples

>>> uint184(HexBytes('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF'))
uint184(24519928653854221733733552434404946937899825954937634815)
property as_uint192

Unsigned 192-bit integer.

Examples

>>> uint192(HexBytes('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF'))
uint192(6277101735386680763835789423207666416102355444464034512895)
property as_uint200

Unsigned 200-bit integer.

Examples

>>> uint200(HexBytes('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF'))
uint200(1606938044258990275541962092341162602522202993782792835301375)
property as_uint208

Unsigned 208-bit integer.

Examples

>>> uint208(HexBytes('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF'))
uint208(411376139330301510538742295639337626245683966408394965837152255)
property as_uint216

Unsigned 216-bit integer.

Examples

>>> uint216(HexBytes('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF'))
uint216(105312291668557186697918027683670432318895095400549111254310977535)
property as_uint224

Unsigned 224-bit integer.

Examples

>>> uint224(HexBytes('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF'))
uint224(26959946667150639794667015087019630673637144422540572481103610249215)
property as_uint232

Unsigned 232-bit integer.

Examples

>>> uint232(HexBytes('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF'))
uint232(6901746346790563787434755862277025452451108972170386555162524223799295)
property as_uint24

Unsigned 24-bit integer.

Examples

>>> uint24(HexBytes('0xFFFFFF'))
uint24(16777215)
property as_uint240

Unsigned 240-bit integer.

Examples

>>> uint240(HexBytes('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF'))
uint240(1766847064778384329583297500742918515827483896875618958121606201292619775)
property as_uint256: uint256

Interprets the data as a 256-bit unsigned integer.

Examples

>>> data = Data("0x000000000000000000000000000000000000000000000000000000000000000a")
>>> data.as_uint256
10
property as_uint32

Unsigned 32-bit integer.

Examples

>>> uint32(HexBytes('0xFFFFFFFF'))
uint32(4294967295)
property as_uint40

Unsigned 40-bit integer.

Examples

>>> uint40(HexBytes('0xFFFFFFFFFF'))
uint40(1099511627775)
property as_uint48

Unsigned 48-bit integer.

Examples

>>> uint48(HexBytes('0xFFFFFFFFFFFF'))
uint48(281474976710655)
property as_uint56

Unsigned 56-bit integer.

Examples

>>> uint56(HexBytes('0xFFFFFFFFFFFFFF'))
uint56(72057594037927935)
property as_uint64: uint64

Interprets the data as a 64-bit unsigned integer.

Examples

>>> data = Data("0x000000000000000a")
>>> data.as_uint64
10
property as_uint72

Unsigned 72-bit integer.

Examples

>>> uint72(HexBytes('0xFFFFFFFFFFFFFFFFFF'))
uint72(4722366482869645213695)
property as_uint8: uint8

Interprets the data as an 8-bit unsigned integer.

Examples

>>> data = Data("0x01")
>>> data.as_uint8
1
property as_uint80

Unsigned 80-bit integer.

Examples

>>> uint80(HexBytes('0xFFFFFFFFFFFFFFFFFFFF'))
uint80(1208925819614629174706175)
property as_uint88

Unsigned 88-bit integer.

Examples

>>> uint88(HexBytes('0xFFFFFFFFFFFFFFFFFFFFFF'))
uint88(309485009821345068724781055)
property as_uint96

Unsigned 96-bit integer.

Examples

>>> uint96(HexBytes('0xFFFFFFFFFFFFFFFFFFFFFFFF'))
uint96(79228162514264337593543950335)

evmspec.structs.receipt module

class evmspec.structs.receipt.ArbitrumFeeStats[source]

Bases: DictStruct

Arbitrum includes these with a tx receipt.

See also

FeeStats

get(key, default=None)

Get the value associated with a key, or a default value if the key is not present.

Parameters:
  • key (str) – The key to look up.

  • default (optional) – The value to return if the key is not present.

Return type:

Any

Example

>>> class MyStruct(DictStruct):
...     field1: str
>>> s = MyStruct(field1="value")
>>> s.get('field1')
'value'
>>> s.get('field2', 'default')
'default'
items()

Returns an iterator over the struct’s field name and value pairs.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.items())
[('field1', 'value'), ('field2', 42)]
Return type:

Iterator[Tuple[str, Any]]

keys()

Returns an iterator over the field names of the struct.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.keys())
['field1', 'field2']
Return type:

Iterator[str]

values()

Returns an iterator over the struct’s field values.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.values())
['value', 42]
Return type:

Iterator[Any]

paid: FeeStats

The breakdown of gas paid for the transaction.

(price * unitsUsed)

prices: FeeStats

The breakdown of gas prices for the transaction.

unitsUsed: FeeStats

The breakdown of units of gas used for the transaction.

class evmspec.structs.receipt.FeeStats[source]

Bases: DictStruct

Arbitrum includes this in the feeStats field of a tx receipt.

See also

ArbitrumFeeStats

get(key, default=None)

Get the value associated with a key, or a default value if the key is not present.

Parameters:
  • key (str) – The key to look up.

  • default (optional) – The value to return if the key is not present.

Return type:

Any

Example

>>> class MyStruct(DictStruct):
...     field1: str
>>> s = MyStruct(field1="value")
>>> s.get('field1')
'value'
>>> s.get('field2', 'default')
'default'
items()

Returns an iterator over the struct’s field name and value pairs.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.items())
[('field1', 'value'), ('field2', 42)]
Return type:

Iterator[Tuple[str, Any]]

keys()

Returns an iterator over the field names of the struct.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.keys())
['field1', 'field2']
Return type:

Iterator[str]

values()

Returns an iterator over the struct’s field values.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.values())
['value', 42]
Return type:

Iterator[Any]

l1Calldata: Wei
l1Transaction: Wei
l2Computation: Wei
l2Storage: Wei
class evmspec.structs.receipt.FullTransactionReceipt[source]

Bases: TransactionReceipt

Extends TransactionReceipt to include full details.

get(key, default=None)

Get the value associated with a key, or a default value if the key is not present.

Parameters:
  • key (str) – The key to look up.

  • default (optional) – The value to return if the key is not present.

Return type:

Any

Example

>>> class MyStruct(DictStruct):
...     field1: str
>>> s = MyStruct(field1="value")
>>> s.get('field1')
'value'
>>> s.get('field2', 'default')
'default'
items()

Returns an iterator over the struct’s field name and value pairs.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.items())
[('field1', 'value'), ('field2', 42)]
Return type:

Iterator[Tuple[str, Any]]

keys()

Returns an iterator over the field names of the struct.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.keys())
['field1', 'field2']
Return type:

Iterator[str]

values()

Returns an iterator over the struct’s field values.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.values())
['value', 42]
Return type:

Iterator[Any]

blobGasUsed: Wei

This field is sometimes present, only on Mainnet.

Examples

>>> receipt.blobGasUsed
Wei(0)
blockHash: HexBytes

The hash of the block that contains the transaction.

Examples

>>> full_receipt.blockHash
HexBytes('0x...')
blockNumber: BlockNumber

The block number that contains the transaction.

Examples

>>> receipt.blockNumber
BlockNumber(1234567)
contractAddress: Address | None

The contract address created, if the transaction was a contract creation, otherwise None.

Examples

>>> receipt.contractAddress
Address('0x...')
cumulativeGasUsed: Wei

The total amount of gas used in the block up to and including this transaction.

Examples

>>> receipt.cumulativeGasUsed
Wei(100000)
effectiveGasPrice: Wei

The actual value per gas deducted from the sender’s account.

This field is only present on Mainnet.

Examples

>>> receipt.effectiveGasPrice
Wei(1000000000)
property feeStats: ArbitrumFeeStats

This field is only present on Arbitrum.

Examples

>>> receipt.feeStats
ArbitrumFeeStats(...)
gasUsed: Wei

The amount of gas used by this transaction, not counting internal transactions, calls or delegate calls.

Examples

>>> receipt.gasUsed
Wei(21000)
l1BlockNumber: BlockNumber

This field is only present on Arbitrum.

Examples

>>> receipt.l1BlockNumber
BlockNumber(1234567)
l1Fee: Wei

This field is only present on Optimism.

Examples

>>> receipt.l1Fee
Wei(50000000000)
l1FeeScalar: Decimal

This field is only present on Optimism.

Examples

>>> receipt.l1FeeScalar
Decimal('1.0')
l1GasPrice: Wei

This field is only present on Optimism.

Examples

>>> receipt.l1GasPrice
Wei(1000000000)
l1GasUsed: Wei

This field is only present on Optimism.

Examples

>>> receipt.l1GasUsed
Wei(50000)
l1InboxBatchInfo: HexBytes | None

This field is only present on Arbitrum.

Examples

>>> receipt.l1InboxBatchInfo
HexBytes('0x...')
property logs: Tuple[Log, ...]

The logs that were generated during this transaction.

Examples

>>> receipt.logs
(Log(...), Log(...))
logsBloom: HexBytes

The bloom filter for all logs in this block.

Examples

>>> full_receipt.logsBloom
HexBytes('0x...')
status: Status

The status of the transaction, represented by the Status enum: Status.success (1) if the transaction succeeded, Status.failure (0) if it failed.

Examples

>>> receipt.status
<Status.success: 1>
transactionHash: TransactionHash

The unique hash of this transaction.

Examples

>>> receipt.transactionHash
TransactionHash('0x...')
transactionIndex: TransactionIndex

The position of this transaction within the block.

Examples

>>> receipt.transactionIndex
TransactionIndex(0)
type: uint

The transaction type.

This field is only present on Mainnet.

Examples

>>> receipt.type
uint(2)
class evmspec.structs.receipt.Status[source]

Bases: Enum

Enum representing the status of a transaction, indicating success or failure.

failure

Represents a failed transaction with a value of 0.

Type:

int

success

Represents a successful transaction with a value of 1.

Type:

int

Examples

>>> Status.success
<Status.success: 1>
>>> Status.failure
<Status.failure: 0>
failure = 0
success = 1
class evmspec.structs.receipt.TransactionReceipt[source]

Bases: LazyDictStruct

Represents the receipt of a transaction within a block.

get(key, default=None)

Get the value associated with a key, or a default value if the key is not present.

Parameters:
  • key (str) – The key to look up.

  • default (optional) – The value to return if the key is not present.

Return type:

Any

Example

>>> class MyStruct(DictStruct):
...     field1: str
>>> s = MyStruct(field1="value")
>>> s.get('field1')
'value'
>>> s.get('field2', 'default')
'default'
items()

Returns an iterator over the struct’s field name and value pairs.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.items())
[('field1', 'value'), ('field2', 42)]
Return type:

Iterator[Tuple[str, Any]]

keys()

Returns an iterator over the field names of the struct.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.keys())
['field1', 'field2']
Return type:

Iterator[str]

values()

Returns an iterator over the struct’s field values.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.values())
['value', 42]
Return type:

Iterator[Any]

blobGasUsed: Wei

This field is sometimes present, only on Mainnet.

Examples

>>> receipt.blobGasUsed
Wei(0)
blockNumber: BlockNumber

The block number that contains the transaction.

Examples

>>> receipt.blockNumber
BlockNumber(1234567)
contractAddress: Address | None

The contract address created, if the transaction was a contract creation, otherwise None.

Examples

>>> receipt.contractAddress
Address('0x...')
cumulativeGasUsed: Wei

The total amount of gas used in the block up to and including this transaction.

Examples

>>> receipt.cumulativeGasUsed
Wei(100000)
effectiveGasPrice: Wei

The actual value per gas deducted from the sender’s account.

This field is only present on Mainnet.

Examples

>>> receipt.effectiveGasPrice
Wei(1000000000)
property feeStats: ArbitrumFeeStats

This field is only present on Arbitrum.

Examples

>>> receipt.feeStats
ArbitrumFeeStats(...)
gasUsed: Wei

The amount of gas used by this transaction, not counting internal transactions, calls or delegate calls.

Examples

>>> receipt.gasUsed
Wei(21000)
l1BlockNumber: BlockNumber

This field is only present on Arbitrum.

Examples

>>> receipt.l1BlockNumber
BlockNumber(1234567)
l1Fee: Wei

This field is only present on Optimism.

Examples

>>> receipt.l1Fee
Wei(50000000000)
l1FeeScalar: Decimal

This field is only present on Optimism.

Examples

>>> receipt.l1FeeScalar
Decimal('1.0')
l1GasPrice: Wei

This field is only present on Optimism.

Examples

>>> receipt.l1GasPrice
Wei(1000000000)
l1GasUsed: Wei

This field is only present on Optimism.

Examples

>>> receipt.l1GasUsed
Wei(50000)
l1InboxBatchInfo: HexBytes | None

This field is only present on Arbitrum.

Examples

>>> receipt.l1InboxBatchInfo
HexBytes('0x...')
property logs: Tuple[Log, ...]

The logs that were generated during this transaction.

Examples

>>> receipt.logs
(Log(...), Log(...))
status: Status

The status of the transaction, represented by the Status enum: Status.success (1) if the transaction succeeded, Status.failure (0) if it failed.

Examples

>>> receipt.status
<Status.success: 1>
transactionHash: TransactionHash

The unique hash of this transaction.

Examples

>>> receipt.transactionHash
TransactionHash('0x...')
transactionIndex: TransactionIndex

The position of this transaction within the block.

Examples

>>> receipt.transactionIndex
TransactionIndex(0)
type: uint

The transaction type.

This field is only present on Mainnet.

Examples

>>> receipt.type
uint(2)

evmspec.structs.transaction module

class evmspec.structs.transaction.AccessListEntry[source]

Bases: LazyDictStruct

Represents an entry in an Ethereum transaction access list.

Access lists are used in EIP-2930 and EIP-1559 transactions to specify storage slots that the transaction plans to access, potentially reducing gas costs.

Example

>>> entry = AccessListEntry(address='0x742d35Cc6634C0532925a3b844Bc454e4438f44e', storageKeys=[...])
>>> entry.address
'0x742d35Cc6634C0532925a3b844Bc454e4438f44e'
>>> len(entry.storageKeys)
2
get(key, default=None)

Get the value associated with a key, or a default value if the key is not present.

Parameters:
  • key (str) – The key to look up.

  • default (optional) – The value to return if the key is not present.

Return type:

Any

Example

>>> class MyStruct(DictStruct):
...     field1: str
>>> s = MyStruct(field1="value")
>>> s.get('field1')
'value'
>>> s.get('field2', 'default')
'default'
items()

Returns an iterator over the struct’s field name and value pairs.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.items())
[('field1', 'value'), ('field2', 42)]
Return type:

Iterator[Tuple[str, Any]]

keys()

Returns an iterator over the field names of the struct.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.keys())
['field1', 'field2']
Return type:

Iterator[str]

values()

Returns an iterator over the struct’s field values.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.values())
['value', 42]
Return type:

Iterator[Any]

address: Address

The Ethereum address of the contract whose storage is being accessed.

property storageKeys: List[HexBytes32]

Decodes storage keys from raw format to a list of HexBytes32.

The _storageKeys attribute contains the raw encoded data, which is decoded into a list of HexBytes32 objects when accessed through this property.

Example

>>> entry = AccessListEntry(address='0x742d35Cc6634C0532925a3b844Bc454e4438f44e', storageKeys=[...])
>>> decoded_keys = entry.storageKeys
>>> isinstance(decoded_keys, list)
True
>>> isinstance(decoded_keys[0], HexBytes32)
True

See also

  • _TransactionBase.accessList()

class evmspec.structs.transaction.Transaction1559[source]

Bases: _TransactionBase

Represents a type-1559 (EIP-1559) Ethereum transaction with dynamic fee.

get(key, default=None)

Get the value associated with a key, or a default value if the key is not present.

Parameters:
  • key (str) – The key to look up.

  • default (optional) – The value to return if the key is not present.

Return type:

Any

Example

>>> class MyStruct(DictStruct):
...     field1: str
>>> s = MyStruct(field1="value")
>>> s.get('field1')
'value'
>>> s.get('field2', 'default')
'default'
items()

Returns an iterator over the struct’s field name and value pairs.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.items())
[('field1', 'value'), ('field2', 42)]
Return type:

Iterator[Tuple[str, Any]]

keys()

Returns an iterator over the field names of the struct.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.keys())
['field1', 'field2']
Return type:

Iterator[str]

values()

Returns an iterator over the struct’s field values.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.values())
['value', 42]
Return type:

Iterator[Any]

property accessList: List[AccessListEntry]

Decodes the access list from raw format to a list of AccessListEntry.

Example

>>> transaction = _TransactionBase(...)
>>> access_list = transaction.accessList
>>> isinstance(access_list, list)
True
>>> isinstance(access_list[0], AccessListEntry)
True

See also

property block: BlockNumber

A shorthand getter for blockNumber.

Example

>>> transaction = _TransactionBase(...)
>>> transaction.block == transaction.blockNumber
True
blockHash: BlockHash

The hash of the block including this transaction.

blockNumber: BlockNumber

The number of the block including this transaction.

chainId: ChainId | None

The chain id of the transaction, if any.

None for v in {27, 28}, otherwise derived from eip-155.

This field is not included in the transactions field of a eth_getBlock response.

gas: Wei

The gas provided by the sender.

gasPrice: Wei

The gas price provided by the sender in wei.

hash: TransactionHash

The hash of the transaction.

input: HexBytes

The data sent along with the transaction.

maxFeePerGas: Wei

The maximum fee per gas set in the transaction.

maxPriorityFeePerGas: Wei

The maximum priority gas fee set in the transaction.

nonce: Nonce

The number of transactions made by the sender before this one.

r: HexBytes

The R field of the signature.

s: HexBytes

The S field of the signature.

sender: Address

The address of the sender.

Note

This attribute is mapped to the field() name ‘from’ during serialization and deserialization.

to: Address | None

The address of the receiver. None when it’s a contract creation transaction.

transactionIndex: TransactionIndex

The index position of the transaction in the block.

type: ClassVar[HexBytes] = HexBytes('0x02')
v: uint

ECDSA recovery ID.

value: Wei

The value transferred in wei encoded as hexadecimal.

class evmspec.structs.transaction.Transaction2930[source]

Bases: _TransactionBase

Represents a type-2930 (EIP-2930) Ethereum transaction with an access list.

get(key, default=None)

Get the value associated with a key, or a default value if the key is not present.

Parameters:
  • key (str) – The key to look up.

  • default (optional) – The value to return if the key is not present.

Return type:

Any

Example

>>> class MyStruct(DictStruct):
...     field1: str
>>> s = MyStruct(field1="value")
>>> s.get('field1')
'value'
>>> s.get('field2', 'default')
'default'
items()

Returns an iterator over the struct’s field name and value pairs.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.items())
[('field1', 'value'), ('field2', 42)]
Return type:

Iterator[Tuple[str, Any]]

keys()

Returns an iterator over the field names of the struct.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.keys())
['field1', 'field2']
Return type:

Iterator[str]

values()

Returns an iterator over the struct’s field values.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.values())
['value', 42]
Return type:

Iterator[Any]

property accessList: List[AccessListEntry]

Decodes the access list from raw format to a list of AccessListEntry.

Example

>>> transaction = _TransactionBase(...)
>>> access_list = transaction.accessList
>>> isinstance(access_list, list)
True
>>> isinstance(access_list[0], AccessListEntry)
True

See also

property block: BlockNumber

A shorthand getter for blockNumber.

Example

>>> transaction = _TransactionBase(...)
>>> transaction.block == transaction.blockNumber
True
blockHash: BlockHash

The hash of the block including this transaction.

blockNumber: BlockNumber

The number of the block including this transaction.

chainId: ChainId | None

The chain id of the transaction, if any.

None for v in {27, 28}, otherwise derived from eip-155.

This field is not included in the transactions field of a eth_getBlock response.

gas: Wei

The gas provided by the sender.

gasPrice: Wei

The gas price provided by the sender in wei.

hash: TransactionHash

The hash of the transaction.

input: HexBytes

The data sent along with the transaction.

nonce: Nonce

The number of transactions made by the sender before this one.

r: HexBytes

The R field of the signature.

s: HexBytes

The S field of the signature.

sender: Address

The address of the sender.

Note

This attribute is mapped to the field() name ‘from’ during serialization and deserialization.

to: Address | None

The address of the receiver. None when it’s a contract creation transaction.

transactionIndex: TransactionIndex

The index position of the transaction in the block.

type: ClassVar[HexBytes] = HexBytes('0x01')
v: uint

ECDSA recovery ID.

value: Wei

The value transferred in wei encoded as hexadecimal.

class evmspec.structs.transaction.Transaction4844[source]

Bases: Transaction1559

Represents a type-1559 (EIP-1559) Ethereum transaction with dynamic fee.

get(key, default=None)

Get the value associated with a key, or a default value if the key is not present.

Parameters:
  • key (str) – The key to look up.

  • default (optional) – The value to return if the key is not present.

Return type:

Any

Example

>>> class MyStruct(DictStruct):
...     field1: str
>>> s = MyStruct(field1="value")
>>> s.get('field1')
'value'
>>> s.get('field2', 'default')
'default'
items()

Returns an iterator over the struct’s field name and value pairs.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.items())
[('field1', 'value'), ('field2', 42)]
Return type:

Iterator[Tuple[str, Any]]

keys()

Returns an iterator over the field names of the struct.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.keys())
['field1', 'field2']
Return type:

Iterator[str]

values()

Returns an iterator over the struct’s field values.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.values())
['value', 42]
Return type:

Iterator[Any]

property accessList: List[AccessListEntry]

Decodes the access list from raw format to a list of AccessListEntry.

Example

>>> transaction = _TransactionBase(...)
>>> access_list = transaction.accessList
>>> isinstance(access_list, list)
True
>>> isinstance(access_list[0], AccessListEntry)
True

See also

blobVersionedHashes: Tuple[HexBytes32, ...]
property block: BlockNumber

A shorthand getter for blockNumber.

Example

>>> transaction = _TransactionBase(...)
>>> transaction.block == transaction.blockNumber
True
blockHash: BlockHash

The hash of the block including this transaction.

blockNumber: BlockNumber

The number of the block including this transaction.

chainId: ChainId | None

The chain id of the transaction, if any.

None for v in {27, 28}, otherwise derived from eip-155.

This field is not included in the transactions field of a eth_getBlock response.

gas: Wei

The gas provided by the sender.

gasPrice: Wei

The gas price provided by the sender in wei.

hash: TransactionHash

The hash of the transaction.

input: HexBytes

The data sent along with the transaction.

maxFeePerBlobGas: Wei
maxFeePerGas: Wei

The maximum fee per gas set in the transaction.

maxPriorityFeePerGas: Wei

The maximum priority gas fee set in the transaction.

nonce: Nonce

The number of transactions made by the sender before this one.

r: HexBytes

The R field of the signature.

s: HexBytes

The S field of the signature.

sender: Address

The address of the sender.

Note

This attribute is mapped to the field() name ‘from’ during serialization and deserialization.

to: Address | None

The address of the receiver. None when it’s a contract creation transaction.

transactionIndex: TransactionIndex

The index position of the transaction in the block.

type: ClassVar[HexBytes] = HexBytes('0x03')
v: uint

ECDSA recovery ID.

value: Wei

The value transferred in wei encoded as hexadecimal.

class evmspec.structs.transaction.TransactionLegacy[source]

Bases: _TransactionBase

Represents a Legacy Ethereum transaction (pre-EIP-2718).

get(key, default=None)

Get the value associated with a key, or a default value if the key is not present.

Parameters:
  • key (str) – The key to look up.

  • default (optional) – The value to return if the key is not present.

Return type:

Any

Example

>>> class MyStruct(DictStruct):
...     field1: str
>>> s = MyStruct(field1="value")
>>> s.get('field1')
'value'
>>> s.get('field2', 'default')
'default'
items()

Returns an iterator over the struct’s field name and value pairs.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.items())
[('field1', 'value'), ('field2', 42)]
Return type:

Iterator[Tuple[str, Any]]

keys()

Returns an iterator over the field names of the struct.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.keys())
['field1', 'field2']
Return type:

Iterator[str]

values()

Returns an iterator over the struct’s field values.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.values())
['value', 42]
Return type:

Iterator[Any]

property accessList: List[AccessListEntry]

Decodes the access list from raw format to a list of AccessListEntry.

Example

>>> transaction = _TransactionBase(...)
>>> access_list = transaction.accessList
>>> isinstance(access_list, list)
True
>>> isinstance(access_list[0], AccessListEntry)
True

See also

property block: BlockNumber

A shorthand getter for blockNumber.

Example

>>> transaction = _TransactionBase(...)
>>> transaction.block == transaction.blockNumber
True
blockHash: BlockHash

The hash of the block including this transaction.

blockNumber: BlockNumber

The number of the block including this transaction.

chainId: ChainId | None

The chain id of the transaction, if any.

None for v in {27, 28}, otherwise derived from eip-155.

This field is not included in the transactions field of a eth_getBlock response.

gas: Wei

The gas provided by the sender.

gasPrice: Wei

The gas price provided by the sender in wei.

hash: TransactionHash

The hash of the transaction.

input: HexBytes

The data sent along with the transaction.

nonce: Nonce

The number of transactions made by the sender before this one.

r: HexBytes

The R field of the signature.

s: HexBytes

The S field of the signature.

sender: Address

The address of the sender.

Note

This attribute is mapped to the field() name ‘from’ during serialization and deserialization.

to: Address | None

The address of the receiver. None when it’s a contract creation transaction.

transactionIndex: TransactionIndex

The index position of the transaction in the block.

type: ClassVar[HexBytes] = HexBytes('0x00')
v: uint

ECDSA recovery ID.

value: Wei

The value transferred in wei encoded as hexadecimal.

class evmspec.structs.transaction.TransactionRLP[source]

Bases: _TransactionBase

Represents a RLP encoded transaction that might have network-specific fields.

get(key, default=None)

Get the value associated with a key, or a default value if the key is not present.

Parameters:
  • key (str) – The key to look up.

  • default (optional) – The value to return if the key is not present.

Return type:

Any

Example

>>> class MyStruct(DictStruct):
...     field1: str
>>> s = MyStruct(field1="value")
>>> s.get('field1')
'value'
>>> s.get('field2', 'default')
'default'
items()

Returns an iterator over the struct’s field name and value pairs.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.items())
[('field1', 'value'), ('field2', 42)]
Return type:

Iterator[Tuple[str, Any]]

keys()

Returns an iterator over the field names of the struct.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.keys())
['field1', 'field2']
Return type:

Iterator[str]

values()

Returns an iterator over the struct’s field values.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.values())
['value', 42]
Return type:

Iterator[Any]

property accessList: List[AccessListEntry]

Decodes the access list from raw format to a list of AccessListEntry.

Example

>>> transaction = _TransactionBase(...)
>>> access_list = transaction.accessList
>>> isinstance(access_list, list)
True
>>> isinstance(access_list[0], AccessListEntry)
True

See also

arbSubType: uint
arbType: uint
property block: BlockNumber

A shorthand getter for blockNumber.

Example

>>> transaction = _TransactionBase(...)
>>> transaction.block == transaction.blockNumber
True
blockHash: BlockHash

The hash of the block including this transaction.

blockNumber: BlockNumber

The number of the block including this transaction.

chainId: ChainId | None

The chain id of the transaction, if any.

None for v in {27, 28}, otherwise derived from eip-155.

This field is not included in the transactions field of a eth_getBlock response.

gas: Wei

The gas provided by the sender.

gasPrice: Wei

The gas price provided by the sender in wei.

hash: TransactionHash

The hash of the transaction.

indexInParent: uint
input: HexBytes

The data sent along with the transaction.

l1BlockNumber: BlockNumber
l1TxOrigin: Address
nonce: Nonce

The number of transactions made by the sender before this one.

r: HexBytes

The R field of the signature.

s: HexBytes

The S field of the signature.

sender: Address

The address of the sender.

Note

This attribute is mapped to the field() name ‘from’ during serialization and deserialization.

to: Address | None

The address of the receiver. None when it’s a contract creation transaction.

transactionIndex: TransactionIndex

The index position of the transaction in the block.

v: uint

ECDSA recovery ID.

value: Wei

The value transferred in wei encoded as hexadecimal.

Module contents

class evmspec.structs.ErigonBlockHeader[source]

Bases: LazyDictStruct

Represents a block header in the Erigon client.

This class inherits from LazyDictStruct, which provides features for handling block header data, ensuring immutability and strictness to known fields. It is currently under development, and specific features may not yet be functional. There may be known issues needing resolution.

See also

  • LazyDictStruct for more details on the underlying structure and its features.

get(key, default=None)

Get the value associated with a key, or a default value if the key is not present.

Parameters:
  • key (str) – The key to look up.

  • default (optional) – The value to return if the key is not present.

Return type:

Any

Example

>>> class MyStruct(DictStruct):
...     field1: str
>>> s = MyStruct(field1="value")
>>> s.get('field1')
'value'
>>> s.get('field2', 'default')
'default'
items()

Returns an iterator over the struct’s field name and value pairs.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.items())
[('field1', 'value'), ('field2', 42)]
Return type:

Iterator[Tuple[str, Any]]

keys()

Returns an iterator over the field names of the struct.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.keys())
['field1', 'field2']
Return type:

Iterator[str]

values()

Returns an iterator over the struct’s field values.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.values())
['value', 42]
Return type:

Iterator[Any]

coinbase: Address

The address of the miner who mined the block.

Examples

>>> header = ErigonBlockHeader(
...     timestamp=UnixTimestamp(1638316800),
...     parentHash=HexBytes("0xabc"),
...     uncleHash=HexBytes("0xdef"),
...     coinbase=Address("0x123"),
...     root=HexBytes("0x456"),
...     difficulty=uint(1000)
... )
>>> header.coinbase
Address('0x123')
difficulty: uint

The difficulty level of the block.

Examples

>>> header = ErigonBlockHeader(
...     timestamp=UnixTimestamp(1638316800),
...     parentHash=HexBytes("0xabc"),
...     uncleHash=HexBytes("0xdef"),
...     coinbase=Address("0x123"),
...     root=HexBytes("0x456"),
...     difficulty=uint(1000)
... )
>>> header.difficulty
uint(1000)
parentHash: HexBytes

The hash of the parent block.

Examples

>>> header = ErigonBlockHeader(
...     timestamp=UnixTimestamp(1638316800),
...     parentHash=HexBytes("0xabc"),
...     uncleHash=HexBytes("0xdef"),
...     coinbase=Address("0x123"),
...     root=HexBytes("0x456"),
...     difficulty=uint(1000)
... )
>>> header.parentHash
HexBytes('0xabc')
root: HexBytes

The root hash of the state trie.

Examples

>>> header = ErigonBlockHeader(
...     timestamp=UnixTimestamp(1638316800),
...     parentHash=HexBytes("0xabc"),
...     uncleHash=HexBytes("0xdef"),
...     coinbase=Address("0x123"),
...     root=HexBytes("0x456"),
...     difficulty=uint(1000)
... )
>>> header.root
HexBytes('0x456')
timestamp: UnixTimestamp

The Unix timestamp for when the block was collated.

Examples

>>> header = ErigonBlockHeader(
...     timestamp=UnixTimestamp(1638316800),
...     parentHash=HexBytes("0xabc"),
...     uncleHash=HexBytes("0xdef"),
...     coinbase=Address("0x123"),
...     root=HexBytes("0x456"),
...     difficulty=uint(1000)
... )
>>> header.timestamp
UnixTimestamp(1638316800)
uncleHash: HexBytes

The hash of the list of uncle headers.

Examples

>>> header = ErigonBlockHeader(
...     timestamp=UnixTimestamp(1638316800),
...     parentHash=HexBytes("0xabc"),
...     uncleHash=HexBytes("0xdef"),
...     coinbase=Address("0x123"),
...     root=HexBytes("0x456"),
...     difficulty=uint(1000)
... )
>>> header.uncleHash
HexBytes('0xdef')
class evmspec.structs.FullTransactionReceipt[source]

Bases: TransactionReceipt

Extends TransactionReceipt to include full details.

get(key, default=None)

Get the value associated with a key, or a default value if the key is not present.

Parameters:
  • key (str) – The key to look up.

  • default (optional) – The value to return if the key is not present.

Return type:

Any

Example

>>> class MyStruct(DictStruct):
...     field1: str
>>> s = MyStruct(field1="value")
>>> s.get('field1')
'value'
>>> s.get('field2', 'default')
'default'
items()

Returns an iterator over the struct’s field name and value pairs.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.items())
[('field1', 'value'), ('field2', 42)]
Return type:

Iterator[Tuple[str, Any]]

keys()

Returns an iterator over the field names of the struct.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.keys())
['field1', 'field2']
Return type:

Iterator[str]

values()

Returns an iterator over the struct’s field values.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.values())
['value', 42]
Return type:

Iterator[Any]

blobGasUsed: Wei

This field is sometimes present, only on Mainnet.

Examples

>>> receipt.blobGasUsed
Wei(0)
blockHash: HexBytes

The hash of the block that contains the transaction.

Examples

>>> full_receipt.blockHash
HexBytes('0x...')
blockNumber: BlockNumber

The block number that contains the transaction.

Examples

>>> receipt.blockNumber
BlockNumber(1234567)
contractAddress: Address | None

The contract address created, if the transaction was a contract creation, otherwise None.

Examples

>>> receipt.contractAddress
Address('0x...')
cumulativeGasUsed: Wei

The total amount of gas used in the block up to and including this transaction.

Examples

>>> receipt.cumulativeGasUsed
Wei(100000)
effectiveGasPrice: Wei

The actual value per gas deducted from the sender’s account.

This field is only present on Mainnet.

Examples

>>> receipt.effectiveGasPrice
Wei(1000000000)
property feeStats: ArbitrumFeeStats

This field is only present on Arbitrum.

Examples

>>> receipt.feeStats
ArbitrumFeeStats(...)
gasUsed: Wei

The amount of gas used by this transaction, not counting internal transactions, calls or delegate calls.

Examples

>>> receipt.gasUsed
Wei(21000)
l1BlockNumber: BlockNumber

This field is only present on Arbitrum.

Examples

>>> receipt.l1BlockNumber
BlockNumber(1234567)
l1Fee: Wei

This field is only present on Optimism.

Examples

>>> receipt.l1Fee
Wei(50000000000)
l1FeeScalar: Decimal

This field is only present on Optimism.

Examples

>>> receipt.l1FeeScalar
Decimal('1.0')
l1GasPrice: Wei

This field is only present on Optimism.

Examples

>>> receipt.l1GasPrice
Wei(1000000000)
l1GasUsed: Wei

This field is only present on Optimism.

Examples

>>> receipt.l1GasUsed
Wei(50000)
l1InboxBatchInfo: HexBytes | None

This field is only present on Arbitrum.

Examples

>>> receipt.l1InboxBatchInfo
HexBytes('0x...')
property logs: Tuple[Log, ...]

The logs that were generated during this transaction.

Examples

>>> receipt.logs
(Log(...), Log(...))
logsBloom: HexBytes

The bloom filter for all logs in this block.

Examples

>>> full_receipt.logsBloom
HexBytes('0x...')
status: Status

The status of the transaction, represented by the Status enum: Status.success (1) if the transaction succeeded, Status.failure (0) if it failed.

Examples

>>> receipt.status
<Status.success: 1>
transactionHash: TransactionHash

The unique hash of this transaction.

Examples

>>> receipt.transactionHash
TransactionHash('0x...')
transactionIndex: TransactionIndex

The position of this transaction within the block.

Examples

>>> receipt.transactionIndex
TransactionIndex(0)
type: uint

The transaction type.

This field is only present on Mainnet.

Examples

>>> receipt.type
uint(2)
class evmspec.structs.Log[source]

Bases: SmallLog

Represents a comprehensive log structure with additional transaction details.

See also

SmallLog for the log structure with address and data.

get(key, default=None)

Get the value associated with a key, or a default value if the key is not present.

Parameters:
  • key (str) – The key to look up.

  • default (optional) – The value to return if the key is not present.

Return type:

Any

Example

>>> class MyStruct(DictStruct):
...     field1: str
>>> s = MyStruct(field1="value")
>>> s.get('field1')
'value'
>>> s.get('field2', 'default')
'default'
items()

Returns an iterator over the struct’s field name and value pairs.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.items())
[('field1', 'value'), ('field2', 42)]
Return type:

Iterator[Tuple[str, Any]]

keys()

Returns an iterator over the field names of the struct.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.keys())
['field1', 'field2']
Return type:

Iterator[str]

values()

Returns an iterator over the struct’s field values.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.values())
['value', 42]
Return type:

Iterator[Any]

address: Address | None

The address of the contract that generated the log.

property block: BlockNumber | None

A shorthand getter for ‘blockNumber’.

blockNumber: BlockNumber | None

The block where the transaction was included where the log originated from. None for pending transactions.

data: Data | None

Array of 32-bytes non-indexed return data of the log.

logIndex: LogIndex

Index position of the log in the transaction. None for pending transactions.

removed: bool | None

True when the log was removed, due to a chain reorganization. False if it’s a valid log.

property topic0: Topic

Returns the first topic.

property topic1: Topic

Returns the second topic if it exists, otherwise raises an AttributeError.

property topic2: Topic

Returns the third topic if it exists, otherwise raises an AttributeError.

property topic3: Topic

Returns the fourth topic if it exists, otherwise raises an AttributeError.

topics: Tuple[Topic, ...]

An array of 0 to 4 32-byte topics. The first topic is the event signature and the others are indexed filters on the event return data.

transactionHash: TransactionHash

The hash of the transaction that generated the log.

transactionIndex: TransactionIndex

The index of the transaction in the block, where the log originated from.

class evmspec.structs.Transaction1559[source]

Bases: _TransactionBase

Represents a type-1559 (EIP-1559) Ethereum transaction with dynamic fee.

get(key, default=None)

Get the value associated with a key, or a default value if the key is not present.

Parameters:
  • key (str) – The key to look up.

  • default (optional) – The value to return if the key is not present.

Return type:

Any

Example

>>> class MyStruct(DictStruct):
...     field1: str
>>> s = MyStruct(field1="value")
>>> s.get('field1')
'value'
>>> s.get('field2', 'default')
'default'
items()

Returns an iterator over the struct’s field name and value pairs.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.items())
[('field1', 'value'), ('field2', 42)]
Return type:

Iterator[Tuple[str, Any]]

keys()

Returns an iterator over the field names of the struct.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.keys())
['field1', 'field2']
Return type:

Iterator[str]

values()

Returns an iterator over the struct’s field values.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.values())
['value', 42]
Return type:

Iterator[Any]

property accessList: List[AccessListEntry]

Decodes the access list from raw format to a list of AccessListEntry.

Example

>>> transaction = _TransactionBase(...)
>>> access_list = transaction.accessList
>>> isinstance(access_list, list)
True
>>> isinstance(access_list[0], AccessListEntry)
True

See also

  • AccessListEntry

property block: BlockNumber

A shorthand getter for blockNumber.

Example

>>> transaction = _TransactionBase(...)
>>> transaction.block == transaction.blockNumber
True
blockHash: BlockHash

The hash of the block including this transaction.

blockNumber: BlockNumber

The number of the block including this transaction.

chainId: ChainId | None

The chain id of the transaction, if any.

None for v in {27, 28}, otherwise derived from eip-155.

This field is not included in the transactions field of a eth_getBlock response.

gas: Wei

The gas provided by the sender.

gasPrice: Wei

The gas price provided by the sender in wei.

hash: TransactionHash

The hash of the transaction.

input: HexBytes

The data sent along with the transaction.

maxFeePerGas: Wei

The maximum fee per gas set in the transaction.

maxPriorityFeePerGas: Wei

The maximum priority gas fee set in the transaction.

nonce: Nonce

The number of transactions made by the sender before this one.

r: HexBytes

The R field of the signature.

s: HexBytes

The S field of the signature.

sender: Address

The address of the sender.

Note

This attribute is mapped to the field() name ‘from’ during serialization and deserialization.

to: Address | None

The address of the receiver. None when it’s a contract creation transaction.

transactionIndex: TransactionIndex

The index position of the transaction in the block.

type: ClassVar[HexBytes] = HexBytes('0x02')
v: uint

ECDSA recovery ID.

value: Wei

The value transferred in wei encoded as hexadecimal.

class evmspec.structs.Transaction2930[source]

Bases: _TransactionBase

Represents a type-2930 (EIP-2930) Ethereum transaction with an access list.

get(key, default=None)

Get the value associated with a key, or a default value if the key is not present.

Parameters:
  • key (str) – The key to look up.

  • default (optional) – The value to return if the key is not present.

Return type:

Any

Example

>>> class MyStruct(DictStruct):
...     field1: str
>>> s = MyStruct(field1="value")
>>> s.get('field1')
'value'
>>> s.get('field2', 'default')
'default'
items()

Returns an iterator over the struct’s field name and value pairs.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.items())
[('field1', 'value'), ('field2', 42)]
Return type:

Iterator[Tuple[str, Any]]

keys()

Returns an iterator over the field names of the struct.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.keys())
['field1', 'field2']
Return type:

Iterator[str]

values()

Returns an iterator over the struct’s field values.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.values())
['value', 42]
Return type:

Iterator[Any]

property accessList: List[AccessListEntry]

Decodes the access list from raw format to a list of AccessListEntry.

Example

>>> transaction = _TransactionBase(...)
>>> access_list = transaction.accessList
>>> isinstance(access_list, list)
True
>>> isinstance(access_list[0], AccessListEntry)
True

See also

  • AccessListEntry

property block: BlockNumber

A shorthand getter for blockNumber.

Example

>>> transaction = _TransactionBase(...)
>>> transaction.block == transaction.blockNumber
True
blockHash: BlockHash

The hash of the block including this transaction.

blockNumber: BlockNumber

The number of the block including this transaction.

chainId: ChainId | None

The chain id of the transaction, if any.

None for v in {27, 28}, otherwise derived from eip-155.

This field is not included in the transactions field of a eth_getBlock response.

gas: Wei

The gas provided by the sender.

gasPrice: Wei

The gas price provided by the sender in wei.

hash: TransactionHash

The hash of the transaction.

input: HexBytes

The data sent along with the transaction.

nonce: Nonce

The number of transactions made by the sender before this one.

r: HexBytes

The R field of the signature.

s: HexBytes

The S field of the signature.

sender: Address

The address of the sender.

Note

This attribute is mapped to the field() name ‘from’ during serialization and deserialization.

to: Address | None

The address of the receiver. None when it’s a contract creation transaction.

transactionIndex: TransactionIndex

The index position of the transaction in the block.

type: ClassVar[HexBytes] = HexBytes('0x01')
v: uint

ECDSA recovery ID.

value: Wei

The value transferred in wei encoded as hexadecimal.

class evmspec.structs.TransactionLegacy[source]

Bases: _TransactionBase

Represents a Legacy Ethereum transaction (pre-EIP-2718).

get(key, default=None)

Get the value associated with a key, or a default value if the key is not present.

Parameters:
  • key (str) – The key to look up.

  • default (optional) – The value to return if the key is not present.

Return type:

Any

Example

>>> class MyStruct(DictStruct):
...     field1: str
>>> s = MyStruct(field1="value")
>>> s.get('field1')
'value'
>>> s.get('field2', 'default')
'default'
items()

Returns an iterator over the struct’s field name and value pairs.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.items())
[('field1', 'value'), ('field2', 42)]
Return type:

Iterator[Tuple[str, Any]]

keys()

Returns an iterator over the field names of the struct.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.keys())
['field1', 'field2']
Return type:

Iterator[str]

values()

Returns an iterator over the struct’s field values.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.values())
['value', 42]
Return type:

Iterator[Any]

property accessList: List[AccessListEntry]

Decodes the access list from raw format to a list of AccessListEntry.

Example

>>> transaction = _TransactionBase(...)
>>> access_list = transaction.accessList
>>> isinstance(access_list, list)
True
>>> isinstance(access_list[0], AccessListEntry)
True

See also

  • AccessListEntry

property block: BlockNumber

A shorthand getter for blockNumber.

Example

>>> transaction = _TransactionBase(...)
>>> transaction.block == transaction.blockNumber
True
blockHash: BlockHash

The hash of the block including this transaction.

blockNumber: BlockNumber

The number of the block including this transaction.

chainId: ChainId | None

The chain id of the transaction, if any.

None for v in {27, 28}, otherwise derived from eip-155.

This field is not included in the transactions field of a eth_getBlock response.

gas: Wei

The gas provided by the sender.

gasPrice: Wei

The gas price provided by the sender in wei.

hash: TransactionHash

The hash of the transaction.

input: HexBytes

The data sent along with the transaction.

nonce: Nonce

The number of transactions made by the sender before this one.

r: HexBytes

The R field of the signature.

s: HexBytes

The S field of the signature.

sender: Address

The address of the sender.

Note

This attribute is mapped to the field() name ‘from’ during serialization and deserialization.

to: Address | None

The address of the receiver. None when it’s a contract creation transaction.

transactionIndex: TransactionIndex

The index position of the transaction in the block.

type: ClassVar[HexBytes] = HexBytes('0x00')
v: uint

ECDSA recovery ID.

value: Wei

The value transferred in wei encoded as hexadecimal.

class evmspec.structs.TransactionRLP[source]

Bases: _TransactionBase

Represents a RLP encoded transaction that might have network-specific fields.

get(key, default=None)

Get the value associated with a key, or a default value if the key is not present.

Parameters:
  • key (str) – The key to look up.

  • default (optional) – The value to return if the key is not present.

Return type:

Any

Example

>>> class MyStruct(DictStruct):
...     field1: str
>>> s = MyStruct(field1="value")
>>> s.get('field1')
'value'
>>> s.get('field2', 'default')
'default'
items()

Returns an iterator over the struct’s field name and value pairs.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.items())
[('field1', 'value'), ('field2', 42)]
Return type:

Iterator[Tuple[str, Any]]

keys()

Returns an iterator over the field names of the struct.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.keys())
['field1', 'field2']
Return type:

Iterator[str]

values()

Returns an iterator over the struct’s field values.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.values())
['value', 42]
Return type:

Iterator[Any]

property accessList: List[AccessListEntry]

Decodes the access list from raw format to a list of AccessListEntry.

Example

>>> transaction = _TransactionBase(...)
>>> access_list = transaction.accessList
>>> isinstance(access_list, list)
True
>>> isinstance(access_list[0], AccessListEntry)
True

See also

  • AccessListEntry

arbSubType: uint
arbType: uint
property block: BlockNumber

A shorthand getter for blockNumber.

Example

>>> transaction = _TransactionBase(...)
>>> transaction.block == transaction.blockNumber
True
blockHash: BlockHash

The hash of the block including this transaction.

blockNumber: BlockNumber

The number of the block including this transaction.

chainId: ChainId | None

The chain id of the transaction, if any.

None for v in {27, 28}, otherwise derived from eip-155.

This field is not included in the transactions field of a eth_getBlock response.

gas: Wei

The gas provided by the sender.

gasPrice: Wei

The gas price provided by the sender in wei.

hash: TransactionHash

The hash of the transaction.

indexInParent: uint
input: HexBytes

The data sent along with the transaction.

l1BlockNumber: BlockNumber
l1TxOrigin: Address
nonce: Nonce

The number of transactions made by the sender before this one.

r: HexBytes

The R field of the signature.

s: HexBytes

The S field of the signature.

sender: Address

The address of the sender.

Note

This attribute is mapped to the field() name ‘from’ during serialization and deserialization.

to: Address | None

The address of the receiver. None when it’s a contract creation transaction.

transactionIndex: TransactionIndex

The index position of the transaction in the block.

v: uint

ECDSA recovery ID.

value: Wei

The value transferred in wei encoded as hexadecimal.

class evmspec.structs.TransactionReceipt[source]

Bases: LazyDictStruct

Represents the receipt of a transaction within a block.

get(key, default=None)

Get the value associated with a key, or a default value if the key is not present.

Parameters:
  • key (str) – The key to look up.

  • default (optional) – The value to return if the key is not present.

Return type:

Any

Example

>>> class MyStruct(DictStruct):
...     field1: str
>>> s = MyStruct(field1="value")
>>> s.get('field1')
'value'
>>> s.get('field2', 'default')
'default'
items()

Returns an iterator over the struct’s field name and value pairs.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.items())
[('field1', 'value'), ('field2', 42)]
Return type:

Iterator[Tuple[str, Any]]

keys()

Returns an iterator over the field names of the struct.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.keys())
['field1', 'field2']
Return type:

Iterator[str]

values()

Returns an iterator over the struct’s field values.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.values())
['value', 42]
Return type:

Iterator[Any]

blobGasUsed: Wei

This field is sometimes present, only on Mainnet.

Examples

>>> receipt.blobGasUsed
Wei(0)
blockNumber: BlockNumber

The block number that contains the transaction.

Examples

>>> receipt.blockNumber
BlockNumber(1234567)
contractAddress: Address | None

The contract address created, if the transaction was a contract creation, otherwise None.

Examples

>>> receipt.contractAddress
Address('0x...')
cumulativeGasUsed: Wei

The total amount of gas used in the block up to and including this transaction.

Examples

>>> receipt.cumulativeGasUsed
Wei(100000)
effectiveGasPrice: Wei

The actual value per gas deducted from the sender’s account.

This field is only present on Mainnet.

Examples

>>> receipt.effectiveGasPrice
Wei(1000000000)
property feeStats: ArbitrumFeeStats

This field is only present on Arbitrum.

Examples

>>> receipt.feeStats
ArbitrumFeeStats(...)
gasUsed: Wei

The amount of gas used by this transaction, not counting internal transactions, calls or delegate calls.

Examples

>>> receipt.gasUsed
Wei(21000)
l1BlockNumber: BlockNumber

This field is only present on Arbitrum.

Examples

>>> receipt.l1BlockNumber
BlockNumber(1234567)
l1Fee: Wei

This field is only present on Optimism.

Examples

>>> receipt.l1Fee
Wei(50000000000)
l1FeeScalar: Decimal

This field is only present on Optimism.

Examples

>>> receipt.l1FeeScalar
Decimal('1.0')
l1GasPrice: Wei

This field is only present on Optimism.

Examples

>>> receipt.l1GasPrice
Wei(1000000000)
l1GasUsed: Wei

This field is only present on Optimism.

Examples

>>> receipt.l1GasUsed
Wei(50000)
l1InboxBatchInfo: HexBytes | None

This field is only present on Arbitrum.

Examples

>>> receipt.l1InboxBatchInfo
HexBytes('0x...')
property logs: Tuple[Log, ...]

The logs that were generated during this transaction.

Examples

>>> receipt.logs
(Log(...), Log(...))
status: Status

The status of the transaction, represented by the Status enum: Status.success (1) if the transaction succeeded, Status.failure (0) if it failed.

Examples

>>> receipt.status
<Status.success: 1>
transactionHash: TransactionHash

The unique hash of this transaction.

Examples

>>> receipt.transactionHash
TransactionHash('0x...')
transactionIndex: TransactionIndex

The position of this transaction within the block.

Examples

>>> receipt.transactionIndex
TransactionIndex(0)
type: uint

The transaction type.

This field is only present on Mainnet.

Examples

>>> receipt.type
uint(2)