blockchain

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

Gets a contract with a given hash.

Parameters

hash (UInt160) – a smart contract hash

Returns

a contract

Return type

Contract

Raises

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

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

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

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

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

current_hash: boa3.builtin.type.UInt256

Gets the hash of the current block.

current_index: int

Gets the index of the current block.

Block

class Block

Bases: object

Represents a block.

Variables
  • hash (UInt256) – a unique identifier based on the unsigned data portion of the object

  • version (int) – the data structure version of the block

  • previous_hash (UInt256) – the hash of the previous block

  • merkle_root (UInt256) – the merkle root of the transactions

  • timestamp (int) – UTC timestamp of the block in milliseconds

  • nonce (int) – a random number used once in the cryptography

  • index (int) – the index of the block

  • primary_index (int) – the primary index of the consensus node that generated this block

  • next_consensus (UInt160) – the script hash of the consensus nodes that generates the next block

  • transaction_count (int) – the number of transactions on this block

Transaction

class Transaction

Bases: object

Represents a transaction.

Variables
  • hash (UInt256) – a unique identifier based on the unsigned data portion of the object

  • version (int) – the data structure version of the transaction

  • nonce (int) – a random number used once in the cryptography

  • sender (UInt160) – the sender is the first signer of the transaction, they will pay the fees of the transaction

  • system_fee (int) – the fee paid for executing the script

  • network_fee (int) – the fee paid for the validation and inclusion of the transaction in a block by the consensus node

  • valid_until_block (int) – indicates that the transaction is only valid before this block height

  • script (bytes) – the array of instructions to be executed on the transaction chain by the virtual machine