export interface TxBody {
allScriptHashes: ScriptHash<unknown>[]
collateral: TxInput<SpendingCredential>[]
collateralReturn: undefined | TxOutput<SpendingCredential>
countUniqueSigners(): number
dcerts: DCert[]
dump(): any
encodingConfig: TxBodyEncodingConfig
fee: bigint
firstValidSlot: undefined | number
getValidityTimeRange(params: NetworkParams): TimeRange
hash(): number[]
inputs: TxInput<SpendingCredential>[]
isValidSlot(slot: IntLike): boolean
kind: "TxBody"
lastValidSlot: undefined | number
metadataHash: undefined | number[]
minted: Assets
outputs: TxOutput<SpendingCredential>[]
recover(network: {getUtxo(id: TxOutputId): Promise<TxInput<SpendingCredential>>}): Promise<void>
refInputs: TxInput<SpendingCredential>[]
scriptDataHash: undefined | number[]
signers: PubKeyHash[]
sortOutputs(): void
sumInputAndMintedAssets(): Assets
sumInputAndMintedValue(): Value
sumInputValue(): Value
sumOutputAssets(): Assets
sumOutputValue(): Value
toCbor(): number[]
totalCollateral: bigint
toTxInfo(
params: NetworkParams,
redeemers: TxRedeemer[],
datums: UplcData[],
txId: TxId
): TxInfo
withdrawals: [StakingAddress<StakingCredential>, bigint][]
}
Note: inputs, minted assets, and withdrawals need to be sorted in order to form a valid transaction
Properties
allScriptHashes
allScriptHashes: ScriptHash<unknown>[]
Used to validate if all the necessary scripts are included TxWitnesses (and that there are not redundant scripts)
collateral
collateral: TxInput<SpendingCredential>[]
Optionally encoded as set.
TODO: rename to
collateralInputs
collateralReturn
collateralReturn: undefined | TxOutput<SpendingCredential>
countUniqueSigners
countUniqueSigners(): number
Calculates the number of dummy signatures needed to get precisely the right tx size.
dcerts
dcerts: DCert[]
Optionally encoded as set.
dump
encodingConfig
encodingConfig: TxBodyEncodingConfig
fee
firstValidSlot
firstValidSlot: undefined | number
getValidityTimeRange
getValidityTimeRange(params: NetworkParams): TimeRange
hash
The bytes that form the TxId
inputs: TxInput<SpendingCredential>[]
Optionally encoded as set.
isValidSlot
isValidSlot(slot: IntLike): boolean
Used by (indirectly) by emulator to check if slot range is valid.
Note: firstValidSlot == lastValidSlot is allowed
kind
lastValidSlot
lastValidSlot: undefined | number
metadataHash: undefined | number[]
minted
minted: Assets
Internally the assets must be sorted by mintingpolicyhash
Minting redeemers must point to the sorted minted assets
outputs
outputs: TxOutput<SpendingCredential>[]
recover
recover(network: {getUtxo(id: TxOutputId): Promise<TxInput<SpendingCredential>>}): Promise<void>
A serialized tx throws away input information
This must be refetched from the network if the tx needs to be analyzed
This must be done for the regular inputs because the datums are needed for correct budget calculation and min required signatures determination
This must be done for the reference inputs because they impact the budget calculation
This must be done for the collateral inputs as well, so that the minium required signatures can be determined correctly
refInputs: TxInput<SpendingCredential>[]
Optionally encoded as set.
scriptDataHash
scriptDataHash: undefined | number[]
signers
signers: PubKeyHash[]
Optionally encoded as set.
sortOutputs
Not done in the same routine as sortInputs(), because balancing of assets happens after redeemer indices are set
sumInputAndMintedAssets(): Assets
Excludes lovelace
sumInputAndMintedValue(): Value
Throws error if any part of the sum is negative (i.e. more is burned than input)
sumInputValue(): Value
sumOutputAssets
sumOutputAssets(): Assets
Excludes lovelace
sumOutputValue
sumOutputValue(): Value
toCbor
totalCollateral
toTxInfo
toTxInfo(
params: NetworkParams,
redeemers: TxRedeemer[],
datums: UplcData[],
txId: TxId
): TxInfo
Returns the on-chain Tx representation
withdrawals
withdrawals: [StakingAddress<StakingCredential>, bigint][]
Withdrawals must be sorted by address
Stake rewarding redeemers must point to the sorted withdrawals