Building Transactions

Getting Started

The transaction builder can be initialized with

let mut mesh = MeshTxBuilder::new_core();

Full Example

The following shows a simple example of building a transaction to send values to a recipient:

use whisky::{
    builder::{IMeshTxBuilder, MeshTxBuilder},
    model::{Asset, UTxO},
};

async fn my_first_whisky_tx(
    recipient_address: &str,
    my_address: &str,
    inputs: Vec<UTxO>,
) -> String {
    let mut mesh = MeshTxBuilder::new_core();
    mesh.tx_out(
        &recipient_address,
        vec![Asset::new_from_str("lovelace", "1000000")],
    )
    .change_address(my_address)
    .select_utxos_from(inputs.clone(), 5000000)
    .complete(None)
    .await;

    mesh.tx_hex()
}

Last updated