whisky_examples/tx/
delegate_stake.rs

1use whisky::*;
2
3pub fn delegate_stake(
4    stake_key_hash: &str,
5    pool_id: &str, // In the form of 'poolxxxxxx'
6    my_address: &str,
7    inputs: &[UTxO],
8) -> Result<String, WError> {
9    let mut tx_builder = TxBuilder::new_core();
10    tx_builder
11        .register_stake_certificate(stake_key_hash)
12        .delegate_stake_certificate(stake_key_hash, pool_id)
13        .change_address(my_address)
14        .select_utxos_from(inputs, 5000000)
15        .complete_sync(None)?;
16
17    Ok(tx_builder.tx_hex())
18}