nativecontract¶
- class ContractManagement¶
Bases:
object
A class used to represent the ContractManagement native contract
- 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.
- classmethod has_method(hash: boa3.builtin.type.UInt160, method: str, parameter_count: int) → bool¶
Check if a method exists in a contract.
- Parameters
- Returns
whether the method exists or not
- Return type
- 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
- Returns
the contract that was created
- Return type
- 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
- 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
- classmethod murmur32(data: bytes, seed: int) → bytes¶
Computes the hash value for the specified byte array using the murmur32 algorithm.
- 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
- 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
- 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
- class GAS¶
Bases:
object
A class used to represent the GAS native contract
- classmethod decimals() → int¶
Gets the amount of decimals used by GAS.
- Returns
the number 8.
- Return type
- classmethod totalSupply() → int¶
Gets the total token supply deployed in the system.
- Returns
the total token supply deployed in the system.
- Return type
- classmethod balanceOf(account: boa3.builtin.type.UInt160) → int¶
Get the current balance of an address.
- 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
- Returns
whether the transfer was successful
- Return type
- 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
- 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.
- classmethod get_current_index() → int¶
Gets the index of the current block.
- Returns
the index of the current block
- Return type
- 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.
- 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
- classmethod decimals() → int¶
Gets the amount of decimals used by NEO.
- Returns
the number 8.
- Return type
- classmethod totalSupply() → int¶
Gets the total token supply deployed in the system.
- Returns
the total token supply deployed in the system.
- Return type
- classmethod balanceOf(account: boa3.builtin.type.UInt160) → int¶
Get the current balance of an address.
- 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
- Returns
whether the transfer was successful
- Return type
- 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
- classmethod unclaimed_gas(account: boa3.builtin.type.UInt160, end: int) → int¶
Gets the amount of unclaimed GAS in the specified account.
- classmethod register_candidate(pubkey: boa3.builtin.type.ECPoint) → bool¶
Registers as a candidate.
- classmethod unregister_candidate(pubkey: boa3.builtin.type.ECPoint) → bool¶
Unregisters as a candidate.
- classmethod vote(account: boa3.builtin.type.UInt160, vote_to: boa3.builtin.type.ECPoint) → bool¶
Votes for a candidate.
- classmethod get_all_candidates() → boa3.builtin.interop.iterator.Iterator¶
Gets the registered candidates iterator.
- Returns
all registered candidates
- Return type
- 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.
- 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
- 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
- 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.
- 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)
- class Policy¶
Bases:
object
A class used to represent the Policy native contract
- classmethod get_fee_per_byte() → int¶
Gets the network fee per transaction byte.
- Returns
the network fee per transaction byte
- Return type
- 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
- classmethod get_storage_price() → int¶
Gets the storage price.
- Returns
the snapshot used to read data
- Return type
- classmethod is_blocked(account: boa3.builtin.type.UInt160) → bool¶
Determines whether the specified account is blocked.
- class RoleManagement¶
Bases:
object
A class used to represent the RoleManagement native contract
- 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.
- class StdLib¶
Bases:
object
A class used to represent StdLib native contract
- 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.
- 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.
- classmethod itoa(value: int, base: int = 10) → str¶
Converts the specific type of value to a decimal or hexadecimal string. The default is decimal.
- classmethod atoi(value: str, base: int = 10) → int¶
Converts a character string to a specific base value, decimal or hexadecimal. The default is decimal.
- classmethod memory_compare(mem1: Union[bytes, str], mem2: Union[bytes, str]) → int¶
Compares a memory with another one.