Skip to main content
Module

x/lucid/mod.ts>Tx

Lucid is a library, which allows you to create Cardano transactions and off-chain code for your Plutus contracts in JavaScript, Deno and Node.js.
Very Popular
Go to Latest
class Tx
Re-export
import { Tx } from "https://deno.land/x/lucid@0.5.3/mod.ts";

Constructors

new
Tx(lucid: Lucid)

Properties

private
lucid: Lucid
private
nftMetadata: NFTMetadata
private
tasks: (() => Promise<void>)[]

Methods

Needs to be a public key address

The PaymentKeyHash is taken when providing a Base, Enterprise or Pointer address

The StakeKeyHash is taken when providing a Reward address

Add a payment or stake key hash as a required signer of the transaction.

applyIf(condition: boolean, callback: (thisTx: Tx) => void | Promise<void>)

Conditionally add to the transaction

attachMetadata(label: Label, metadata: Json)

Converts strings to bytes if prefixed with '0x'

Converts strings to bytes if prefixed with '0x'

Uses version 2 of CIP-0025

You don't need to add policy id and asset name to the metadata, only add the details

collectFrom(utxos: UTxO[], redeemer?: Redeemer)

A public key or native script input

With redeemer a plutus script input

complete(option?: { changeAddress?: Address; datum?: { asHash?: Datum; inline?: Datum; }; })
delegateTo(
rewardAddress: RewardAddress,
poolId: PoolId,
redeemer?: Redeemer,
)

Delegate to a stake pool

deregisterStake(rewardAddress: RewardAddress, redeemer?: Redeemer)
mintAssets(assets: Assets, redeemer?: Redeemer)

All assets should be of the same Policy Id.

You can chain mintAssets events together if you need to mint assets with different Policy Ids.

If the plutus script doesn't need a redeemer, you still neeed to specifiy the empty redeemer.

payToAddress(address: Address, assets: Assets)

Pay to a public key or native script address

payToAddressWithData(
address: Address,
outputData: Datum | OutputData,
assets: Assets,
)

Pay to a public key or native script address with datum or scriptRef

payToContract(
address: Address,
outputData: Datum | OutputData,
assets: Assets,
)

Pay to a plutus script address with datum or scriptRef

readFrom(utxos: UTxO[])

Read data from utxos. These utxos are only referenced and not spent

validFrom(unixTime: UnixTime)
validTo(unixTime: UnixTime)
withdraw(
rewardAddress: RewardAddress,
amount: Lovelace,
redeemer?: Redeemer,
)