Skip to content
module

neo3.contracts.utils

Contract utilities for determing the contract hash, contract types, extracting public keys and signing treshold and more.

Functions
function

neo3.contracts.utils.create_multisig_redeemscript(m, public_keys) → bytes

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

This generated script is intended to be executed by the VM to indicate that the requested action is allowed.

Parameters
  • m () minimum number of signature required for signing. Can't be lower than 2.
  • public_keys (sequence of ECPoint) public keys to use during verification.
Raises
  • ValueError if the minimum required signatures is not met.
  • ValueError if the maximum allowed signatures is exceeded.
  • ValueError if the maximum allowed public keys is exceeded.
function

neo3.contracts.utils.create_signature_redeemscript(public_key) → bytes

Create a single signature redeem script.

This generated script is intended to be executed by the VM to indicate that the requested action is allowed.

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

neo3.contracts.utils.get_contract_hash(sender, nef_checksum, contract_name)

Return the calculated contract hash.

Parameters
  • sender () script hash of account that deployed the contract.
  • nef_checksum () checksum of the contract's NEF file.
  • contract_name () the name from the contract's manifest.
Returns (UInt160)

a unique contract identifier.

function

neo3.contracts.utils.is_multisig_contract(script) → bool

Test if the provided script is a multi-signature contract.

Parameters
  • script () contract script.
function

neo3.contracts.utils.is_signature_contract(script) → bool

Test if the provided script is a (single) signature contract.

Parameters
  • script () contract script.
function

neo3.contracts.utils.parse_as_multisig_contract(script)

Try to parse script as multisig contract and extract related data.

Parameters
  • script () array of vm byte code.
Returns (bool)

True if the script passes as a valid multisignature contract script. False otherwise.int: the signing threshold if validation passed. 0 otherwise. list[ECPoint]: the public keys in the script if valiation passed. An empty array otherwise.

function

neo3.contracts.utils.validate_type(obj, type_)

Helper function to validate ABI type information.

Parameters
  • obj () target object.
  • type_ expected type
Raises
  • ValueError if types do not match.