Supplier Interfaces API
The Supplier Interfaces API provides extensible interfaces for integrating custom data providers with the Cardano Client Library. These interfaces provide the essential APIs required to build and submit transactions, making them the quickest and clearest way to integrate any third-party data provider.
What are Supplier Interfaces?
Section titled “What are Supplier Interfaces?”Supplier interfaces provide the core functionality needed for transaction building and submission:
- Getting UTXOs - Retrieve unspent transaction outputs for addresses
- Fetching protocol parameters - Get current network protocol parameters
- Evaluating transaction script costs - Calculate execution costs for Plutus scripts
- Submitting transactions - Send transactions to the blockchain
Important: The transaction builder APIs depend on Supplier interfaces, not directly on BackendService. This provides the right level of abstraction to integrate any third-party provider with minimal effort.
Supplier Interfaces vs BackendService
Section titled “Supplier Interfaces vs BackendService”While BackendService provides many additional APIs useful for dApps (address history, asset metadata, block data, etc.), creating a new BackendService implementation requires significantly more effort. Supplier interfaces focus only on what’s strictly required for transaction building and submission, making integration faster and simpler.
Key Features
Section titled “Key Features”- Minimal Integration Surface: Only implement what’s needed for transactions
- Extensible Architecture: Define custom data provider implementations
- Interface Standardization: Consistent contracts for different data sources
- Provider Flexibility: Switch between implementations seamlessly
- Testing Support: Mock implementations for unit and integration testing
- Service Composition: Combine multiple suppliers for complex scenarios
Core Classes
Section titled “Core Classes”Supplier Interfaces
Section titled “Supplier Interfaces”UtxoSupplier- Provides UTXO data for addresses and transactionsProtocolParamsSupplier- Supplies current protocol parametersTransactionProcessor- Handles transaction submission and evaluationScriptSupplier- Provides Plutus scripts by hashTransactionEvaluator- Evaluates transaction execution costs
Default Implementations
Section titled “Default Implementations”The library provides default implementations that are automatically used when creating QuickTxBuilder from BackendService:
DefaultUtxoSupplier- Default UTXO supplier from BackendServiceDefaultProtocolParamsSupplier- Default protocol parameters from BackendServiceDefaultTransactionProcessor- Default transaction processor from BackendService
These are instantiated automatically when using:
QuickTxBuilder quickTxBuilder = new QuickTxBuilder(backendService);Third-Party Implementations
Section titled “Third-Party Implementations”For specialized use cases, third-party supplier implementations are available:
OgmiosProtocolParamSupplier- Ogmios-based protocol parametersOgmiosTransactionProcessor- Ogmios transaction processingKupoUtxoSupplier- Kupo-based UTXO providerOgmiosTransactionEvaluator- Ogmios script evaluation
Usage Examples
Section titled “Usage Examples”Custom UtxoSupplier Implementation
Section titled “Custom UtxoSupplier Implementation”Implement a custom UTXO supplier:
public class CustomUtxoSupplier implements UtxoSupplier {
@Override public List<Utxo> getPage(String address, Integer nrOfItems, Integer page, OrderEnum order) { // Implement UTXO fetching logic return fetchUtxosFromCustomSource(address, nrOfItems, page, order); }
@Override public Optional<Utxo> getTxOutput(String txHash, int outputIndex) { // Implement transaction output retrieval return fetchTransactionOutput(txHash, outputIndex); }
@Override public List<Utxo> getAll(String address) { // Fetch all UTXOs for address return fetchAllUtxosFromSource(address); }}Custom ProtocolParamsSupplier
Section titled “Custom ProtocolParamsSupplier”Implement protocol parameters supplier:
public class CustomProtocolParamsSupplier implements ProtocolParamsSupplier {
@Override public ProtocolParams getProtocolParams() { // Fetch current protocol parameters from your source return ProtocolParams.builder() .minFeeA(44) .minFeeB(155381) .maxBlockSize(65536) .maxTxSize(16384) .keyDeposit("2000000") .poolDeposit("500000000") .build(); }}Using Custom Suppliers
Section titled “Using Custom Suppliers”Integrate custom suppliers with QuickTx via constructor:
// Create custom suppliersUtxoSupplier customUtxoSupplier = new CustomUtxoSupplier();ProtocolParamsSupplier protocolParamsSupplier = new CustomProtocolParamsSupplier();TransactionProcessor transactionProcessor = new CustomTransactionProcessor();
// Use with QuickTx - suppliers must be provided through constructorQuickTxBuilder quickTxBuilder = new QuickTxBuilder( customUtxoSupplier, protocolParamsSupplier, transactionProcessor);
// Build and submit transactionTx tx = new Tx() .payToAddress(receiverAddress, Amount.ada(10)) .from(senderAddress);
Result<String> result = quickTxBuilder.compose(tx) .withSigner(SignerProviders.signerFrom(account)) .completeAndWait(System.out::println);Built-in Implementations
Section titled “Built-in Implementations”Ogmios Suppliers
Section titled “Ogmios Suppliers”Use Ogmios-based suppliers:
// Ogmios protocol parametersOgmiosProtocolParamSupplier ogmiosProtocolParams = new OgmiosProtocolParamSupplier("http://localhost:1337");
// Ogmios transaction processorOgmiosTransactionProcessor ogmiosProcessor = new OgmiosTransactionProcessor("http://localhost:1337");Kupo Suppliers
Section titled “Kupo Suppliers”Use Kupo for UTXO data combined with Ogmios for other services:
// Kupo UTXO supplierKupoUtxoSupplier kupoUtxoSupplier = new KupoUtxoSupplier("http://localhost:1442");
// Ogmios for protocol params and transaction processingOgmiosProtocolParamSupplier protocolParamsSupplier = new OgmiosProtocolParamSupplier("http://localhost:1337");OgmiosTransactionProcessor transactionProcessor = new OgmiosTransactionProcessor("http://localhost:1337");
// Use with QuickTx - all suppliers provided through constructorQuickTxBuilder builder = new QuickTxBuilder( kupoUtxoSupplier, protocolParamsSupplier, transactionProcessor);Combining with BackendService
Section titled “Combining with BackendService”You can also combine a custom supplier with BackendService:
// Use Kupo for UTXOs, BackendService for everything elseKupoUtxoSupplier kupoUtxoSupplier = new KupoUtxoSupplier("http://localhost:1442");BackendService backendService = new BFBackendService( Constants.BLOCKFROST_PREPROD_URL, "your-project-id");
QuickTxBuilder builder = new QuickTxBuilder(backendService, kupoUtxoSupplier);The Supplier Interfaces API provides extensible integration points for custom data providers and backend services.