transaction
— All things Transaction related¶
This module contains the famous Transaction class.
At its core is a byte array holding the instructions to be executed by the NEO virtual machine. Such instructions can include token balance updates or general smart contract execution.
Auxiliary attributes are included for validation purposes and validity constraints (think; only valid until a certain block) among other reasons.
-
class
neo3.network.payloads.transaction.
Transaction
(version, nonce, system_fee, network_fee, valid_until_block, attributes=None, signers=None, script=None, witnesses=None, protocol_magic=None)¶ Bases:
neo3.network.payloads.inventory.IInventory
,neo3.core.IInteroperable
,neo3.core.IJson
Data to be executed by the NEO virtual machine.
-
deserialize
(reader)¶ Deserialize the object from a binary stream.
- Parameters
reader (
BinaryReader
) – instance.- Return type
-
classmethod
deserialize_from_bytes
(data)¶ Parse data into an object instance.
-
deserialize_special
(reader)¶ Internal use only - deserialize the data from the stream into a TX that includes the unofficial fields
- Return type
-
deserialize_unsigned
(reader)¶ Deserialize the unsigned data part of the object from a binary stream.
- Parameters
reader (
BinaryReader
) – instance.- Raises
ValueError – The version is not zero.
ValueError – If the system of network fee is negative.
ValueError – If there is no script
- Return type
-
fee_per_byte
()¶ Calculates the network fee per byte.
Fee per byte = the TX’s networkfee / TX’s size
Warning
Should only be called once the transaction is completely build and will no longer be modified.
- Return type
-
classmethod
from_json
(json, procotol_magic=None)¶ Create object from JSON
-
classmethod
from_stack_item
(stack_item)¶ Convert a stack item into an object
- Return type
~T
-
get_hash_data
(protocol_magic)¶ Get the unsigned data
-
get_script_hashes_for_verifying
(_)¶ Helper method to get the data used in verifying the object.
-
hash
()¶ Get a unique block identifier based on the unsigned data portion of the object.
- Return type
-
serialize
(writer)¶ Serialize the object into a binary stream.
- Parameters
writer (
BinaryWriter
) – instance.- Return type
-
serialize_special
(writer)¶ Internal use only - serialize the TX includes its unofficial fields
- Return type
-
serialize_unsigned
(writer)¶ Serialize the unsigned part of the object into a binary stream.
- Parameters
writer (
BinaryWriter
) – instance.- Return type
-
to_stack_item
(reference_counter)¶ Convert self to a VM stack item.
- Parameters
reference_counter (
ReferenceCounter
) – ExecutionEngine reference counter- Return type
StackItem
-
try_get_attribute
(needle)¶ Helper method for finding an attribute of a specific type.
-
MAX_TRANSACTION_ATTRIBUTES
= 16¶ the maximum number of transaction attributes for a single transaction
-
MAX_TRANSACTION_SIZE
= 102400¶ the maximum number of bytes a single transaction may consists of
-
MAX_VALID_UNTIL_BLOCK_INCREMENT
= 5760¶ the maximum time a transaction will be valid from height of creation plus this value. Default is 24h
-
block_height
¶ The block height in which the transaction is included.
-
property
inventory_type
¶ Inventory type identifier.
- Return type
-
network_fee
¶ The cost of validation and inclusion in a block by the consensus node.
-
nonce
¶ Random number
-
script
¶ The array of instructions to be executed on the chain by the virtual machine.
-
property
sender
¶ The hash of the account who has send the transaction to the network
- Return type
-
signers
¶ A list of authorities used by the
ChecKWitness()
smart contract system call.
-
system_fee
¶ The cost of executing the script.
-
valid_until_block
¶ Optional attributes
See also
HighPriorityAttribute
.OracleResponse
.
-
version
¶ Transaction data structure version - for internal use
-
vm_state
¶ The virtual machine result of executing the script.
-
witnesses
: List[Witness]¶ A list of signing authorities used to validate the transaction.
-
-
class
neo3.network.payloads.transaction.
TransactionAttribute
¶ Bases:
neo3.core.serialization.ISerializable
,neo3.core.IJson
Attributes that can be attached to a Transaction.
-
deserialize
(reader)¶ Deserialize the object from a binary stream.
- Parameters
reader (
BinaryReader
) – instance.- Return type
-
static
deserialize_from
(reader)¶ Deserialize from a binary stream into a new TransactionAttribute
- Return type
-
classmethod
deserialize_from_bytes
(data)¶ Parse data into an object instance.
-
classmethod
from_json
(json)¶ Create object from JSON
-
serialize
(writer)¶ Serialize the object into a binary stream.
- Parameters
writer (
BinaryWriter
) – instance.- Return type
-