Skip to main content


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
import { Tx } from "";


Tx(lucid: Lucid)


lucid: Lucid
tasks: ((that: Tx) => unknown)[]

Stores the tx instructions, which get executed after calling .complete()

txBuilder: C.TransactionBuilder


addNetworkId(id: number): Tx

Explicitely set the network id in the transaction body.

addSigner(address: Address | RewardAddress): Tx

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.

addSignerKey(keyHash: PaymentKeyHash | StakeKeyHash): Tx

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

attachCertificateValidator(certValidator: CertificateValidator): Tx
attachMetadata(label: Label, metadata: Json): Tx
attachMetadataWithConversion(label: Label, metadata: Json): Tx

Converts strings to bytes if prefixed with '0x'.

attachMintingPolicy(mintingPolicy: MintingPolicy): Tx
attachSpendingValidator(spendingValidator: SpendingValidator): Tx
attachWithdrawalValidator(withdrawalValidator: WithdrawalValidator): Tx
collectFrom(utxos: UTxO[], redeemer?: Redeemer): Tx

A public key or native script input. With redeemer it's a plutus script input.

complete(options?: { change?: { address?: Address; outputData?: OutputData; }; coinSelection?: boolean; nativeUplc?: boolean; }): Promise<TxComplete>
compose(tx: Tx | null): Tx

Compose transactions.

rewardAddress: RewardAddress,
poolId: PoolId,
redeemer?: Redeemer,
): Tx

Delegate to a stake pool.

deregisterStake(rewardAddress: RewardAddress, redeemer?: Redeemer): Tx

Deregister a reward address.

mintAssets(assets: Assets, redeemer?: Redeemer): Tx

All assets should be of the same policy id. You can chain mintAssets functions together if you need to mint assets with different policy ids. If the plutus script doesn't need a redeemer, you still need to specifiy the void redeemer.

payToAddress(address: Address, assets: Assets): Tx

Pay to a public key or native script address.

address: Address,
outputData: Datum | OutputData,
assets: Assets,
): Tx

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

address: Address,
outputData: Datum | OutputData,
assets: Assets,
): Tx

Pay to a plutus script address with datum or scriptRef.

readFrom(utxos: UTxO[]): Tx

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

registerPool(poolParams: PoolParams): Tx

Register a stake pool. A pool deposit is required. The metadataUrl needs to be hosted already before making the registration.

registerStake(rewardAddress: RewardAddress): Tx

Register a reward address in order to delegate to a pool and receive rewards.

retirePool(poolId: PoolId, epoch: number): Tx

Retire a stake pool. The epoch needs to be the greater than the current epoch + 1 and less than current epoch + eMax. The pool deposit will be sent to reward address as reward after full retirement of the pool.

toString(): Promise<string>

Return the current transaction body in Hex encoded Cbor.

updatePool(poolParams: PoolParams): Tx

Update a stake pool. No pool deposit is required. The metadataUrl needs to be hosted already before making the update.

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