nativecontract

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 CryptoLib

Bases: object

A class used to represent the CryptoLib native contract

hash: boa3.builtin.type.UInt160
classmethod murmur32(data: bytes, seed: int)bytes

Computes the hash value for the specified byte array using the murmur32 algorithm.

Parameters
  • data (bytes) – the input to compute the hash code for

  • seed (int) – the seed of the murmur32 hash function

Returns

the hash value

Return type

bytes

classmethod sha256(key: Any)bytes

Encrypts a key using SHA-256.

Parameters

key (Any) – the key to be encrypted

Returns

a byte value that represents the encrypted key

Return type

bytes

classmethod ripemd160(key: Any)bytes

Encrypts a key using RIPEMD-160.

Parameters

key (Any) – the key to be encrypted

Returns

a byte value that represents the encrypted key

Return type

bytes

classmethod verify_with_ecdsa(message: bytes, pubkey: boa3.builtin.type.ECPoint, signature: bytes, curve: boa3.internal.neo3.contracts.namedcurve.NamedCurve)bool

Using the elliptic curve, it checks if the signature of the message was originally produced by the public key.

Parameters
  • message (bytes) – the encrypted message

  • pubkey (ECPoint) – the public key that might have created the item

  • signature (bytes) – the signature of the item

  • curve (NamedCurve) – the curve that will be used by the ecdsa

Returns

a boolean value that represents whether the signature is valid

Return type

bool

class GAS

Bases: object

A class used to represent the GAS native contract

hash: boa3.builtin.type.UInt160
classmethod symbol()str

Gets the symbol of GAS.

Returns

the GAS string.

Return type

str

classmethod decimals()int

Gets the amount of decimals used by GAS.

Returns

the number 8.

Return type

int

classmethod totalSupply()int

Gets the total token supply deployed in the system.

Returns

the total token supply deployed in the system.

Return type

int

classmethod balanceOf(account: boa3.builtin.type.UInt160)int

Get the current balance of an address.

Parameters

account (UInt160) – the account’s address to retrieve the balance for

Returns

the account’s balance

Return type

int

classmethod transfer(from_address: boa3.builtin.type.UInt160, to_address: boa3.builtin.type.UInt160, amount: int, data: Optional[Any] = None)bool

Transfers an amount of GAS from one account to another

If the method succeeds, it will fire the Transfer event and must return true, even if the amount is 0, or from and to are the same address.

Parameters
  • from_address (UInt160) – the address to transfer from

  • to_address (UInt160) – the address to transfer to

  • amount (int) – the amount of GAS to transfer

  • data (Any) – whatever data is pertinent to the onNEP17Payment method

Returns

whether the transfer was successful

Return type

bool

Raises

Exception – raised if from_address or to_address length is not 20 or if amount is less than zero.

class Ledger

Bases: object

A class used to represent the Ledger native contract

hash: boa3.builtin.type.UInt160
classmethod get_block(index_or_hash: Union[int, boa3.builtin.type.UInt256])boa3.builtin.interop.blockchain.block.Block

Gets the block with the given index or hash.

Parameters

index_or_hash (int or UInt256) – index or hash identifier of the block

Returns

the desired block, if exists. None otherwise

Return type

Block or None

classmethod get_current_index()int

Gets the index of the current block.

Returns

the index of the current block

Return type

int

classmethod get_transaction(hash_: boa3.builtin.type.UInt256)boa3.builtin.interop.blockchain.transaction.Transaction

Gets a transaction with the given hash.

Parameters

hash (UInt256) – hash identifier of the transaction

Returns

the Transaction, if exists. None otherwise

classmethod get_transaction_from_block(block_hash_or_height: Union[boa3.builtin.type.UInt256, int], tx_index: int)boa3.builtin.interop.blockchain.transaction.Transaction

Gets a transaction from a block.

Parameters
  • block_hash_or_height (UInt256 or int) – a block identifier

  • tx_index (int) – the transaction identifier in the block

Returns

the Transaction, if exists. None otherwise

classmethod get_transaction_height(hash_: boa3.builtin.type.UInt256)int

Gets the height of a transaction.

Parameters

hash (UInt256) – hash identifier of the transaction

Returns

height of the transaction

classmethod get_transaction_signers(hash_: boa3.builtin.type.UInt256)List[boa3.builtin.interop.blockchain.signer.Signer]

Gets the VM state of a transaction.

Parameters

hash (UInt256) – hash identifier of the transaction

Returns

VM state of the transaction

classmethod get_transaction_vm_state(hash_: boa3.builtin.type.UInt256)boa3.internal.neo3.vm.vmstate.VMState

Gets the VM state of a transaction.

Parameters

hash (UInt256) – hash identifier of the transaction

Returns

VM state of the transaction

class NEO

Bases: object

A class used to represent the NEO native contract

hash: boa3.builtin.type.UInt160
classmethod symbol()str

Gets the symbol of NEO.

Returns

the NEO string.

Return type

str

classmethod decimals()int

Gets the amount of decimals used by NEO.

Returns

the number 8.

Return type

int

classmethod totalSupply()int

Gets the total token supply deployed in the system.

Returns

the total token supply deployed in the system.

Return type

int

classmethod balanceOf(account: boa3.builtin.type.UInt160)int

Get the current balance of an address.

Parameters

account (UInt160) – the account’s address to retrieve the balance for

Returns

the account’s balance

Return type

int

classmethod transfer(from_address: boa3.builtin.type.UInt160, to_address: boa3.builtin.type.UInt160, amount: int, data: Optional[Any] = None)bool

Transfers an amount of GAS from one account to another

If the method succeeds, it will fire the Transfer event and must return true, even if the amount is 0, or from and to are the same address.

Parameters
  • from_address (UInt160) – the address to transfer from

  • to_address (UInt160) – the address to transfer to

  • amount (int) – the amount of NEO to transfer

  • data (Any) – whatever data is pertinent to the onNEP17Payment method

Returns

whether the transfer was successful

Return type

bool

Raises

Exception – raised if from_address or to_address length is not 20 or if amount is less than zero.

classmethod get_gas_per_block()int

Gets the amount of GAS generated in each block.

Returns

the amount of GAS generated

Return type

int

classmethod unclaimed_gas(account: boa3.builtin.type.UInt160, end: int)int

Gets the amount of unclaimed GAS in the specified account.

Parameters
  • account (UInt160) – the account to check

  • end (int) – the block index used when calculating GAS

classmethod register_candidate(pubkey: boa3.builtin.type.ECPoint)bool

Registers as a candidate.

Parameters

pubkey (ECPoint) – The public key of the account to be registered

Returns

whether the registration was a success or not

Return type

bool

classmethod unregister_candidate(pubkey: boa3.builtin.type.ECPoint)bool

Unregisters as a candidate.

Parameters

pubkey (ECPoint) – The public key of the account to be unregistered

Returns

whether the unregistration was a success or not

Return type

bool

classmethod vote(account: boa3.builtin.type.UInt160, vote_to: boa3.builtin.type.ECPoint)bool

Votes for a candidate.

Parameters
  • account (UInt160) – the account that is voting

  • vote_to (ECPoint) – the public key of the one being voted

classmethod get_all_candidates()boa3.builtin.interop.iterator.Iterator

Gets the registered candidates iterator.

Returns

all registered candidates

Return type

Iterator

classmethod un_vote(account: boa3.builtin.type.UInt160)bool

Removes the vote of the candidate voted. It would be the same as calling vote(account, None).

Parameters

account (UInt160) – the account that is removing the vote

classmethod get_candidates()List[Tuple[boa3.builtin.type.ECPoint, int]]

Gets the list of all registered candidates.

Returns

all registered candidates

Return type

List[Tuple[ECPoint, int]]

classmethod get_candidate_vote(pubkey: boa3.builtin.type.ECPoint)int

Gets votes from specific candidate.

Returns

Votes or -1 if it was not found.

Return type

int

classmethod get_committee()List[boa3.builtin.type.ECPoint]

Gets all committee members list.

Returns

all committee members

Return type

List[ECPoint]

classmethod get_next_block_validators()List[boa3.builtin.type.ECPoint]

Gets validators list of the next block.

Returns

the public keys of the validators

Return type

List[ECPoint]

classmethod get_account_state(account: boa3.builtin.type.UInt160)boa3.builtin.contract.NeoAccountState

Gets the latest votes of the specified account.

Parameters

account (UInt160) – the specified account

Returns

the state of the account

Return type

NeoAccountState

class Oracle

Bases: object

Neo Oracle Service is an out-of-chain data access service built into Neo N3. It allows users to request the external data sources in smart contracts, and Oracle nodes designated by the committee will access the specified data source then pass the result in the callback function to continue executing the smart contract logic.

hash: boa3.builtin.type.UInt160
classmethod request(url: str, request_filter: Optional[str], callback: str, user_data: Any, gas_for_response: int)

Requests an information from outside the blockchain.

This method just requests data from the oracle, it won’t return the result.

Parameters
  • url (str) – External url to retrieve the data

  • request_filter (str or None) –

    Filter to the request.

    See JSONPath format https://github.com/atifaziz/JSONPath

  • callback (str) –

    Method name that will be as a callback.

    This method must be public and implement the following interface:

    (url: str, user_data: Any, code: int, result: bytes) -> None

  • user_data (Any) – Optional data. It’ll be returned as the same when the callback is called

  • gas_for_response (int) –

    Amount of GAS needed to run the callback method.

    It MUST NOT be specified as the user representation.

    If it costs 1 gas, this value must be 1_00000000 (with the 8 decimals)

classmethod get_price()int

Gets the price for an Oracle request.

Returns

the price for an Oracle request

class Policy

Bases: object

A class used to represent the Policy native contract

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

Gets the network fee per transaction byte.

Returns

the network fee per transaction byte

Return type

int

classmethod get_exec_fee_factor()int

Gets the execution fee factor. This is a multiplier that can be adjusted by the committee to adjust the system fees for transactions.

Returns

the execution fee factor

Return type

int

classmethod get_storage_price()int

Gets the storage price.

Returns

the snapshot used to read data

Return type

int

classmethod is_blocked(account: boa3.builtin.type.UInt160)bool

Determines whether the specified account is blocked.

Parameters

account (UInt160) – the account to be checked

Returns

whether the account is blocked or not

Return type

bool

class RoleManagement

Bases: object

A class used to represent the RoleManagement native contract

hash: boa3.builtin.type.UInt160
classmethod get_designated_by_role(role: boa3.internal.neo3.contracts.native.nativetypes.Role, index: int)boa3.builtin.type.ECPoint

Gets the list of nodes for the specified role.

Parameters
  • role (Role) – the type of the role

  • index (int) – the index of the block to be queried

Returns

the public keys of the nodes

Return type

ECPoint

class StdLib

Bases: object

A class used to represent StdLib native contract

hash: boa3.builtin.type.UInt160
classmethod serialize(item: Any)bytes

Serializes the given value into its bytes representation.

Parameters

item (Any) – value to be serialized

Returns

the serialized value

Return type

bytes

Raises

Exception – raised if the item’s type is not serializable.

classmethod deserialize(data: bytes)Any

Deserializes the given bytes value.

Parameters

data (bytes) – serialized value

Returns

the deserialized result

Return type

Any

Raises

Exception – raised when the date doesn’t represent a serialized value.

classmethod json_serialize(item: Any)str

Serializes an item into a json.

Parameters

item (Any) – The item that will be serialized

Returns

The serialized item

Return type

str

Raises

Exception – raised if the item is an integer value out of the Neo’s accepted range, is a dictionary with a bytearray key, or isn’t serializable.

classmethod json_deserialize(json: str)Any

Deserializes a json into some valid type.

Parameters

json (str) – A json that will be deserialized

Returns

The deserialized json

Return type

Any

Raises

Exception – raised if jsons deserialization is not valid.

classmethod base64_decode(key: str)bytes

Decodes a string value encoded with base64.

Parameters

key (str) – string value to be decoded

Returns

the decoded string

Return type

bytes

classmethod base64_encode(key: bytes)str

Encodes a bytes value using base64.

Parameters

key (bytes) – bytes value to be encoded

Returns

the encoded string

Return type

str

classmethod base58_decode(key: str)bytes

Decodes a string value encoded with base58.

Parameters

key (str) – string value to be decoded

Returns

the decoded bytes

Return type

bytes

classmethod base58_encode(key: bytes)str

Encodes a bytes value using base58.

Parameters

key (bytes) – bytes value to be encoded

Returns

the encoded string

Return type

str

classmethod base58_check_decode(key: str)bytes

Converts the specified str, which encodes binary data as base-58 digits, to an equivalent bytes value. The encoded str contains the checksum of the binary data.

Parameters

key (str) – string value to be decoded

Returns

the decoded bytes

Return type

bytes

classmethod base58_check_encode(key: bytes)str

Converts a bytes value to its equivalent str representation that is encoded with base-58 digits. The encoded str contains the checksum of the binary data.

Parameters

key (bytes) – bytes value to be encoded

Returns

the encoded string

Return type

str

classmethod itoa(value: int, base: int = 10)str

Converts the specific type of value to a decimal or hexadecimal string. The default is decimal.

Parameters
  • value (int) – the int value

  • base (int) – the value’s base

Returns

the converted string

Return type

int

classmethod atoi(value: str, base: int = 10)int

Converts a character string to a specific base value, decimal or hexadecimal. The default is decimal.

Parameters
  • value (str) – the int value as a string

  • base (int) – the value base

Returns

the equivalent value

Return type

int

Raises

Exception – raised when base isn’t 10 or 16.

classmethod memory_compare(mem1: Union[bytes, str], mem2: Union[bytes, str])int

Compares a memory with another one.

Parameters
  • mem1 (bytes or str) – a memory to be compared to another one

  • mem2 (bytes or str) – a memory that will be compared with another one

Returns

-1 if mem1 precedes mem2, 0 if mem1 and mem2 are equal, 1 if mem1 follows mem2

Return type

int

Searches for a given value in a given memory.

Parameters
  • mem (bytes or str) – the memory

  • value (bytes or str) – the value

  • start (int) – the index the search should start from

  • backward (bool) – whether it should invert the memory

Returns

the index of the value in the memory. Returns -1 if it’s not found

Return type

int