evmspec.structs.trace package
Submodules
evmspec.structs.trace.call module
- class evmspec.structs.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:
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)]
- 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']
- 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]
- 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...'
- class evmspec.structs.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:
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:
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)]
- 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']
- 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]
- class evmspec.structs.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"
- 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:
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)]
- 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']
- 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]
- property block: BlockNumber
A shorthand getter for ‘blockNumber’.
Examples
>>> class MyTrace(_FilterTraceBase): ... pass >>> trace = MyTrace(blockNumber=123456, blockHash="0xabc...", transactionHash="0xdef...", transactionPosition=1, traceAddress=[0, 1], subtraces=2) >>> trace.block 123456
- blockHash: BlockHash
The hash of the block where this action happened.
Examples
>>> class MyTrace(_FilterTraceBase): ... pass >>> trace = MyTrace(blockNumber=123456, blockHash="0xabc...", transactionHash="0xdef...", transactionPosition=1, traceAddress=[0, 1], subtraces=2) >>> trace.blockHash '0xabc...'
- blockNumber: BlockNumber
The number of the block where this action happened.
Examples
>>> class MyTrace(_FilterTraceBase): ... pass >>> trace = MyTrace(blockNumber=123456, blockHash="0xabc...", transactionHash="0xdef...", transactionPosition=1, traceAddress=[0, 1], subtraces=2) >>> trace.blockNumber 123456
- 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
>>> class MyTrace(_FilterTraceBase): ... pass >>> trace = MyTrace(blockNumber=123456, blockHash="0xabc...", transactionHash="0xdef...", transactionPosition=1, traceAddress=[0, 1], subtraces=2) >>> trace.subtraces 2
- traceAddress: List[uint]
The trace addresses (array) representing the path of the call within the trace tree.
Examples
>>> class MyTrace(_FilterTraceBase): ... pass >>> trace = MyTrace(blockNumber=123456, blockHash="0xabc...", transactionHash="0xdef...", transactionPosition=1, traceAddress=[0, 1], subtraces=2) >>> trace.traceAddress [0, 1]
- transactionHash: TransactionHash
The hash of the transaction being traced.
Examples
>>> class MyTrace(_FilterTraceBase): ... pass >>> trace = MyTrace(blockNumber=123456, blockHash="0xabc...", transactionHash="0xdef...", transactionPosition=1, traceAddress=[0, 1], subtraces=2) >>> trace.transactionHash '0xdef...'
- transactionPosition: int
The position of the transaction in the block.
Examples
>>> class MyTrace(_FilterTraceBase): ... pass >>> trace = MyTrace(blockNumber=123456, blockHash="0xabc...", transactionHash="0xdef...", transactionPosition=1, traceAddress=[0, 1], subtraces=2) >>> trace.transactionPosition 1
- class evmspec.structs.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>
- call = 0
- delegatecall = 1
- staticcall = 2
evmspec.structs.trace.create module
- class evmspec.structs.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).
Examples
>>> action = Action(init=HexBytes("0x6000600055")) >>> action.init HexBytes('0x6000600055')
See also
evmspec.structs.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:
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)]
- 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']
- 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]
- 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...'
- class evmspec.structs.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.
Examples
>>> result = Result(address=Address("0x1234567890abcdef1234567890abcdef12345678"), code=HexBytes("0x6000600055")) >>> result.address '0x1234567890abcdef1234567890abcdef12345678' >>> result.code HexBytes('0x6000600055')
See also
evmspec.structs.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:
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)]
- 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']
- 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]
- class evmspec.structs.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 property to decode this data into a structured
Action
object representing 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.type 'create' >>> trace.action.init HexBytes('0x6000600055')
- 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:
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)]
- 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']
- 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]
- 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
>>> class MyTrace(_FilterTraceBase): ... pass >>> trace = MyTrace(blockNumber=123456, blockHash="0xabc...", transactionHash="0xdef...", transactionPosition=1, traceAddress=[0, 1], subtraces=2) >>> trace.block 123456
- blockHash: BlockHash
The hash of the block where this action happened.
Examples
>>> class MyTrace(_FilterTraceBase): ... pass >>> trace = MyTrace(blockNumber=123456, blockHash="0xabc...", transactionHash="0xdef...", transactionPosition=1, traceAddress=[0, 1], subtraces=2) >>> trace.blockHash '0xabc...'
- blockNumber: BlockNumber
The number of the block where this action happened.
Examples
>>> class MyTrace(_FilterTraceBase): ... pass >>> trace = MyTrace(blockNumber=123456, blockHash="0xabc...", transactionHash="0xdef...", transactionPosition=1, traceAddress=[0, 1], subtraces=2) >>> trace.blockNumber 123456
- error: str
An error message if an error occurred during the execution of the transaction. Defaults to UNSET.
Examples
>>> class MyTrace(_FilterTraceBase): ... pass >>> trace = MyTrace(blockNumber=123456, blockHash="0xabc...", transactionHash="0xdef...", transactionPosition=1, traceAddress=[0, 1], subtraces=2, error=UNSET) >>> trace.error UNSET
- result: Result
The result object, adhering to the parity format, containing deployment details.
This includes the address and bytecode of the deployed contract, which are essential for verifying the deployment was successful and retrieving the contract’s code.
See also
Result
for more details on the result structure.
- subtraces: uint
The number of traces of internal transactions that occurred during this transaction.
Examples
>>> class MyTrace(_FilterTraceBase): ... pass >>> trace = MyTrace(blockNumber=123456, blockHash="0xabc...", transactionHash="0xdef...", transactionPosition=1, traceAddress=[0, 1], subtraces=2) >>> trace.subtraces 2
- traceAddress: List[uint]
The trace addresses (array) representing the path of the call within the trace tree.
Examples
>>> class MyTrace(_FilterTraceBase): ... pass >>> trace = MyTrace(blockNumber=123456, blockHash="0xabc...", transactionHash="0xdef...", transactionPosition=1, traceAddress=[0, 1], subtraces=2) >>> trace.traceAddress [0, 1]
- transactionHash: TransactionHash
The hash of the transaction being traced.
Examples
>>> class MyTrace(_FilterTraceBase): ... pass >>> trace = MyTrace(blockNumber=123456, blockHash="0xabc...", transactionHash="0xdef...", transactionPosition=1, traceAddress=[0, 1], subtraces=2) >>> trace.transactionHash '0xdef...'
- transactionPosition: int
The position of the transaction in the block.
Examples
>>> class MyTrace(_FilterTraceBase): ... pass >>> trace = MyTrace(blockNumber=123456, blockHash="0xabc...", transactionHash="0xdef...", transactionPosition=1, traceAddress=[0, 1], subtraces=2) >>> trace.transactionPosition 1
evmspec.structs.trace.reward module
- class evmspec.structs.trace.reward.Action[source]
Bases:
_ActionBase
Action type for rewards.
This class extends
_ActionBase
to include specific attributes for reward actions in Ethereum traces.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:
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)]
- 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']
- 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]
- 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...'
- class evmspec.structs.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:
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)]
- 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']
- 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]
- 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 structuredAction
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
>>> class MyTrace(_FilterTraceBase): ... pass >>> trace = MyTrace(blockNumber=123456, blockHash="0xabc...", transactionHash="0xdef...", transactionPosition=1, traceAddress=[0, 1], subtraces=2) >>> trace.block 123456
- blockHash: BlockHash
The hash of the block where this action happened.
Examples
>>> class MyTrace(_FilterTraceBase): ... pass >>> trace = MyTrace(blockNumber=123456, blockHash="0xabc...", transactionHash="0xdef...", transactionPosition=1, traceAddress=[0, 1], subtraces=2) >>> trace.blockHash '0xabc...'
- blockNumber: BlockNumber
The number of the block where this action happened.
Examples
>>> class MyTrace(_FilterTraceBase): ... pass >>> trace = MyTrace(blockNumber=123456, blockHash="0xabc...", transactionHash="0xdef...", transactionPosition=1, traceAddress=[0, 1], subtraces=2) >>> trace.blockNumber 123456
- error: str
An error message if an error occurred during the execution of the transaction. Defaults to UNSET.
Examples
>>> class MyTrace(_FilterTraceBase): ... pass >>> trace = MyTrace(blockNumber=123456, blockHash="0xabc...", transactionHash="0xdef...", transactionPosition=1, traceAddress=[0, 1], subtraces=2, error=UNSET) >>> trace.error UNSET
- subtraces: uint
The number of traces of internal transactions that occurred during this transaction.
Examples
>>> class MyTrace(_FilterTraceBase): ... pass >>> trace = MyTrace(blockNumber=123456, blockHash="0xabc...", transactionHash="0xdef...", transactionPosition=1, traceAddress=[0, 1], subtraces=2) >>> trace.subtraces 2
- traceAddress: List[uint]
The trace addresses (array) representing the path of the call within the trace tree.
Examples
>>> class MyTrace(_FilterTraceBase): ... pass >>> trace = MyTrace(blockNumber=123456, blockHash="0xabc...", transactionHash="0xdef...", transactionPosition=1, traceAddress=[0, 1], subtraces=2) >>> trace.traceAddress [0, 1]
- transactionHash: TransactionHash
The hash of the transaction being traced.
Examples
>>> class MyTrace(_FilterTraceBase): ... pass >>> trace = MyTrace(blockNumber=123456, blockHash="0xabc...", transactionHash="0xdef...", transactionPosition=1, traceAddress=[0, 1], subtraces=2) >>> trace.transactionHash '0xdef...'
- transactionPosition: int
The position of the transaction in the block.
Examples
>>> class MyTrace(_FilterTraceBase): ... pass >>> trace = MyTrace(blockNumber=123456, blockHash="0xabc...", transactionHash="0xdef...", transactionPosition=1, traceAddress=[0, 1], subtraces=2) >>> trace.transactionPosition 1
evmspec.structs.trace.suicide module
- class evmspec.structs.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. These attributes are inherited from_ActionBase
and are accessible when properly initialized.See also
_ActionBase
for common action attributes.
Examples
>>> from evmspec.structs.trace.suicide import Action >>> from evmspec.data import Address >>> action = Action(sender=Address("0x1234567890abcdef1234567890abcdef12345678"), value=1000, gas=21000) >>> action.sender '0x1234567890abcdef1234567890abcdef12345678' >>> 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:
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)]
- 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']
- 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]
- 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...'
- class evmspec.structs.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.
See also
_FilterTraceBase
for common trace attributes.Action
for details on the action attribute.
Examples
>>> from evmspec.structs.trace.suicide import Trace, Action >>> from evmspec.data import Address >>> action = Action(sender=Address("0x1234567890abcdef1234567890abcdef12345678"), value=1000, gas=21000) >>> trace = Trace( ... blockNumber=123456, ... blockHash="0xabc", ... transactionHash="0xdef", ... transactionPosition=1, ... traceAddress=[0], ... subtraces=0, ... action=action, ... result=None ... ) >>> trace.type 'suicide' >>> trace.action.sender '0x1234567890abcdef1234567890abcdef12345678' >>> 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:
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)]
- 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']
- 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]
- property block: BlockNumber
A shorthand getter for ‘blockNumber’.
Examples
>>> class MyTrace(_FilterTraceBase): ... pass >>> trace = MyTrace(blockNumber=123456, blockHash="0xabc...", transactionHash="0xdef...", transactionPosition=1, traceAddress=[0, 1], subtraces=2) >>> trace.block 123456
- blockHash: BlockHash
The hash of the block where this action happened.
Examples
>>> class MyTrace(_FilterTraceBase): ... pass >>> trace = MyTrace(blockNumber=123456, blockHash="0xabc...", transactionHash="0xdef...", transactionPosition=1, traceAddress=[0, 1], subtraces=2) >>> trace.blockHash '0xabc...'
- blockNumber: BlockNumber
The number of the block where this action happened.
Examples
>>> class MyTrace(_FilterTraceBase): ... pass >>> trace = MyTrace(blockNumber=123456, blockHash="0xabc...", transactionHash="0xdef...", transactionPosition=1, traceAddress=[0, 1], subtraces=2) >>> trace.blockNumber 123456
- error: str
An error message if an error occurred during the execution of the transaction. Defaults to UNSET.
Examples
>>> class MyTrace(_FilterTraceBase): ... pass >>> trace = MyTrace(blockNumber=123456, blockHash="0xabc...", transactionHash="0xdef...", transactionPosition=1, traceAddress=[0, 1], subtraces=2, 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
>>> class MyTrace(_FilterTraceBase): ... pass >>> trace = MyTrace(blockNumber=123456, blockHash="0xabc...", transactionHash="0xdef...", transactionPosition=1, traceAddress=[0, 1], subtraces=2) >>> trace.subtraces 2
- traceAddress: List[uint]
The trace addresses (array) representing the path of the call within the trace tree.
Examples
>>> class MyTrace(_FilterTraceBase): ... pass >>> trace = MyTrace(blockNumber=123456, blockHash="0xabc...", transactionHash="0xdef...", transactionPosition=1, traceAddress=[0, 1], subtraces=2) >>> trace.traceAddress [0, 1]
- transactionHash: TransactionHash
The hash of the transaction being traced.
Examples
>>> class MyTrace(_FilterTraceBase): ... pass >>> trace = MyTrace(blockNumber=123456, blockHash="0xabc...", transactionHash="0xdef...", transactionPosition=1, traceAddress=[0, 1], subtraces=2) >>> trace.transactionHash '0xdef...'
- transactionPosition: int
The position of the transaction in the block.
Examples
>>> class MyTrace(_FilterTraceBase): ... pass >>> trace = MyTrace(blockNumber=123456, blockHash="0xabc...", transactionHash="0xdef...", transactionPosition=1, traceAddress=[0, 1], subtraces=2) >>> trace.transactionPosition 1
Module contents
- evmspec.structs.trace.FilterTrace
A type alias for filtering trace types.
FilterTrace is a Union of the following trace types: -
evmspec.structs.trace.call.Trace
-evmspec.structs.trace.create.Trace
-evmspec.structs.trace.reward.Trace
-evmspec.structs.trace.suicide.Trace
Examples
You can use FilterTrace to specify a variable that can hold any of the trace types:
>>> from evmspec.structs.trace import FilterTrace >>> trace: FilterTrace = call.Trace(...) >>> trace = create.Trace(...) >>> trace = reward.Trace(...) >>> trace = suicide.Trace(...)
See also