Skip to main content
Module

x/lucid/mod.ts>Core.TransactionBuilder

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 Core.TransactionBuilder
import { Core } from "https://deno.land/x/lucid@0.5.2/mod.ts";
const { TransactionBuilder } = Core;

Methods

add_certificate(certificate: Certificate, script_witness?: ScriptWitness): void

Add certificate via a Certificates object

add_input(utxo: TransactionUnspentOutput, script_witness?: ScriptWitness): void

This automatically selects and adds inputs from {inputs} consisting of just enough to cover the outputs that have already been added. This should be called after adding all certs/outputs/etc and will be an error otherwise. Adding a change output must be called after via TransactionBuilder::balance() inputs to cover the minimum fees. This does not, however, set the txbuilder's fee.

add_json_metadatum(key: BigNum, val: string): void

Add a single JSON metadatum using a TransactionMetadatumLabel and a String It will be securely added to existing or new metadata in this builder

add_json_metadatum_with_schema(
key: BigNum,
val: string,
schema: number,
): void

Add a single JSON metadatum using a TransactionMetadatumLabel, a String, and a MetadataJsonSchema object It will be securely added to existing or new metadata in this builder

Add a single metadatum using TransactionMetadatumLabel and TransactionMetadatum objects It will be securely added to existing or new metadata in this builder

add_mint(
policy_id: ScriptHash,
mint_assets: MintAssets,
script_witness?: ScriptWitness,
): void

Add a mint entry to this builder using a PolicyID and MintAssets object It will be securely added to existing or new Mint in this builder It will securely add assets to an existing PolicyID But it will replace/overwrite any existing mint assets with the same PolicyID first redeemer applied to a PolicyID is taken for all further assets added to the same PolicyID

add_native_script(native_script: NativeScript): void

Add native scripts via a NativeScripts object

Add explicit output via a TransactionOutput object

add_plutus_data(plutus_data: PlutusData): void

Add plutus data via a PlutusData object

add_plutus_script(plutus_script: PlutusScript): void

Add plutus scripts via a PlutusScripts object

add_plutus_v2_script(plutus_script: PlutusScript): void

Add plutus v2 scripts via a PlutusScripts object

add_required_signer(required_signer: Ed25519KeyHash): void
add_withdrawal(
reward_address: RewardAddress,
coin: BigNum,
script_witness?: ScriptWitness,
): void
balance(address: Address, datum?: Datum): void

Warning: this function will mutate the /fee/ field Make sure to call this function last after setting all other tx-body properties Editing inputs, outputs, mint, etc. after change been calculated might cause a mismatch in calculated fee versus the required fee

Returns full Transaction object with the body and the auxiliary data NOTE: witness_set will contain all mint_scripts if any been added or set NOTE: is_valid set to true

certificates(): Certificates | undefined
construct(collateral_utxos?: TransactionUnspentOutputs, collateral_change_address?: Address): Promise<Transaction>

Returns full Transaction object with the body and the auxiliary data

NOTE: witness_set will contain all mint_scripts if any been added or set

takes fetched ex units into consideration

add collateral utxos and collateral change receiver in case you redeem from plutus script utxos

async call

NOTE: is_valid set to true

calculates how much the fee would increase if you added a given output

calculates how much the fee would increase if you added a given output

free(): void
full_size(): number

does not include refunds or withdrawals

does not include fee

get_fee_if_set(): BigNum | undefined

withdrawals and refunds

Return explicit input plus implicit input plus mint

Return explicit output plus implicit output plus burn (does not consider fee directly)

warning: sum of all parts of a transaction must equal 0. You cannot just set the fee to the min value and forget about it warning: min_fee may be slightly larger than the actual minimum fee (ex: a few lovelaces) this is done to simplify the library code, but can be fixed later

mint(): Mint | undefined

Returns a copy of the current mint state in the builder

Returns a copy of the current witness native scripts in the builder

network_id(): NetworkId | undefined
output_sizes(): Uint32Array
redeemers(): Redeemers | undefined
set_auxiliary_data(auxiliary_data: AuxiliaryData): void

Set explicit auxiliary data via an AuxiliaryData object It might contain some metadata plus native or Plutus scripts

Set metadata using a GeneralTransactionMetadata object It will be set to the existing or new auxiliary data in this builder

set_network_id(network_id: NetworkId): void
set_ttl(ttl: BigNum): void
set_validity_start_interval(validity_start_interval: BigNum): void
withdrawals(): Withdrawals | undefined