Skip to main content

CardanoClientHelper

export interface CardanoClientHelper<C extends ReadonlyCardanoClient> {
  calcBalance(addr: Address): Promise<Value>
  client: C
  getUtxo<SC extends SpendingCredential = SpendingCredential>(
    id: TxOutputId,
    addr?: Address<SC>
  ): Promise<TxInput<SC>>
  getUtxos<SC extends SpendingCredential = SpendingCredential>(addr: Address<SC>): Promise<TxInput<SC>[]>
  getUtxosWithAssetClass<SC extends SpendingCredential = SpendingCredential>(
    addr: Address<SC>,
    assetClass: AssetClass
  ): Promise<TxInput<SC>[]>
  hasUtxo(id: TxOutputId): Promise<boolean>
  isMainnet(): boolean
  now: number
  options: CardanoClientHelperOptions
  parameters: Promise<NetworkParams>
  selectUtxo<SC extends SpendingCredential = SpendingCredential>(
    addr: Address<SC>,
    value: Value
  ): Promise<TxInput<SC>>
  selectUtxos<SC extends SpendingCredential = SpendingCredential>(
    addr: Address<SC>,
    value: Value,
    coinSelection?: CoinSelection<SC>
  ): Promise<TxInput<SC>[]>
  submitTx: C extends CardanoClient
    ? (tx: Tx) => Promise<TxId>
    : never
}

Properties

calcBalance

calcBalance(addr: Address): Promise<Value>

client

client: C

getUtxo

getUtxo<SC extends SpendingCredential = SpendingCredential>(
  id: TxOutputId,
  addr?: Address<SC>
): Promise<TxInput<SC>>

getUtxos

getUtxos<SC extends SpendingCredential = SpendingCredential>(addr: Address<SC>): Promise<TxInput<SC>[]>

getUtxosWithAssetClass

getUtxosWithAssetClass<SC extends SpendingCredential = SpendingCredential>(
  addr: Address<SC>,
  assetClass: AssetClass
): Promise<TxInput<SC>[]>

hasUtxo

hasUtxo(id: TxOutputId): Promise<boolean>

isMainnet

isMainnet(): boolean

now

now: number

options

options: CardanoClientHelperOptions

parameters

parameters: Promise<NetworkParams>

selectUtxo

selectUtxo<SC extends SpendingCredential = SpendingCredential>(
  addr: Address<SC>,
  value: Value
): Promise<TxInput<SC>>
This method is used to select very specific UTxOs that contain known tokens/NFTs If the UTxO isn't found that usually means something is wrong with the network synchronization The onSelectUtxoFail callback can be used to trigger a synchronization action if the UTxO isn' foun

selectUtxos

selectUtxos<SC extends SpendingCredential = SpendingCredential>(
  addr: Address<SC>,
  value: Value,
  coinSelection?: CoinSelection<SC>
): Promise<TxInput<SC>[]>
coinSelection defaults to selectSmallestFirst

submitTx

submitTx: C extends CardanoClient
  ? (tx: Tx) => Promise<TxId>
  : never
Only available if the underlying client isn't a ReadonlyCardanoClient