Skip to main content

Stake IOTA

Alpha Software

The IOTA SDK is currently in alpha. APIs, interfaces, and behavior may change without notice between releases. It is not yet recommended for production use.

This how-to demonstrates how to stake IOTA to an active validator using the SDK transaction builder.

info

This example runs on testnet. Set the sender address to an account you control that holds enough IOTA to stake.

Prerequisites

  • The IOTA SDK installed for your target language
  • A sender address funded with IOTA on testnet

Steps

1. Initialize the Client and Set the Sender Address

Connect to testnet and set the address that will stake.

crates/iota-sdk/examples/stake.rs
loading...

2. Select a Validator

Fetch the active validators and pick the one to stake to.

crates/iota-sdk/examples/stake.rs
loading...

3. Build the Stake Command and Dry-Run

Add the stake command to the transaction builder and dry-run it to verify it will execute correctly.

crates/iota-sdk/examples/stake.rs
loading...

Expected Output

Staking to validator <validator-name>
Stake dry run was successful!

Full Example

crates/iota-sdk/examples/stake.rs
loading...