BlockfrostProvider

scalus.cardano.node.BlockfrostProvider
See theBlockfrostProvider companion object
class BlockfrostProvider(apiKey: String, baseUrl: String, maxConcurrentRequests: Int, initialCardanoInfo: CardanoInfo)(using backend: Backend[Future], ec: ExecutionContext) extends BlockchainProvider

Blockfrost-based Provider for Cardano blockchain operations.

Use the async factory methods in the companion object to create instances: BlockfrostProvider.preview(apiKey), BlockfrostProvider.mainnet(apiKey), etc. These fetch protocol parameters during construction so that cardanoInfo is immediately available.

Value parameters

apiKey

Blockfrost API key

baseUrl

Blockfrost API base URL

initialCardanoInfo

CardanoInfo with protocol parameters (fetched during async construction)

maxConcurrentRequests

Maximum concurrent HTTP requests

Attributes

Companion
object
Graph
Supertypes
trait BlockchainProviderTF[Future]
trait BlockchainReaderTF[Future]
class Object
trait Matchable
class Any
Show all

Members list

Value members

Concrete methods

override def cardanoInfo: CardanoInfo

Returns CardanoInfo for this reader.

Returns CardanoInfo for this reader.

This is always available synchronously after the reader is constructed. For emulators, this returns the current context. For remote providers like BlockfrostProvider, the CardanoInfo is fetched during async construction.

Attributes

Definition Classes
def currentSlot: Future[SlotNo]

Returns the current slot number.

Returns the current slot number.

Attributes

override def executionContext: ExecutionContext

Returns the ExecutionContext captured by this reader.

Returns the ExecutionContext captured by this reader.

This is used internally by default method implementations. External code can use this when working with Futures returned by reader methods, or provide their own.

Attributes

Definition Classes

Fetches the latest protocol parameters from the network.

Fetches the latest protocol parameters from the network.

Attributes

def fetchParamsOfEpoch(epoch: Long): Future[ProtocolParams]
override def findUtxos(query: UtxoQuery): Future[Either[UtxoQueryError, Utxos]]

Find UTxOs using a type-safe query.

Find UTxOs using a type-safe query.

Value parameters

query

The query specifying source, filters, and pagination

Attributes

Returns

Either a UtxoQueryError or the matching UTxOs

Definition Classes

Force refresh of cached CardanoInfo from the network.

Force refresh of cached CardanoInfo from the network.

Fetches latest protocol parameters and updates the internal cache. Use this for long-running applications that need to stay current with network changes.

Attributes

override def submit(tx: Transaction): Future[Either[SubmitError, TransactionHash]]

Submits a transaction to the network.

Submits a transaction to the network.

Attributes

Definition Classes

Inherited methods

def findUtxo(input: TransactionInput): Future[Either[UtxoQueryError, Utxo]]

Find a single UTxO by its transaction input.

Find a single UTxO by its transaction input.

Value parameters

input

the transaction input to look up

Attributes

Returns

Either a UtxoQueryError or the found Utxo

Inherited from:
BlockchainReader
def findUtxos(address: Address): Future[Either[UtxoQueryError, Utxos]]

Find all UTxOs at the given address.

Find all UTxOs at the given address.

Value parameters

address

the address to query

Attributes

Returns

Either a UtxoQueryError or the found UTxOs

Inherited from:
BlockchainReader
def findUtxos(inputs: Set[TransactionInput]): Future[Either[UtxoQueryError, Utxos]]

Find UTxOs by a set of transaction inputs.

Find UTxOs by a set of transaction inputs.

Value parameters

inputs

the transaction inputs to look up

Attributes

Returns

Either a UtxoQueryError or the found UTxOs (fails if not all inputs are found)

Inherited from:
BlockchainReader
inline def queryUtxos(inline f: Utxo => Boolean): UtxoQueryWithReader

Query UTxOs using lambda DSL.

Query UTxOs using lambda DSL.

This method translates a lambda expression to a UtxoQuery at compile time and returns a builder that can be further configured before execution.

Example:

// Simple query - execute immediately
reader.queryUtxos { u =>
 u.output.address == myAddress
}.execute()

// With pagination and minimum total
reader.queryUtxos { u =>
 u.output.address == myAddress && u.output.value.hasAsset(policyId, assetName)
}.minTotal(Coin.ada(100)).limit(10).execute()

Supported expressions:

  • u.output.address == addr - query by address
  • u.input.transactionId == txId - query by transaction
  • u.output.value.hasAsset(policyId, assetName) - query/filter by asset
  • u.output.value.coin >= amount - filter by minimum lovelace
  • u.output.hasDatumHash(hash) - filter by datum hash
  • && - AND combination
  • || - OR combination

Value parameters

f

Lambda expression from Utxo to Boolean

Attributes

Returns

A UtxoQueryWithReader builder that can be configured and executed

Inherited from:
BlockchainReader

Deprecated and Inherited methods

def findUtxo(address: Address, transactionId: Option[TransactionHash] = ..., datum: Option[DatumOption] = ..., minAmount: Option[Coin] = ...): Future[Either[UtxoQueryError, Utxo]]

Find a single UTxO by address and optional filters.

Find a single UTxO by address and optional filters.

Attributes

Deprecated
[Since version 0.14.2] Use findUtxos(UtxoQuery) instead

Use findUtxos(UtxoQuery) instead

Inherited from:
BlockchainProvider
def findUtxos(address: Address, transactionId: Option[TransactionHash] = ..., datum: Option[DatumOption] = ..., minAmount: Option[Coin] = ..., minRequiredTotalAmount: Option[Coin] = ...): Future[Either[UtxoQueryError, Utxos]]

Find UTxOs by address and optional filters.

Find UTxOs by address and optional filters.

Attributes

Deprecated
[Since version 0.14.2] Use findUtxos(UtxoQuery) instead

Use findUtxos(UtxoQuery) instead

Inherited from:
BlockchainProvider