Skip to content
module

neo3.contracts.contract

Smart contract and account contract classes. Contains a list of all native contracts.

Attributes
  • CONTRACT_HASHES List of Neo's native contract hashes.
Classes
class

neo3.contracts.contract.Contract(script, parameter_list)

Generic contract.

Attributes
  • script The contract instructions (OpCodes)
  • script_hash (UInt160) The contract script hash.
Methods
classmethod

create_multisig_contract(m, public_keys) → Contract

Create a multi-signature contract requiring m signatures from the list public_keys.

Parameters
  • m (int) minimum number of signature required for signing. Can't be lower than 2.
  • public_keys (Sequence) public keys to use during verification.
classmethod

create_signature_contract(public_key) → Contract

Create a signature contract.

Parameters
  • public_key (ECPoint) the public key to use during verification.
class

neo3.contracts.contract.ContractState(id_, nef, manifest_, update_counter, hash_)

Bases
neo3.core.serialization.ISerializable

Smart contract chain state container.

Attributes
  • script (bytes) NEF script
Methods
  • __len__() Return the length of the object in number of bytes.
  • can_call(target_contract, target_method) (bool) Utility function to check if the contract has permission to call target_method on target_contract.
  • 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.
  • deserialize_from_bytes(data) (ISerializable_T) Parse data into an object instance.
method

__len__()

Return the length of the object in number of bytes.

method

can_call(target_contract, target_method)

Utility function to check if the contract has permission to call target_method on target_contract.

Returns (bool)

True if allowed. False if not possible.

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