boa3.builtin package

Event(*args, **kwargs)

Describes an action that happened in the blockchain.

CreateNewEvent(arguments: List[Tuple[str, type]] = [], event_name: str = '') Event

Creates a new event.

Parameters
  • arguments (List[Tuple[str, type]]) – the list of the events args’ names and types

  • event_name (str) – custom name of the event. It’s filled with the variable name if not specified

Returns

the new event

Return type

Event

public(name: Optional[str] = None, safe: bool = True, *args, **kwargs)

This decorator identifies which methods should be included in the abi file.

Parameters
  • name (str) – Identifier for this method that’ll be used on the abi. If not specified, it’ll be the same identifier from Python method definition

  • safe (bool) – Whether this method is an abi safe method. False by default

metadata(*args)

This decorator identifies the function that returns the metadata object of the smart contract. This can be used to only one function. Using this decorator in multiple functions will raise a compiler error.

contract(script_hash: ByteString)

This decorator identifies a class that should be interpreted as an interface to an existing contract.

Parameters

script_hash (str or bytes) – Script hash of the interfaced contract

display_name(name: str)

This decorator identifies which methods from a contract interface should have a different identifier from the one interfacing it. It only works in contract interface classes.

Parameters

name (str) – Method identifier from the contract manifest.

to_script_hash(data_bytes: Any) bytes

Converts a data to a script hash.

Parameters

data_bytes (Any) – data to hash

Returns

the script hash of the data

Return type

bytes

class NeoMetadata

Bases: object

This class stores the smart contract manifest information.

Variables
  • name – the smart contract name. Will be the name of the file by default;

  • supported_standards (List[str]) – Neo standards supported by this smart contract. Empty by default;

  • permissions (List[str]) – a list of contracts and methods that this smart contract permits to invoke and call. All contracts and methods permitted by default;

  • trusts (List[str]) – a list of contracts that this smart contract trust. Empty by default;

  • author (str or None) – the smart contract author. None by default;

  • email (str or None) – the smart contract author email. None by default;

  • description (str or None) – the smart contract description. None by default;

property extras: Dict[str, Any]

Gets the metadata extra information.

Returns

a dictionary that maps each extra value with its name. Empty by default

add_trusted_source(hash_or_address: str)

Adds a valid contract hash, valid group public key, or the ‘*’ wildcard to trusts.

Parameters

hash_or_address (str) – a contract hash, group public key or ‘*’

add_group(pub_key: str, signature: str)

Adds a pair of public key and signature to the groups in the manifest.

Parameters
  • pub_key (str) – public key of the group

  • signature (str) – signature of the contract hash encoded in Base64

add_permission(*, contract: str = '*', methods: Union[List[str], str] = '*')

Adds a valid contract and a valid methods to the permissions in the manifest.

Parameters
  • contract (str) – a contract hash, group public key or ‘*’

  • methods (Union[List[str], str]) – a list of methods or ‘*’

static _verify_is_valid_public_key(public_key: str) bool

Verifies if a given compressed public key is valid.

Returns

whether the given public key is valid or not

static _verify_is_valid_contract_hash(contract_hash: str) bool

Verifies if a given contract hash is valid.

Returns

whether the given contract hash is valid or not

Modules: