whisky_examples/tx/
unlock_fund.rs1use whisky::*;
2
3pub async fn unlock_fund(
4 script_utxo: &UTxO,
5 redeemer: &str,
6 script: &ProvidedScriptSource,
7 my_address: &str,
8 inputs: &[UTxO],
9 collateral: &UTxO,
10) -> Result<String, WError> {
11 let mut tx_builder = TxBuilder::new_core();
12 let pub_key_hash = deserialize_address(my_address).pub_key_hash;
13
14 tx_builder
15 .spending_plutus_script_v3()
18 .tx_in(
19 &script_utxo.input.tx_hash,
20 script_utxo.input.output_index,
21 &script_utxo.output.amount,
22 &script_utxo.output.address,
23 )
24 .tx_in_inline_datum_present()
25 .tx_in_redeemer_value(&WRedeemer {
27 data: WData::JSON(redeemer.to_string()),
28 ex_units: Budget { mem: 0, steps: 0 },
29 })
30 .tx_in_script(&script.script_cbor)
31 .change_address(my_address)
33 .required_signer_hash(&pub_key_hash) .tx_in_collateral(
35 &collateral.input.tx_hash,
36 collateral.input.output_index,
37 &collateral.output.amount,
38 &collateral.output.address,
39 )
40 .input_for_evaluation(script_utxo)
41 .select_utxos_from(inputs, 5000000)
42 .complete(None)
43 .await?;
44
45 Ok(tx_builder.tx_hex())
46}