Skip to content
module

neo3.network.payloads.transaction

Transaction payload and related classes.

Classes
class

neo3.network.payloads.transaction.HighPriorityAttribute()

Bases
neo3.network.payloads.transaction.TransactionAttribute neo3.core.serialization.ISerializable neo3.core.interfaces.IJson

Attribute to give the transaction processing priority over other transactions.

Methods
  • __len__() Return the length of the object in number of bytes.
  • deserialize(reader) Deserialize the object from a binary stream.
  • serialize(writer) Serialize the object into a binary stream.
  • to_array() (bytes) Serialize the object into a bytearray.
  • to_json() (dict) Convert object into JSON representation.
  • deserialize_from_bytes(data) (ISerializable_T) Parse data into an object instance.
  • from_json(json) Create object from JSON.
  • deserialize_from(reader) (TransactionAttribute) Deserialize from a binary stream into a new TransactionAttribute.
classmethod

deserialize_from_bytes(data)

Parse data into an object instance.

Parameters
  • data (bytes | bytearray) hex escaped bytes.
Returns (ISerializable_T)

a deserialized instance of the class.

method

to_array() → bytes

Serialize the object into a bytearray.

method

__len__()

Return the length of the object in number of bytes.

method

deserialize(reader)

Deserialize the object from a binary stream.

Parameters
  • reader (BinaryReader) instance.
staticmethod

deserialize_from(reader) → TransactionAttribute

Deserialize from a binary stream into a new TransactionAttribute.

classmethod

from_json(json)

Create object from JSON.

method

serialize(writer)

Serialize the object into a binary stream.

Parameters
  • writer (BinaryWriter) instance.
method

to_json() → dict

Convert object into JSON representation.

class

neo3.network.payloads.transaction.OracleResponse(id, code, result)

Bases
neo3.network.payloads.transaction.TransactionAttribute neo3.core.serialization.ISerializable neo3.core.interfaces.IJson

Oracle response.

Attributes
  • allow_multiple Only one OracleResponse attribute can be attached per transaction
  • code The evaluation result code
  • id The OracleRequest id to which this is a response
  • result The actual result
Methods
  • __len__() Return the length of the object in number of bytes.
  • deserialize(reader) Deserialize the object from a binary stream.
  • serialize(writer) Serialize the object into a binary stream.
  • to_array() (bytes) Serialize the object into a bytearray.
  • to_json() (dict) Convert object into JSON representation.
  • deserialize_from_bytes(data) (ISerializable_T) Parse data into an object instance.
  • from_json(json) Create object from JSON
  • deserialize_from(reader) (TransactionAttribute) Deserialize from a binary stream into a new TransactionAttribute.
classmethod

deserialize_from_bytes(data)

Parse data into an object instance.

Parameters
  • data (bytes | bytearray) hex escaped bytes.
Returns (ISerializable_T)

a deserialized instance of the class.

method

to_array() → bytes

Serialize the object into a bytearray.

method

__len__()

Return the length of the object in number of bytes.

classmethod

from_json(json)

Create object from JSON

method

to_json() → dict

Convert object into JSON representation.

method

deserialize(reader)

Deserialize the object from a binary stream.

Parameters
  • reader (BinaryReader) instance.
staticmethod

deserialize_from(reader) → TransactionAttribute

Deserialize from a binary stream into a new TransactionAttribute.

method

serialize(writer)

Serialize the object into a binary stream.

Parameters
  • writer (BinaryWriter) instance.
enum

neo3.network.payloads.transaction.OracleResponseCode()

Bases
enum.IntEnum int enum.ReprEnum enum.Enum

Oracle response status codes.

Members
  • CONSENSUS_UNREACHABLE (int) 0x12
  • CONTENT_TYPE_NOT_SUPPORTED (int) 0x1f
  • ERROR (int) 0xff
  • FORBIDDEN (int) 0x18
  • INSUFFICIENT_FUNDS (int) 0x1c
  • NOT_FOUND (int) 0x14
  • PROTOCOL_NOT_SUPPORTED (int) 0x10
  • RESPONSE_TOO_LARGE (int) 0x1a
  • SUCCESS (int) 0x0
  • TIMEOUT (int) 0x16
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.network.payloads.verification.IVerifiable neo3.core.serialization.ISerializable neo3.core.interfaces.IJson

Data to be executed by the NEO virtual machine.

Attributes
  • block_height The block height in which the transaction is included.
  • inventory_type (InventoryType) Inventory type identifier.
  • 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.
  • sender (UInt160) The hash of the account who has sent the transaction to the network
  • signers (A list of authorities used by the) func:ChecKWitness smart contract system call.
  • system_fee The cost of executing the script.
  • valid_until_block The maximum chain height this transaction is valid.
  • version Transaction data structure version - for internal use
  • vm_state The virtual machine result of executing the script.
  • witnesses (list) A list of signing authorities used to validate the transaction.
Methods
  • __len__() Return the length of the object in number of bytes.
  • deserialize(reader) Deserialize the object from a binary stream.
  • deserialize_unsigned(reader) Deserialize the unsigned data part of the object from a binary stream.
  • fee_per_byte() (int) Calculates the network fee per byte.
  • get_hash_data(protocol_magic) (bytes) Get the unsigned data.
  • get_script_hashes_for_verifying(_) (list) Helper method to get the data used in verifying the object.
  • hash() (UInt256) Get a unique block identifier based on the unsigned data portion of the object.
  • serialize(writer) Serialize the object into a binary stream.
  • serialize_unsigned(writer) Serialize the unsigned part of the object into a binary stream.
  • to_array() (bytes) Serialize the object into a bytearray.
  • to_json() (dict) Convert object into JSON representation.
  • try_get_attribute(needle) (Optional) Helper method for finding an attribute of a specific type.
  • deserialize_from_bytes(data) (ISerializable_T) Parse data into an object instance.
  • from_json(json, procotol_magic) Create object from JSON.
classmethod

deserialize_from_bytes(data)

Parse data into an object instance.

Parameters
  • data (bytes | bytearray) hex escaped bytes.
Returns (ISerializable_T)

a deserialized instance of the class.

method

to_array() → bytes

Serialize the object into a bytearray.

method

__len__()

Return the length of the object in number of bytes.

method

deserialize(reader)

Deserialize the object from a binary stream.

Parameters
  • reader (BinaryReader) instance.
method

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
method

fee_per_byte() → int

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.

classmethod

from_json(json, procotol_magic=None)

Create object from JSON.

method

get_script_hashes_for_verifying(_) → list

Helper method to get the data used in verifying the object.

method

hash() → UInt256

Get a unique block identifier based on the unsigned data portion of the object.

method

serialize(writer)

Serialize the object into a binary stream.

Parameters
  • writer (BinaryWriter) instance.
method

serialize_unsigned(writer)

Serialize the unsigned part of the object into a binary stream.

Parameters
  • writer (BinaryWriter) instance.
method

to_json() → dict

Convert object into JSON representation.

method

try_get_attribute(needle)

Helper method for finding an attribute of a specific type.

Parameters
  • needle (Type) the type to search for
Returns (Optional)

The attribute matching the type if found. None otherwise.

method

get_hash_data(protocol_magic) → bytes

Get the unsigned data.

Parameters
  • protocol_magic (int) network protocol number (NEO MainNet = 860833102, Testnet (T5) = 894710606, private net = ?)
abstract class

neo3.network.payloads.transaction.TransactionAttribute()

Bases
neo3.core.serialization.ISerializable neo3.core.interfaces.IJson

Base class for attributes that can be attached to a Transaction.

Methods
  • __len__() Return the length of the object in number of bytes.
  • deserialize(reader) Deserialize the object from a binary stream.
  • serialize(writer) Serialize the object into a binary stream.
  • to_array() (bytes) Serialize the object into a bytearray.
  • to_json() (dict) Convert object into JSON representation.
  • deserialize_from_bytes(data) (ISerializable_T) Parse data into an object instance.
  • from_json(json) Create object from JSON.
  • deserialize_from(reader) (TransactionAttribute) Deserialize from a binary stream into a new TransactionAttribute.
classmethod

deserialize_from_bytes(data)

Parse data into an object instance.

Parameters
  • data (bytes | bytearray) hex escaped bytes.
Returns (ISerializable_T)

a deserialized instance of the class.

method

to_array() → bytes

Serialize the object into a bytearray.

method

__len__()

Return the length of the object in number of bytes.

method

deserialize(reader)

Deserialize the object from a binary stream.

Parameters
  • reader (BinaryReader) instance.
staticmethod

deserialize_from(reader) → TransactionAttribute

Deserialize from a binary stream into a new TransactionAttribute.

classmethod

from_json(json)

Create object from JSON.

method

serialize(writer)

Serialize the object into a binary stream.

Parameters
  • writer (BinaryWriter) instance.
method

to_json() → dict

Convert object into JSON representation.

enum

neo3.network.payloads.transaction.TransactionAttributeType()

Bases
enum.Enum

Various attributes that can be set by consensus committee members.

Members
  • HIGH_PRIORITY (int) 0x1
  • ORACLE_RESPONSE (int) 0x11
  • _INVALID (int) 0x9999