Unity3D

Unity3D

class Unity3D(**kwargs)

Implements the unity3dapi endpoints.

get_utxos_for_address(address: str | Address, **kwargs) GetUTXOModel

Gets UTXOs for specified address.

Parameters:
  • address (str, Address) – The address.

  • **kwargs – Extra keyword arguments.

Returns:

UTXOs for the specified address.

Return type:

GetUTXOModel

Raises:

APIError – Error thrown by node API. See message for details.

get_address_balance(address: str | Address, **kwargs) Money

Provides balance of the given address confirmed with at least 1 confirmation.

Parameters:
  • address (str, Address) – The address.

  • **kwargs – Extra keyword arguments.

Returns:

The amount in the address.

Return type:

Money

Raises:

APIError – Error thrown by node API. See message for details.

get_blockheader(block_hash: str | uint256, is_json_format: bool = True, **kwargs) BlockHeaderModel

Gets the specified block header.

Parameters:
  • block_hash (str, uint256) – The specified block hash.

  • is_json_format (bool, optional) – If block header should be returned as json. Default=True.

  • **kwargs – Extra keyword arguments.

Returns:

The block headers.

Return type:

BlockHeaderModel

Raises:

APIError – Error thrown by node API. See message for details.

get_raw_transaction(trxid: uint256 | str, verbose: bool = False, **kwargs) hexstr | TransactionModel

Gets a raw transaction from a transaction id.

Requires txindex=1 in node configuration.

Parameters:
  • trxid (uint256, str) – The transaction hash.

  • verbose (bool, optional) – If output should include verbose transaction data. Default=False.

  • **kwargs – Extra keyword arguments.

Returns:

A raw transaction.

Return type:

Union[hexstr, TransactionModel]

Raises:

APIError – Error thrown by node API. See message for details.

send_transaction(transaction_hex: str | hexstr, **kwargs) WalletSendTransactionModel

Sends a transaction that has already been built.

Parameters:
  • transaction_hex (hexstr, str) – The hexified transaction.

  • **kwargs – Extra keyword arguments.

Returns:

Information about a sent transaction.

Return type:

WalletSendTransactionModel

Raises:

APIError – Error thrown by node API. See message for details.

validate_address(address: str, **kwargs) ValidateAddressModel

Validate an address

Parameters:
  • address (str) – The address to validate.

  • **kwargs – Extra keyword arguments.

Returns:

Information on the validity of the provided address, and if valid, if it is a witness or script address.

Return type:

ValidateAddressModel

Raises:

APIError – Error thrown by node API. See message for details.

block(block_hash: uint256 | str, show_transaction_details: bool = True, output_json: bool = True, **kwargs) BlockModel | BlockTransactionDetailsModel | hexstr | str

Retrieves the block which matches the supplied block hash.

Parameters:
  • block_hash (uint256, str) – The hash of the required block.

  • show_transaction_details (bool, optional) – A flag that indicates whether to return each block transaction complete with details or simply return transaction hashes. Default=True.

  • output_json (bool) – Output json or hex block. Default=True.

  • **kwargs – Extra keyword arguments.

Returns:

The representation of the block.

Return type:

(BlockModel, BlockTransactionDetailsModel, hexstr, str)

Raises:

APIError – Error thrown by node API. See message for details.

addressindexer_tip(**kwargs) AddressIndexerTipModel

Retrieves the address indexer tip.

Parameters:

**kwargs – Extra keyword arguments.

Returns:

The address indexer tip hash and height.

Return type:

AddressIndexerTipModel

Raises:

APIError – Error thrown by node API. See message for details.

receipt(tx_hash: uint256 | str, **kwargs) ReceiptModel

Gets a smart contract transaction receipt.

Parameters:
  • tx_hash (uint256, str) – The transaction hash of the smart contract receipt.

  • **kwargs – Extra keyword arguments.

Returns:

The smart contract transaction receipt.

Return type:

ReceiptModel

Raises:

APIError – Error thrown by node API. See message for details.

local_call(contract_address: Address | str, method_name: str, amount: Money | int | float | Decimal, gas_price: int, gas_limit: int, sender: Address | str, block_height: int | None = None, parameters: List[str | SmartContractParameter] | None = None, **kwargs) LocalExecutionResultModel

Makes a local call to a method on a smart contract that has been successfully deployed. The purpose is to query and test methods.

Parameters:
  • contract_address (Address, str) – The smart contract address being called.

  • method_name (str) – The smart contract method being called.

  • amount (Money, int, float, Decimal) – The amount being sent.

  • gas_price (int) – The amount of gas being used in satoshis.

  • gas_limit (int) – The maximum amount of gas that can be used in satoshis.

  • sender (Address, str) – The address of the sending address.

  • block_height (int, optional) – The height at which to query the contract’s state. If unset, will default to the current chain tip.

  • parameters (List[Union[SmartContractParameter, str]], optional) – A list of parameters for the smart contract.

  • **kwargs – Extra keyword arguments.

Returns:

The results of a local contract execution.

Return type:

LocalExecutionResultModel

Raises:

APIError – Error thrown by node API. See message for details.

GetUTXOModel

class GetUTXOModel(*, balanceSat: Money, utxOs: List[UTXOModel], reason: str = None)

A pydantic model for the unity3d getuxtosforaddress endpoint.

balance: Money

The balance in Money units.

utxos: List[UTXOModel]

The list of utxos.

reason: str | None

The message, if failed.

UTXOModel

class UTXOModel(*, hash: uint256, n: int, satoshis: Money)

A pydantic model for a utxo.

tx_hash: uint256

The tx hash

n: int

The outpoint index.

amount: Money

The amount in Money units