Skip to main content

CardanoClient

export interface CardanoClient {
  getTx?: (id: TxId) => Promise<Tx>
  getUtxo(id: TxOutputId): Promise<TxInput>
  getUtxos(address: Address): Promise<TxInput[]>
  getUtxosWithAssetClass?: (
    address: Address,
    assetClass: AssetClass
  ) => Promise<TxInput[]>
  hasUtxo(utxoId: TxOutputId): Promise<boolean>
  isMainnet(): boolean
  now: number
  parameters: Promise<NetworkParams>
  submitTx(tx: Tx): Promise<TxId>
}
Blockchain query layer interface.

Properties

getTx

getTx?: (id: TxId) => Promise<Tx>
Optionally more efficient method of getting a whole Tx

getUtxo

getUtxo(id: TxOutputId): Promise<TxInput>
Returns a single TxInput (that might already have been spent).

getUtxos

getUtxos(address: Address): Promise<TxInput[]>
Returns a complete list of UTxOs at a given address.

getUtxosWithAssetClass

getUtxosWithAssetClass?: (
  address: Address,
  assetClass: AssetClass
) => Promise<TxInput[]>
Optionally more efficient method to get a complete list of UTxOs at a given address, filtered to contain a given AssetClass

hasUtxo

hasUtxo(utxoId: TxOutputId): Promise<boolean>
indicates whether the underlying network is known to have the UTxO

isMainnet

isMainnet(): boolean
Returns true for mainnet

now

now: number
Returns the number of ms since some reference (for mainnet -> since 1970, for emulator -> arbitrary reference)

parameters

parameters: Promise<NetworkParams>
Returns the latest network parameters.

submitTx

submitTx(tx: Tx): Promise<TxId>
Submits a transaction to the blockchain and returns the id of that transaction upon success.