Skip to main content

CardanoClient

Blockchain query layer interface.

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[]>
  isMainnet(): boolean
  now: number
  parameters: Promise<NetworkParams>
  submitTx(tx: Tx): Promise<TxId>
}

Properties

getTx

Optionally more efficient method of getting a whole Tx

cardanoClient.getTx satisfies (id: TxId) => Promise<Tx>

getUtxo

Returns a single TxInput (that might already have been spent).

cardanoClient.getUtxo satisfies (id: TxOutputId) => Promise<TxInput>

getUtxos

Returns a complete list of UTxOs at a given address.

cardanoClient.getUtxos satisfies (address: Address) => Promise<TxInput[]>

getUtxosWithAssetClass

Optionally more efficient method to get a complete list of UTxOs at a given address, filtered to contain a given AssetClass

cardanoClient.getUtxosWithAssetClass satisfies (
  address: Address,
  assetClass: AssetClass
) => Promise<TxInput[]>

isMainnet

Returns true for mainnet

cardanoClient.isMainnet satisfies () => boolean

now

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

cardanoClient.now satisfies number

parameters

Returns the latest network parameters.

cardanoClient.parameters satisfies Promise<NetworkParams>

submitTx

Submits a transaction to the blockchain and returns the id of that transaction upon success.

cardanoClient.submitTx satisfies (tx: Tx) => Promise<TxId>