contract¶
- class CallFlags(value)¶
Bases:
enum.IntFlag
Defines special behaviors allowed when invoking smart contracts, e.g., chain calls, sending notifications and modifying states.
- NONE¶
Special behaviors of the invoked contract are not allowed, such as chain calls, sending notifications, modifying state, etc.
- READ_STATES¶
Indicates that the called contract is allowed to read states.
- WRITE_STATES¶
Indicates that the called contract is allowed to write states.
- ALLOW_CALL¶
Indicates that the called contract is allowed to call another contract.
- ALLOW_NOTIFY¶
Indicates that the called contract is allowed to send notifications.
- STATES¶
Indicates that the called contract is allowed to read or write states.
- READ_ONLY¶
Indicates that the called contract is allowed to read states or call another contract.
- ALL¶
All behaviors of the invoked contract are allowed.
- 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
- class ContractManifest¶
Bases:
object
Represents the manifest of a smart contract 1.
When a smart contract is deployed, it must explicitly declare the features and permissions it will use.
When it is running, it will be limited by its declared list of features and permissions, and cannot make any behavior beyond the scope of the list.
- 1
For more details, see NEP-15.
- Variables
name (str) – The name of the contract.
groups (List[ContractGroup]) – The groups of the contract.
supported_standards (List[str]) – Indicates which standards the contract supports. It can be a list of NEPs.
abi (ContractAbi) – The ABI of the contract.
permissions (List[ContractPermission]) – The permissions of the contract.
trusts (List[ContractPermissionDescriptor] or None) –
The trusted contracts and groups of the contract.
If a contract is trusted, the user interface will not give any warnings when called by the contract.
extras (str) – Custom user data as a json string.
- call_contract(script_hash: boa3.builtin.type.UInt160, method: str, args: Sequence = (), call_flags: boa3.internal.neo3.contracts.contracttypes.CallFlags = <CallFlags.ALL: 15>) → Any¶
Calls a smart contract given the method and the arguments.
- Parameters
- Returns
the result of the specified method
- Return type
Any
- Raises
Exception – raised if there isn’t a valid CallFlags, the script hash is not a valid smart contract or the method was not found or the arguments aren’t valid to the specified method.
- create_contract(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
- Returns
the contract that was created
- Return type
- Raises
Exception – raised if the nef or the manifest are not a valid smart contract.
- update_contract(nef_file: bytes, manifest: bytes, data: Optional[Any] = None)¶
Updates the executing smart contract given the script and the manifest.
- Parameters
- 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.
- destroy_contract()¶
Destroy the executing smart contract.
- get_minimum_deployment_fee() → int¶
Gets the minimum fee of contract deployment.
- Returns
the minimum fee of contract deployment
- get_call_flags() → boa3.internal.neo3.contracts.contracttypes.CallFlags¶
Gets the CallFlags in the current context.
- create_standard_account(pub_key: boa3.builtin.type.ECPoint) → boa3.builtin.type.UInt160¶
Calculates the script hash from a public key.
- create_multisig_account(m: int, pub_keys: List[boa3.builtin.type.ECPoint]) → boa3.builtin.type.UInt160¶
Calculates corresponding multisig account script hash for the given public keys.
- NEO: boa3.builtin.type.UInt160¶
NEO’s token script hash.
- GAS: boa3.builtin.type.UInt160¶
GAS’ token script hash.