whisky
Github
  • whisky
  • WASM - whisky-js
  • Tx Builder
    • Getting Started
      • Lock Fund
      • Unlock Fund
      • Mint Tokens
      • Delegate Stake
      • Complex Transaction
    • Service Integration
  • Services
    • Providers
      • Fetcher
      • Evaluator
      • Submitter
Powered by GitBook
On this page
  1. Tx Builder
  2. Getting Started

Delegate Stake

Build a transaction to (register stake certificate and) delegate stake to a pool

The following shows a simple example of building a transaction to (register stake certificate and) delegate stake to a pool for the first time.

use whisky::*;

pub fn delegate_stake(
    stake_key_hash: &str,
    pool_id: &str, // In the form of 'poolxxxxxx'
    my_address: &str,
    inputs: &[UTxO],
) -> Result<String, WError> {
    let mut tx_builder = TxBuilder::new_core();
    tx_builder
        .register_stake_certificate(stake_key_hash)
        .delegate_stake_certificate(stake_key_hash, pool_id)
        .change_address(my_address)
        .select_utxos_from(inputs, 5000000)
        .complete_sync(None)?;

    Ok(tx_builder.tx_hex())
}
PreviousMint TokensNextComplex Transaction

Last updated 1 month ago