whisky_examples/tx/
mint_tokens.rs1use whisky::*;
2
3pub async fn mint_tokens(
4 to_mint_asset: &Asset,
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
13 tx_builder
14 .mint_plutus_script_v3()
17 .mint(
18 to_mint_asset.quantity_i128(),
19 &to_mint_asset.policy(),
20 &to_mint_asset.name(),
21 )
22 .minting_script(&script.script_cbor)
23 .mint_redeemer_value(&WRedeemer {
25 data: WData::JSON(redeemer.to_string()),
26 ex_units: Budget { mem: 0, steps: 0 },
27 })
28 .change_address(my_address)
29 .tx_in_collateral(
30 &collateral.input.tx_hash,
31 collateral.input.output_index,
32 &collateral.output.amount,
33 &collateral.output.address,
34 )
35 .select_utxos_from(inputs, 5000000)
36 .complete(None)
37 .await?;
38
39 Ok(tx_builder.tx_hex())
40}