Transaction.ts
Transaction overview
Table of contents
encoding
addVKeyWitnesses
Add VKey witnesses to a transaction at the domain level.
This creates a new Transaction with the additional witnesses merged in. All encoding metadata (body bytes, redeemers format, witness map structure) is preserved so that txId and scriptDataHash remain stable.
Signature
export declare const addVKeyWitnesses: (
tx: Transaction,
witnesses: ReadonlyArray<TransactionWitnessSet.VKeyWitness>
) => TransactionAdded in v2.0.0
addVKeyWitnessesBytes
Merge wallet vkey witnesses into a transaction, preserving CBOR encoding.
Uses the WithFormat round-trip: decode with format capture, mutate at the domain level, re-encode with the original format tree. Body encoding, redeemer bytes, map key ordering, and all non-witness data are preserved through the format tree reconciliation.
options applies only to parsing the wallet witness set bytes. Transaction
decoding and re-encoding are governed by the captured format tree, making
codec options irrelevant for the transaction round-trip path.
Signature
export declare const addVKeyWitnessesBytes: (
txBytes: Uint8Array,
walletWitnessSetBytes: Uint8Array,
options?: CBOR.CodecOptions
) => Uint8ArrayAdded in v2.0.0
addVKeyWitnessesHex
Hex variant of addVKeyWitnessesBytes.
Signature
export declare const addVKeyWitnessesHex: (
txHex: string,
walletWitnessSetHex: string,
options?: CBOR.CodecOptions
) => stringAdded in v2.0.0
extractBodyBytes
Extract the original body bytes from a raw transaction CBOR byte array.
A Cardano transaction is a 4-element CBOR array: [body, witnessSet, isValid, auxiliaryData].
This returns the raw body bytes without decoding/re-encoding, preserving the exact CBOR encoding.
Signature
export declare const extractBodyBytes: (txBytes: Uint8Array) => Uint8ArrayAdded in v2.0.0
toCBORBytesWithFormat
Convert a Transaction to CBOR bytes using an explicit root format tree.
Signature
export declare const toCBORBytesWithFormat: (data: Transaction, format: CBOR.CBORFormat) => Uint8ArrayAdded in v2.0.0
toCBORHexWithFormat
Convert a Transaction to CBOR hex string using an explicit root format tree.
Signature
export declare const toCBORHexWithFormat: (data: Transaction, format: CBOR.CBORFormat) => stringAdded in v2.0.0
model
Transaction (class)
Transaction based on Conway CDDL specification
CDDL: transaction = [transaction_body, transaction_witness_set, bool, auxiliary_data / nil]
Signature
export declare class TransactionAdded in v2.0.0
toJSON (method)
Signature
toJSON()toString (method)
Signature
toString(): string[Inspectable.NodeInspectSymbol] (method)
Signature
[Inspectable.NodeInspectSymbol](): unknown[Equal.symbol] (method)
Signature
[Equal.symbol](that: unknown): boolean[Hash.symbol] (method)
Signature
[Hash.symbol](): numberparsing
fromCBORBytesWithFormat
Parse a Transaction from CBOR bytes and return the root format tree.
Signature
export declare const fromCBORBytesWithFormat: (bytes: Uint8Array) => CBOR.DecodedWithFormat<Transaction>Added in v2.0.0
fromCBORHexWithFormat
Parse a Transaction from CBOR hex string and return the root format tree.
Signature
export declare const fromCBORHexWithFormat: (hex: string) => CBOR.DecodedWithFormat<Transaction>Added in v2.0.0
utils
CDDLSchema
Conway CDDL schema for Transaction tuple structure.
CDDL: transaction = [transaction_body, transaction_witness_set, bool, auxiliary_data / nil]
Signature
export declare const CDDLSchema: Schema.declare<
readonly [Map<bigint, CBOR.CBOR>, Map<bigint, CBOR.CBOR>, boolean, CBOR.CBOR],
readonly [Map<bigint, CBOR.CBOR>, Map<bigint, CBOR.CBOR>, boolean, CBOR.CBOR],
readonly [],
never
>FromCBORBytes
CBOR bytes transformation schema for Transaction.
Signature
export declare const FromCBORBytes: (
options?: CBOR.CodecOptions
) => Schema.transform<
Schema.transformOrFail<
typeof Schema.Uint8ArrayFromSelf,
Schema.declare<CBOR.CBOR, CBOR.CBOR, readonly [], never>,
never
>,
Schema.transformOrFail<
Schema.declare<
readonly [Map<bigint, CBOR.CBOR>, Map<bigint, CBOR.CBOR>, boolean, CBOR.CBOR],
readonly [Map<bigint, CBOR.CBOR>, Map<bigint, CBOR.CBOR>, boolean, CBOR.CBOR],
readonly [],
never
>,
Schema.SchemaClass<Transaction, Transaction, never>,
never
>
>FromCBORHex
CBOR hex transformation schema for Transaction.
Signature
export declare const FromCBORHex: (
options?: CBOR.CodecOptions
) => Schema.transform<
Schema.transform<
Schema.Schema<Uint8Array, string, never>,
Schema.transformOrFail<
typeof Schema.Uint8ArrayFromSelf,
Schema.declare<CBOR.CBOR, CBOR.CBOR, readonly [], never>,
never
>
>,
Schema.transformOrFail<
Schema.declare<
readonly [Map<bigint, CBOR.CBOR>, Map<bigint, CBOR.CBOR>, boolean, CBOR.CBOR],
readonly [Map<bigint, CBOR.CBOR>, Map<bigint, CBOR.CBOR>, boolean, CBOR.CBOR],
readonly [],
never
>,
Schema.SchemaClass<Transaction, Transaction, never>,
never
>
>FromCDDL
Transform between CDDL tuple and Transaction class.
Signature
export declare const FromCDDL: Schema.transformOrFail<
Schema.declare<
readonly [Map<bigint, CBOR.CBOR>, Map<bigint, CBOR.CBOR>, boolean, CBOR.CBOR],
readonly [Map<bigint, CBOR.CBOR>, Map<bigint, CBOR.CBOR>, boolean, CBOR.CBOR],
readonly [],
never
>,
Schema.SchemaClass<Transaction, Transaction, never>,
never
>arbitrary
Signature
export declare const arbitrary: FastCheck.Arbitrary<Transaction>fromCBORBytes
Signature
export declare const fromCBORBytes: (bytes: Uint8Array, options?: CBOR.CodecOptions) => TransactionfromCBORHex
Signature
export declare const fromCBORHex: (hex: string, options?: CBOR.CodecOptions) => TransactiontoCBORBytes
Signature
export declare const toCBORBytes: (data: Transaction, options?: CBOR.CodecOptions) => anytoCBORHex
Signature
export declare const toCBORHex: (data: Transaction, options?: CBOR.CodecOptions) => string