tx.txbuilder.addinput
Home > @blaze-cardano/tx > TxBuilder > addInput
TxBuilder.addInput() method
Adds an input to the transaction. This method is responsible for including a new input, which represents a reference to an unspent transaction output (UTxO) that will be consumed by the transaction. Optionally, a redeemer and an unhashed datum can be provided for script validation purposes.
Signature:
addInput(utxo: TransactionUnspentOutput, redeemer?: PlutusData, unhashDatum?: PlutusData): TxBuilder;
Parameters
| Parameter | Type | Description | 
|---|---|---|
| utxo | TransactionUnspentOutput | The UTxO to be consumed as an input. | 
| redeemer | PlutusData | (Optional) Optional. The redeemer data for script validation, required for spending Plutus script-locked UTxOs. | 
| unhashDatum | PlutusData | (Optional) Optional. The unhashed datum, required if the UTxO being spent includes a datum hash instead of inline datum. | 
Returns:
{TxBuilder} The same transaction builder
Exceptions
{Error} If attempting to add a duplicate input, if the UTxO payment key is missing, if attempting to spend with a redeemer for a KeyHash credential, if attempting to spend without a datum when required, or if providing both an inline datum and an unhashed datum.