Skip to content
module

neo3.network.payloads.verification

Classes for managing transaction signers and signature scopes.

Classes
  • ConditionAnd Match all conditions.
  • ConditionBool Fixed value. Can be used to emulate GLOBAL scope.
  • ConditionCalledByContract Match hash against caller script hash.
  • ConditionCalledByEntry Match hash against entry script hash.
  • ConditionCalledByGroup Match key against the caller group.
  • ConditionGroup Match group against current script hash.
  • ConditionNot Invert condition.
  • ConditionOr Match any from a list of conditions.
  • ConditionScriptHash Match hash against another script hash.
  • IVerifiable(*args, **kwargs) Verifiable interface.
  • Signer A class that specifies the rules of who can pass CheckWitness() verifications in a smart contract.
  • Witness An executable verification script that validates a verifiable object like a transaction.
  • WitnessCondition() Base class for conditions.
  • WitnessRule A firewall like rule with an action to deny or allow if the condition matches. Gives fine-grained control overwhere the signature of the witness is valid inside the system.
class

neo3.network.payloads.verification.ConditionAnd(expressions)

Bases
neo3.network.payloads.verification.WitnessCondition neo3.core.serialization.ISerializable neo3.core.interfaces.IJson

Match all conditions.

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
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.
method

serialize(writer)

Serialize the object into a binary stream.

Parameters
  • writer (BinaryWriter) instance.
class

neo3.network.payloads.verification.ConditionBool(value)

Bases
neo3.network.payloads.verification.WitnessCondition neo3.core.serialization.ISerializable neo3.core.interfaces.IJson

Fixed value. Can be used to emulate GLOBAL scope.

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
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.
method

serialize(writer)

Serialize the object into a binary stream.

Parameters
  • writer (BinaryWriter) instance.
class

neo3.network.payloads.verification.ConditionCalledByContract(hash_)

Bases
neo3.network.payloads.verification.WitnessCondition neo3.core.serialization.ISerializable neo3.core.interfaces.IJson

Match hash against caller script hash.

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
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.
method

serialize(writer)

Serialize the object into a binary stream.

Parameters
  • writer (BinaryWriter) instance.
class

neo3.network.payloads.verification.ConditionCalledByEntry()

Bases
neo3.network.payloads.verification.WitnessCondition neo3.core.serialization.ISerializable neo3.core.interfaces.IJson

Match hash against entry script hash.

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
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.

classmethod

from_json(json)

Create object from JSON

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

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.verification.ConditionCalledByGroup(group)

Bases
neo3.network.payloads.verification.WitnessCondition neo3.core.serialization.ISerializable neo3.core.interfaces.IJson

Match key against the caller group.

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
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.
method

serialize(writer)

Serialize the object into a binary stream.

Parameters
  • writer (BinaryWriter) instance.
class

neo3.network.payloads.verification.ConditionGroup(group)

Bases
neo3.network.payloads.verification.ConditionCalledByGroup neo3.network.payloads.verification.WitnessCondition neo3.core.serialization.ISerializable neo3.core.interfaces.IJson

Match group against current script hash.

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
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.
method

serialize(writer)

Serialize the object into a binary stream.

Parameters
  • writer (BinaryWriter) instance.
class

neo3.network.payloads.verification.ConditionNot(expression)

Bases
neo3.network.payloads.verification.WitnessCondition neo3.core.serialization.ISerializable neo3.core.interfaces.IJson

Invert condition.

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
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.
method

serialize(writer)

Serialize the object into a binary stream.

Parameters
  • writer (BinaryWriter) instance.
class

neo3.network.payloads.verification.ConditionOr(expressions)

Bases
neo3.network.payloads.verification.WitnessCondition neo3.core.serialization.ISerializable neo3.core.interfaces.IJson

Match any from a list of conditions.

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
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.
method

serialize(writer)

Serialize the object into a binary stream.

Parameters
  • writer (BinaryWriter) instance.
class

neo3.network.payloads.verification.ConditionScriptHash(hash_)

Bases
neo3.network.payloads.verification.ConditionCalledByContract neo3.network.payloads.verification.WitnessCondition neo3.core.serialization.ISerializable neo3.core.interfaces.IJson

Match hash against another script hash.

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
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.
method

serialize(writer)

Serialize the object into a binary stream.

Parameters
  • writer (BinaryWriter) instance.
abstract class

neo3.network.payloads.verification.IVerifiable(*args, **kwargs)

Bases
neo3.core.serialization.ISerializable

Verifiable interface.

Methods
  • __len__() Return the length of the object in number of bytes.
  • deserialize(reader) Deserialize the object from a binary stream.
  • get_script_hashes_for_verifying(snapshot) (list) Helper method to get the data used in verifying the object.
  • serialize(writer) Serialize the object into a binary stream.
  • get_hash_data(protocol_magic) (bytes) Get the unsigned data.
  • to_array() (bytes) Serialize the object into a bytearray.
  • deserialize_from_bytes(data) (ISerializable_T) Parse data into an object instance.
abstract method

__len__()

Return the length of the object in number of bytes.

abstract method

deserialize(reader)

Deserialize the object from a binary stream.

Parameters
  • reader (BinaryReader) instance.
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.

abstract method

serialize(writer)

Serialize the object into a binary stream.

Parameters
  • writer (BinaryWriter) instance.
method

to_array() → bytes

Serialize the object into a bytearray.

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 method

get_script_hashes_for_verifying(snapshot) → list

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

class

neo3.network.payloads.verification.Signer(account, scope=<WitnessScope.CALLED_BY_ENTRY: 1>, allowed_contracts=None, allowed_groups=None, rules=None)

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

A class that specifies the rules of who can pass CheckWitness() verifications in a smart contract.

Attributes
  • account The TX sender.
  • allowed_contracts (list[types.UInt160]) Whitelist of contract script hashes if used with WitnessScope.CUSTOM_CONTRACTS.
  • allowed_groups (list[cryptography.ECPoint]) Whitelist of public keys if used with WitnessScope.CUSTOM_GROUPS.
  • rules List of rules that must pass for the current execution context when used with WitnessScope.WITNESS_RULES.
  • scope (WitnessScope) The configured validation scope.
Methods
  • get_all_rules() Return all witness rules.
  • __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.
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.
classmethod

from_json(json)

Create object from JSON.

generator

get_all_rules()

Return all witness rules.

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.verification.Witness(invocation_script, verification_script)

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

An executable verification script that validates a verifiable object like a transaction.

Attributes
  • invocation_script A set of VM instructions to set up the stack for verification.
  • verification_script It is expected to set the result stack to a boolean True if validation passed.
Methods
  • __len__() Return the length of the object in number of bytes.
  • deserialize(reader) Deserialize the object from a binary stream.
  • script_hash() (UInt160) Get the script hash based on the verification script.
  • 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
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.
classmethod

from_json(json)

Create object from JSON

method

script_hash() → UInt160

Get the script hash based on the verification script.

method

serialize(writer)

Serialize the object into a binary stream.

Parameters
  • writer (BinaryWriter) instance.
method

to_json() → dict

Convert object into JSON representation.

abstract class

neo3.network.payloads.verification.WitnessCondition()

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

Base class for conditions.

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
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.
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.verification.WitnessConditionType()

Bases
enum.IntEnum int enum.ReprEnum enum.Enum

Type of valid witness conditions.

Members
  • AND (int) 0x2
  • BOOLEAN (int) 0x0
  • CALLED_BY_CONTRACT (int) 0x28
  • CALLED_BY_ENTRY (int) 0x20
  • CALLED_BY_GROUP (int) 0x29
  • GROUP (int) 0x19
  • NOT (int) 0x1
  • OR (int) 0x3
  • SCRIPT_HASH (int) 0x18
class

neo3.network.payloads.verification.WitnessRule(action, condition)

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

A firewall like rule with an action to deny or allow if the condition matches. Gives fine-grained control overwhere the signature of the witness is valid inside the system.

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.
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.
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.verification.WitnessRuleAction()

Bases
enum.IntEnum int enum.ReprEnum enum.Enum

Witness rule execution.

Members
  • ALLOW (int) 0x1
  • DENY (int) 0x0
enum

neo3.network.payloads.verification.WitnessScope()

Bases
enum.IntFlag int enum.ReprEnum enum.Flag enum.Enum

Flags that determine where in the system the signature is valid. Used by CheckWitness() sys call.

Members
  • CALLED_BY_ENTRY (int) 0x1
  • CUSTOM_CONTRACTS (int) 0x10
  • CUSTOM_GROUPS (int) 0x20
  • GLOBAL (int) 0x80
  • NONE (int) 0x0
  • WITNESS_RULES (int) 0x40