Navigation

  • index
  • modules |
  • next |
  • previous |
  • neo-mamba documentation »
  • The neo-mamba Library »
  • Network »
  • Payloads »
  • transaction — All things Transaction related

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

None

classmethod deserialize_from_bytes(data)¶

Parse data into an object instance.

Parameters

data (Union[bytes, bytearray]) – hex escaped bytes.

Return type

~ISerializable_T

Returns

a deserialized instance of the class.

deserialize_special(reader)¶

Internal use only - deserialize the data from the stream into a TX that includes the unofficial fields

Return type

None

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

None

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

int

classmethod from_json(json, procotol_magic=None)¶

Create object from JSON

from_replica(replica)¶

Shallow copy attributes from a reference object.

Return type

None

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

Parameters

protocol_magic (int) – network protocol number (NEO MainNet = 5195086, Testnet = 1951352142, private net = ??)

Return type

bytes

get_script_hashes_for_verifying(_)¶

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

Return type

List[UInt160]

hash()¶

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

Return type

UInt256

serialize(writer)¶

Serialize the object into a binary stream.

Parameters

writer (BinaryWriter) – instance.

Return type

None

serialize_special(writer)¶

Internal use only - serialize the TX includes its unofficial fields

Return type

None

serialize_unsigned(writer)¶

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

Parameters

writer (BinaryWriter) – instance.

Return type

None

to_array()¶

Serialize the object into a bytearray.

Return type

bytes

to_json()¶

Convert object into json

Return type

dict

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.

Parameters

needle (Type[~TransactionAttribute_T]) – the type to search for

Return type

Optional[~TransactionAttribute_T]

Returns

The attribute matching the type if found. None otherwise.

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

InventoryType

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

UInt160

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

None

static deserialize_from(reader)¶

Deserialize from a binary stream into a new TransactionAttribute

Return type

TransactionAttribute

classmethod deserialize_from_bytes(data)¶

Parse data into an object instance.

Parameters

data (Union[bytes, bytearray]) – hex escaped bytes.

Return type

~ISerializable_T

Returns

a deserialized instance of the class.

classmethod from_json(json)¶

Create object from JSON

serialize(writer)¶

Serialize the object into a binary stream.

Parameters

writer (BinaryWriter) – instance.

Return type

None

to_array()¶

Serialize the object into a bytearray.

Return type

bytes

to_json()¶

Convert object into json

Return type

dict

verify(snapshot, tx)¶
Return type

bool

class neo3.network.payloads.transaction.TransactionAttributeType(value)¶

Bases: enum.Enum

An enumeration.

classmethod from_csharp_name(name)¶

Internal helper to parse from C# convention

to_csharp_name()¶

Internal helper to match C# convention

Return type

str

HIGH_PRIORITY = 1¶
ORACLE_RESPONSE = 17¶

Previous topic

ping — Share chain status

Next topic

verification — Validation of objects and smart contract invokers

This Page

  • Show Source

Quick search

Navigation

  • index
  • modules |
  • next |
  • previous |
  • neo-mamba documentation »
  • The neo-mamba Library »
  • Network »
  • Payloads »
  • transaction — All things Transaction related
© Copyright 2019-2021, COZ - Erik van den Brink. Created using Sphinx 3.5.2.