Transactions
Transaction class defines VeChain’s multi-clause transaction (tx).
This module defines data structure of a transaction, and the encoding/decoding of transaction data.
Classes:
Multi-clause transaction. |
Type or structure checkers:
Type of transaction clause. |
|
Type of |
|
Type of transaction body. |
|
Validation |
|
Validation |
|
Validation |
Data:
Unsigned transaction wrapper. |
|
Signed transaction wrapper. |
Functions:
Calculate the gas the data will consume. |
|
Calculate roughly the gas from a list of clauses. |
- class thor_devkit.transaction.Transaction(body: thor_devkit.transaction.TransactionBodyT)[source]
Bases:
objectMulti-clause transaction.
Attributes:
Mask for delegation bit.
Get a dict of the body that represents the transaction.
Roughly estimate amount of gas this transaction will consume.
Signature of transaction.
Transaction origin.
Transaction delegator.
Check if this transaction is delegated.
Transaction id.
Methods:
Get a deep copy of transaction body.
Get signing hash (with delegate address if given).
Encode the tx into bytes.
Create a Transaction type instance from encoded bytes.
Deprecated:
Get delegator.
Get intrinsic gas estimate.
Get signature.
Set signature.
Get origin.
Get transaction ID.
Get a dict of the body that represents the transaction.
Construct a transaction from a given body.
- DELEGATED_MASK: Final = 1
Mask for delegation bit.
The reserved feature of delegated (vip-191) is 1.
- property body: thor_devkit.transaction.TransactionBodyT
Get a dict of the body that represents the transaction.
- copy_body() thor_devkit.transaction.TransactionBodyT[source]
Get a deep copy of transaction body.
- get_signing_hash(delegate_for: Optional[str] = None) bytes[source]
Get signing hash (with delegate address if given).
- property intrinsic_gas: int
Roughly estimate amount of gas this transaction will consume.
New in version 2.0.0.
- property is_delegated: bool
Check if this transaction is delegated.
Changed in version 2.0.0:
is_delegatedis a property now.
- static decode(raw: bytes, unsigned: bool) thor_devkit.transaction.Transaction[source]
Create a Transaction type instance from encoded bytes.
- get_delegator() Optional[str][source]
Get delegator.
Deprecated since version 2.0.0: Use
delegatorproperty instead.
- get_intrinsic_gas() int[source]
Get intrinsic gas estimate.
Deprecated since version 2.0.0: Use
intrinsic_gasproperty instead.
- get_signature() Optional[bytes][source]
Get signature.
Deprecated since version 2.0.0: Use
signatureproperty instead.
- set_signature(sig: bytes) None[source]
Set signature.
Deprecated since version 2.0.0: Use
signatureproperty setter instead.
- get_origin() Optional[str][source]
Get origin.
Deprecated since version 2.0.0: Use
originproperty instead.
- get_id() Optional[str][source]
Get transaction ID.
Deprecated since version 2.0.0: Use
idproperty instead.
- get_body(as_copy: bool = True) thor_devkit.transaction.TransactionBodyT[source]
Get a dict of the body that represents the transaction.
Deprecated since version 2.0.0: Use
body()orcopy_body()instead.- Parameters
as_copy (bool, default: True) – Return a new dict clone of the body
- Returns
If as_copy, return a newly created dict. If not, return the body of this Transaction object.
- Return type
- class thor_devkit.transaction.ClauseT[source]
Bases:
TypedDictType of transaction clause.
New in version 2.0.0.
- class thor_devkit.transaction.ReservedT[source]
Bases:
TypedDictType of
reservedtransaction field.New in version 2.0.0.
- class thor_devkit.transaction.TransactionBodyT[source]
Bases:
TypedDictType of transaction body.
New in version 2.0.0.
- blockRef: str
Block reference,
0x...-like hex string (8 bytes).First 4 bytes are block height, the rest is part of referred block ID.
- clauses: Sequence[thor_devkit.transaction.ClauseT]
Transaction clauses.
- reserved: typing_extensions.NotRequired[thor_devkit.transaction.ReservedT]
Reserved field.
- thor_devkit.transaction.CLAUSE(data): Final
Validation
Schemafor transaction clause.Changed in version 2.0.0: Added validation of
to,valueanddataas hex string.
- thor_devkit.transaction.BODY(data): Final
Validation
Schemafor transaction body.Changed in version 2.0.0: Added validation of
gas,dependsOnandnoncefields as hex string.
- thor_devkit.transaction.UnsignedTxWrapper: Final
Unsigned transaction wrapper.
- thor_devkit.transaction.SignedTxWrapper: Final
Signed transaction wrapper.