Provider

class cometa.providers.provider.ProviderProtocol(*args, **kwargs)[source]

Bases: Protocol

Protocol defining the interface for Cardano blockchain data providers.

Providers are responsible for interacting with the Cardano blockchain to: - Fetch protocol parameters - Query UTXOs for addresses - Resolve datums - Submit and confirm transactions - Evaluate Plutus script execution

Implement this protocol to create custom providers (e.g., Blockfrost, Koios, etc.).

get_name()[source]

Get the human-readable name of this provider.

Returns:

The provider name (e.g., “Blockfrost”, “Koios”).

Return type:

str

get_network_magic()[source]

Get the network magic number this provider is connected to.

Returns:

The network magic (e.g., 764824073 for mainnet).

Return type:

int

get_parameters()[source]

Retrieve the current protocol parameters from the blockchain.

Returns:

The current ProtocolParameters.

Raises:

Exception – If the request fails.

Return type:

ProtocolParameters

get_unspent_outputs(address)[source]

Get all unspent transaction outputs (UTXOs) for an address.

Parameters:

address (Union['Address', str]) – The payment address to query.

Returns:

A list of Utxo objects.

Raises:

Exception – If the request fails.

Return type:

List[‘Utxo’]

get_rewards_balance(reward_account)[source]

Get the current staking rewards balance for a reward account.

Parameters:

reward_account (Union['RewardAddress', str]) – The reward address to query.

Returns:

The rewards balance in lovelace.

Raises:

Exception – If the request fails.

Return type:

int

get_unspent_outputs_with_asset(address, asset_id)[source]

Get UTXOs for an address that contain a specific asset.

Parameters:
  • address (Union['Address', str]) – The payment address to query.

  • asset_id (Union['AssetId', str]) – The asset identifier to filter by.

Returns:

A list of Utxo objects containing the asset.

Raises:

Exception – If the request fails.

Return type:

List[‘Utxo’]

get_unspent_output_by_nft(asset_id)[source]

Get the UTXO containing a specific NFT.

Parameters:

asset_id (Union['AssetId', str]) – The NFT asset identifier.

Returns:

The Utxo containing the NFT.

Raises:

Exception – If the NFT is not found or held by multiple UTXOs.

Return type:

Utxo

resolve_unspent_outputs(tx_ins)[source]

Resolve transaction inputs to their corresponding UTXOs.

Parameters:

tx_ins (Union['TransactionInputSet', List['TransactionInput']]) – The transaction inputs to resolve.

Returns:

A list of resolved Utxo objects.

Raises:

Exception – If resolution fails.

Return type:

List[‘Utxo’]

resolve_datum(datum_hash)[source]

Resolve a datum by its hash.

Parameters:

datum_hash (Union['Blake2bHash', str]) – The hash of the datum to resolve.

Returns:

The CBOR-encoded datum as a hex string.

Raises:

Exception – If the datum is not found.

Return type:

str

confirm_transaction(tx_id, timeout_ms=None)[source]

Wait for a transaction to be confirmed on-chain.

Parameters:
  • tx_id (str) – The transaction ID (hex string).

  • timeout_ms (int | None) – Optional timeout in milliseconds.

Returns:

True if confirmed, False if timeout reached.

Raises:

Exception – If confirmation check fails.

Return type:

bool

submit_transaction(tx_cbor_hex)[source]

Submit a signed transaction to the blockchain.

Parameters:

tx_cbor_hex (str) – The CBOR-encoded transaction as a hex string.

Returns:

The transaction ID (hex string) of the submitted transaction.

Raises:

Exception – If submission fails.

Return type:

str

evaluate_transaction(tx_cbor_hex, additional_utxos=None)[source]

Evaluate a transaction to get execution units for Plutus scripts.

Parameters:
  • tx_cbor_hex (str) – The CBOR-encoded transaction as a hex string.

  • additional_utxos (Union['UtxoList', List['Utxo']] | None) – Optional additional UTXOs for evaluation.

Returns:

A list of Redeemer objects with computed execution units.

Raises:

Exception – If evaluation fails.

Return type:

List[‘Redeemer’]

__init__(*args, **kwargs)
cometa.providers.provider.Provider

alias of ProviderProtocol