evmspec.trace package

Submodules

evmspec.trace.call module

class evmspec.trace.call.Action[source]

Bases: _ActionBase

Action type for contract calls.

Examples

>>> action = Action(callType=Type.call, to=Address("0x0"), input=HexBytes("0x"))
>>> action.callType
<Type.call: 0>
>>> action.to
'0x0000000000000000000000000000000000000000'
>>> action.input
HexBytes('0x')
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]

callType: Type

The type of the call.

gas: Wei

The gas provided.

Examples

>>> from msgspec import json
>>> class MyAction(_ActionBase):
...     pass
>>> action = json.decode(b'{"from": "0xabc...", "value": 1000, "gas": 21000}', type=MyAction)
>>> action.gas
21000
input: HexBytes

The input data of the action (transaction).

sender: Address

The sender address.

Note

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

Examples

>>> from msgspec import json
>>> class MyAction(_ActionBase):
...     pass
>>> action = json.decode(b'{"from": "0xabc...", "value": 1000, "gas": 21000}', type=MyAction)
>>> action.sender
'0xabc...'
to: Address

The receiver address.

value: Wei

The amount of ETH sent in this action (transaction).

Examples

>>> from msgspec import json
>>> class MyAction(_ActionBase):
...     pass
>>> action = json.decode(b'{"from": "0xabc...", "value": 1000, "gas": 21000}', type=MyAction)
>>> action.value
1000
class evmspec.trace.call.Result[source]

Bases: _ResultBase

Represents the result of a contract call action, including the output data of the contract call.

output

The output of this transaction.

Type:

hexbytes.main.HexBytes

Examples

>>> result = Result(output=HexBytes("0x"))
>>> result.output
HexBytes('0x')
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]

gasUsed: Wei

The amount of gas used by this transaction.

Examples

>>> class MyResult(_ResultBase):
...     pass
>>> result = MyResult(gasUsed=21000)
>>> result.gasUsed
21000
output: HexBytes

The output of this transaction.

class evmspec.trace.call.Trace[source]

Bases: _FilterTraceBase

Represents a trace of a contract call, including action and result details.

Examples

>>> data = b'{"type": "call", "action": {"callType": 0, "to": "0x0", "input": "0x"}, "result": null, "error": "out of gas"}'
>>> trace = msgspec.json.decode(data, type=Trace)
>>> trace = Trace(_action=Raw(b'{"callType": 0, "to": "0x0", "input": "0x"}'), result=None)
>>> trace.type
'call'
>>> trace.action.callType
<Type.call: 0>
>>> trace.result is None
True
>>> trace.error
"out of 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]

property action: Action

The decoded call action, parity style.

property block: BlockNumber

A shorthand getter for ‘blockNumber’.

Examples

>>> trace = _FilterTraceBase(blockNumber=123456, ...)
>>> trace.block
123456
blockHash: BlockHash

The hash of the block where this action happened.

Examples

>>> trace = _FilterTraceBase(blockHash="0xabc...", ...)
>>> trace.blockHash
'0xabc...'
blockNumber: BlockNumber

The number of the block where this action happened.

Examples

>>> trace = _FilterTraceBase(blockNumber=123456, ...)
>>> trace.blockNumber
123456
error: str

The error message, if an error occurred.

result: Result | None

The result object, parity style.

None if the call errored. Error details will be included in the error field.

subtraces: uint

The number of traces of internal transactions that occurred during this transaction.

Examples

>>> trace = _FilterTraceBase(subtraces=2, ...)
>>> trace.subtraces
2
traceAddress: List[uint]

The trace addresses (array) representing the path of the call within the trace tree.

Examples

>>> trace = _FilterTraceBase(traceAddress=[0, 1], ...)
>>> trace.traceAddress
[0, 1]
transactionHash: TransactionHash

The hash of the transaction being traced.

Examples

>>> trace = _FilterTraceBase(transactionHash="0xdef...", ...)
>>> trace.transactionHash
'0xdef...'
transactionPosition: int

The position of the transaction in the block.

Examples

>>> trace = _FilterTraceBase(transactionPosition=1, ...)
>>> trace.transactionPosition
1
type: ClassVar[Literal['call']] = 'call'

A class variable indicating the trace type as “call”.

class evmspec.trace.call.Type[source]

Bases: Enum

Enum representing the types of contract calls: call, delegatecall, and staticcall.

Examples

>>> Type.call
<Type.call: 0>
>>> Type.delegatecall
<Type.delegatecall: 1>
>>> Type.staticcall
<Type.staticcall: 2>

See also

call = 0
delegatecall = 1
staticcall = 2

evmspec.trace.create module

class evmspec.trace.create.Action[source]

Bases: _ActionBase

Represents the action type for contract creations.

This class captures the initialization code necessary for deploying a new contract on the Ethereum Virtual Machine (EVM).

init

The init code for the deployed contract.

Type:

HexBytes

Examples

>>> action = Action(init=HexBytes("0x6000600055"))
>>> action.init
HexBytes('0x6000600055')

See also

  • evmspec.trace._base._ActionBase

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]

gas: Wei

The gas provided.

Examples

>>> from msgspec import json
>>> class MyAction(_ActionBase):
...     pass
>>> action = json.decode(b'{"from": "0xabc...", "value": 1000, "gas": 21000}', type=MyAction)
>>> action.gas
21000
init: HexBytes

The init code for the deployed contract.

sender: Address

The sender address.

Note

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

Examples

>>> from msgspec import json
>>> class MyAction(_ActionBase):
...     pass
>>> action = json.decode(b'{"from": "0xabc...", "value": 1000, "gas": 21000}', type=MyAction)
>>> action.sender
'0xabc...'
value: Wei

The amount of ETH sent in this action (transaction).

Examples

>>> from msgspec import json
>>> class MyAction(_ActionBase):
...     pass
>>> action = json.decode(b'{"from": "0xabc...", "value": 1000, "gas": 21000}', type=MyAction)
>>> action.value
1000
class evmspec.trace.create.Result[source]

Bases: _ResultBase

Represents the result of a contract creation action.

It includes details such as the address and bytecode of the newly deployed contract. This information is essential for verifying the deployment was successful and retrieving the contract’s code.

address

The address of the deployed contract.

Type:

Address

code

The bytecode of the deployed contract.

Type:

HexBytes

Examples

>>> result = Result(address=Address("0x1234567890abcdef1234567890abcdef12345678"), code=HexBytes("0x6000600055"))
>>> result.address
'0x1234567890abcdef1234567890abcdef12345678'
>>> result.code
HexBytes('0x6000600055')

See also

  • evmspec.trace._base._ResultBase

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 address of the deployed contract.

code: HexBytes

The bytecode of the deployed contract.

gasUsed: Wei

The amount of gas used by this transaction.

Examples

>>> class MyResult(_ResultBase):
...     pass
>>> result = MyResult(gasUsed=21000)
>>> result.gasUsed
21000
class evmspec.trace.create.Trace[source]

Bases: _FilterTraceBase

Represents a trace of a contract deployment.

Provides a detailed trace structure which includes raw action data and a method to decode this data into a structured Action object representing the specific details of the contract creation process.

type

The type of trace, fixed as “create”.

Type:

ClassVar[Literal[“create”]]

_action

The raw create action data, following the parity format.

Type:

Raw

result

The result object, adhering to the parity format, containing deployment details.

Type:

Result

Examples

>>> trace = Trace(_action=Raw(b'{"init":"0x6000600055"}'), result=Result(address=Address("0x1234567890abcdef1234567890abcdef12345678"), code=HexBytes("0x6000600055")))
>>> trace.type
'create'
>>> trace.action.init
HexBytes('0x6000600055')

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]

property action: Action

Decodes the raw action data into an Action object.

Utilizes the _action field for decoding, transforming it into a structured Action object that represents the specific details of the contract creation process.

Examples

>>> trace = Trace(_action=Raw(b'{"init":"0x6000600055"}'), result=Result(address=Address("0x1234567890abcdef1234567890abcdef12345678"), code=HexBytes("0x6000600055")))
>>> trace.action.init
HexBytes('0x6000600055')
property block: BlockNumber

A shorthand getter for ‘blockNumber’.

Examples

>>> trace = _FilterTraceBase(blockNumber=123456, ...)
>>> trace.block
123456
blockHash: BlockHash

The hash of the block where this action happened.

Examples

>>> trace = _FilterTraceBase(blockHash="0xabc...", ...)
>>> trace.blockHash
'0xabc...'
blockNumber: BlockNumber

The number of the block where this action happened.

Examples

>>> trace = _FilterTraceBase(blockNumber=123456, ...)
>>> trace.blockNumber
123456
error: str

An error message if an error occurred during the execution of the transaction. Defaults to UNSET.

Examples

>>> trace = _FilterTraceBase(error=UNSET, ...)
>>> trace.error
UNSET
result: Result

The result object, adhering to the parity format, containing deployment details.

subtraces: uint

The number of traces of internal transactions that occurred during this transaction.

Examples

>>> trace = _FilterTraceBase(subtraces=2, ...)
>>> trace.subtraces
2
traceAddress: List[uint]

The trace addresses (array) representing the path of the call within the trace tree.

Examples

>>> trace = _FilterTraceBase(traceAddress=[0, 1], ...)
>>> trace.traceAddress
[0, 1]
transactionHash: TransactionHash

The hash of the transaction being traced.

Examples

>>> trace = _FilterTraceBase(transactionHash="0xdef...", ...)
>>> trace.transactionHash
'0xdef...'
transactionPosition: int

The position of the transaction in the block.

Examples

>>> trace = _FilterTraceBase(transactionPosition=1, ...)
>>> trace.transactionPosition
1
type: ClassVar[Literal['create']] = 'create'

evmspec.trace.reward module

class evmspec.trace.reward.Action[source]

Bases: _ActionBase

Action type for rewards.

This class extends _ActionBase to include specific attributes for reward actions in Ethereum traces.

author

The author of this reward.

Type:

Address

rewardType

The type of the reward.

Type:

Type

Example

>>> action = Action(author=Address("0x123"), rewardType=Type.block)
>>> print(action.author)
0x123
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]

author: Address

The author of this reward.

gas: Wei

The gas provided.

Examples

>>> from msgspec import json
>>> class MyAction(_ActionBase):
...     pass
>>> action = json.decode(b'{"from": "0xabc...", "value": 1000, "gas": 21000}', type=MyAction)
>>> action.gas
21000
rewardType: Type

The type of the reward.

sender: Address

The sender address.

Note

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

Examples

>>> from msgspec import json
>>> class MyAction(_ActionBase):
...     pass
>>> action = json.decode(b'{"from": "0xabc...", "value": 1000, "gas": 21000}', type=MyAction)
>>> action.sender
'0xabc...'
value: Wei

The amount of ETH sent in this action (transaction).

Examples

>>> from msgspec import json
>>> class MyAction(_ActionBase):
...     pass
>>> action = json.decode(b'{"from": "0xabc...", "value": 1000, "gas": 21000}', type=MyAction)
>>> action.value
1000
class evmspec.trace.reward.Trace[source]

Bases: _FilterTraceBase

Represents the trace for a reward in Ethereum.

This class extends _FilterTraceBase and is specifically tagged as a “reward” trace. It includes raw data for the reward action that requires decoding.

type

A class variable indicating the trace type.

Type:

ClassVar[Literal[“reward”]]

_action

Raw data of the reward action, requires decoding to be useful.

Type:

Raw

Example

>>> trace = Trace(blockNumber=123, blockHash=BlockHash("0xabc"), transactionHash=TransactionHash("0xdef"), transactionPosition=0, traceAddress=[], subtraces=0, _action=Raw(b'...'))
>>> decoded_action = trace.action
>>> print(decoded_action.rewardType)
Type.block

See also

  • Action: The decoded action object.

  • _FilterTraceBase: The base class for trace representations.

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 action: Action

Decodes the raw reward action into an Action object, using parity style.

This method uses the msgspec.json.decode() function with a decoding hook to convert the raw action data into a structured Action object.

Returns:

The decoded action.

Example

>>> trace = Trace(blockNumber=123, blockHash=BlockHash("0xabc"), transactionHash=TransactionHash("0xdef"), transactionPosition=0, traceAddress=[], subtraces=0, _action=Raw(b'...'))
>>> action = trace.action
>>> print(action.author)
0x123
property block: BlockNumber

A shorthand getter for ‘blockNumber’.

Examples

>>> trace = _FilterTraceBase(blockNumber=123456, ...)
>>> trace.block
123456
blockHash: BlockHash

The hash of the block where this action happened.

Examples

>>> trace = _FilterTraceBase(blockHash="0xabc...", ...)
>>> trace.blockHash
'0xabc...'
blockNumber: BlockNumber

The number of the block where this action happened.

Examples

>>> trace = _FilterTraceBase(blockNumber=123456, ...)
>>> trace.blockNumber
123456
error: str

An error message if an error occurred during the execution of the transaction. Defaults to UNSET.

Examples

>>> trace = _FilterTraceBase(error=UNSET, ...)
>>> trace.error
UNSET
subtraces: uint

The number of traces of internal transactions that occurred during this transaction.

Examples

>>> trace = _FilterTraceBase(subtraces=2, ...)
>>> trace.subtraces
2
traceAddress: List[uint]

The trace addresses (array) representing the path of the call within the trace tree.

Examples

>>> trace = _FilterTraceBase(traceAddress=[0, 1], ...)
>>> trace.traceAddress
[0, 1]
transactionHash: TransactionHash

The hash of the transaction being traced.

Examples

>>> trace = _FilterTraceBase(transactionHash="0xdef...", ...)
>>> trace.transactionHash
'0xdef...'
transactionPosition: int

The position of the transaction in the block.

Examples

>>> trace = _FilterTraceBase(transactionPosition=1, ...)
>>> trace.transactionPosition
1
type: ClassVar[Literal['reward']] = 'reward'
class evmspec.trace.reward.Type[source]

Bases: Enum

Represents the types of rewards in Ethereum: block or uncle.

This enum is used to specify the type of reward in Ethereum traces.

block

Represents a block reward.

Type:

int

uncle

Represents an uncle reward.

Type:

int

Example

>>> reward_type = Type.block
>>> print(reward_type)
Type.block
block = 0
uncle = 1

evmspec.trace.suicide module

class evmspec.trace.suicide.Action[source]

Bases: _ActionBase

Represents the action type for contract suicides.

This class captures the details of the self-destruct operation for contract suicides. It inherits attributes from _ActionBase that provide common details such as sender, value, and gas for Ethereum transaction actions.

See also

  • _ActionBase for common action attributes.

Examples

>>> from evmspec.trace.suicide import Action
>>> action = Action(sender="0x123", value=1000, gas=21000)
>>> action.sender
'0x123'
>>> action.value
1000
>>> action.gas
21000
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]

gas: Wei

The gas provided.

Examples

>>> from msgspec import json
>>> class MyAction(_ActionBase):
...     pass
>>> action = json.decode(b'{"from": "0xabc...", "value": 1000, "gas": 21000}', type=MyAction)
>>> action.gas
21000
sender: Address

The sender address.

Note

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

Examples

>>> from msgspec import json
>>> class MyAction(_ActionBase):
...     pass
>>> action = json.decode(b'{"from": "0xabc...", "value": 1000, "gas": 21000}', type=MyAction)
>>> action.sender
'0xabc...'
value: Wei

The amount of ETH sent in this action (transaction).

Examples

>>> from msgspec import json
>>> class MyAction(_ActionBase):
...     pass
>>> action = json.decode(b'{"from": "0xabc...", "value": 1000, "gas": 21000}', type=MyAction)
>>> action.value
1000
class evmspec.trace.suicide.Trace[source]

Bases: _FilterTraceBase

Represents a trace of a contract self-destruct operation.

This class provides a detailed trace of a contract suicide action including the specific action taken and the result of the operation, conforming to the structure of a parity-style Ethereum trace.

type

The constant literal denoting the trace type as ‘suicide’.

Type:

ClassVar[Literal[‘suicide’]]

action

The suicide action, parity style.

Type:

evmspec.trace.suicide.Action

result

Explicitly set to None, indicating no meaningful result is expected from a contract self-destruct operation.

Type:

Literal[None]

See also

  • _FilterTraceBase for common trace attributes.

  • Action for details on the action attribute.

Examples

>>> from evmspec.trace.suicide import Trace, Action
>>> trace = Trace(
...     blockNumber=123456,
...     blockHash="0xabc",
...     transactionHash="0xdef",
...     transactionPosition=1,
...     traceAddress=[0],
...     subtraces=0,
...     action=Action(sender="0x123", value=1000, gas=21000),
...     result=None
... )
>>> trace.type
'suicide'
>>> trace.action.sender
'0x123'
>>> trace.result is None
True
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]

action: Action

The suicide action, parity style.

property block: BlockNumber

A shorthand getter for ‘blockNumber’.

Examples

>>> trace = _FilterTraceBase(blockNumber=123456, ...)
>>> trace.block
123456
blockHash: BlockHash

The hash of the block where this action happened.

Examples

>>> trace = _FilterTraceBase(blockHash="0xabc...", ...)
>>> trace.blockHash
'0xabc...'
blockNumber: BlockNumber

The number of the block where this action happened.

Examples

>>> trace = _FilterTraceBase(blockNumber=123456, ...)
>>> trace.blockNumber
123456
error: str

An error message if an error occurred during the execution of the transaction. Defaults to UNSET.

Examples

>>> trace = _FilterTraceBase(error=UNSET, ...)
>>> trace.error
UNSET
result: Literal[None]

Explicitly set to None, indicating no meaningful result is expected from a contract self-destruct operation.

subtraces: uint

The number of traces of internal transactions that occurred during this transaction.

Examples

>>> trace = _FilterTraceBase(subtraces=2, ...)
>>> trace.subtraces
2
traceAddress: List[uint]

The trace addresses (array) representing the path of the call within the trace tree.

Examples

>>> trace = _FilterTraceBase(traceAddress=[0, 1], ...)
>>> trace.traceAddress
[0, 1]
transactionHash: TransactionHash

The hash of the transaction being traced.

Examples

>>> trace = _FilterTraceBase(transactionHash="0xdef...", ...)
>>> trace.transactionHash
'0xdef...'
transactionPosition: int

The position of the transaction in the block.

Examples

>>> trace = _FilterTraceBase(transactionPosition=1, ...)
>>> trace.transactionPosition
1
type: ClassVar[Literal['suicide']] = 'suicide'

The constant literal denoting the trace type as ‘suicide’.

Module contents

evmspec.trace.FilterTrace

A type alias for filtering trace types.

FilterTrace is a Union of the following trace types: - evmspec.trace.call.Trace - evmspec.trace.create.Trace - evmspec.trace.reward.Trace - evmspec.trace.suicide.Trace

Examples

You can use FilterTrace to specify a variable that can hold any of the trace types:

>>> from evmspec.trace import FilterTrace
>>> trace: FilterTrace = call.Trace(...)
>>> trace = create.Trace(...)
>>> trace = reward.Trace(...)
>>> trace = suicide.Trace(...)

alias of Union[Trace, Trace, Trace, Trace]