contractmanagement

class ContractManagement

Bases: object

A class used to represent the ContractManagement native contract

hash: boa3.builtin.type.UInt160
classmethod get_minimum_deployment_fee()int

Gets the minimum fee of contract deployment.

Returns

the minimum fee of contract deployment

classmethod get_contract(script_hash: boa3.builtin.type.UInt160)boa3.builtin.interop.contract.contract.Contract

Gets a contract with a given hash.

Parameters

script_hash (UInt160) – a smart contract hash

Returns

a contract

Return type

Contract

Raises

Exception – raised if hash length isn’t 20 bytes.

classmethod has_method(hash: boa3.builtin.type.UInt160, method: str, parameter_count: int)bool

Check if a method exists in a contract.

Parameters
  • hash (UInt160) – The hash of the deployed contract

  • method (str) – The name of the method

  • parameter_count (int) – The number of parameters

Returns

whether the method exists or not

Return type

bool

Raises

Exception – raised if hash length isn’t 20 bytes or if the parameter_count is less than 0.

classmethod deploy(nef_file: bytes, manifest: bytes, data: Optional[Any] = None)boa3.builtin.interop.contract.contract.Contract

Creates a smart contract given the script and the manifest.

Parameters
  • nef_file (bytes) – the target smart contract’s compiled nef

  • manifest (bytes) – the manifest.json that describes how the script should behave

  • data (Any) – the parameters for the _deploy function

Returns

the contract that was created

Return type

Contract

Raises

Exception – raised if the nef or the manifest are not a valid smart contract.

classmethod update(nef_file: bytes, manifest: bytes, data: Optional[Any] = None)

Updates the executing smart contract given the script and the manifest.

Parameters
  • nef_file (bytes) – the new smart contract’s compiled nef

  • manifest (bytes) – the new smart contract’s manifest

  • data (Any) – the parameters for the _deploy function

Raises

Exception – raised if the nef and the manifest are not a valid smart contract or the new contract is the same as the old one.

classmethod destroy()

Destroy the executing smart contract.

class Contract

Bases: object

Represents a contract that can be invoked.

Variables
  • id (int) – the serial number of the contract

  • update_counter (int) – the number of times the contract was updated

  • hash (UInt160) – the hash of the contract

  • nef (bytes) – the serialized Neo Executable Format (NEF) object holding of the smart contract code and compiler information

  • manifest (ContractManifest) – the manifest of the contract