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.
- Rust
- Go
- Python
- Kotlin
- Swift
- C#
- WASM/TS
crates/iota-sdk/examples/stake.rs
loading...
bindings/go/examples/stake/main.go
loading...
bindings/python/examples/stake.py
loading...
bindings/kotlin/examples/Stake.kt
loading...
bindings/swift/examples/Stake.swift
loading...
bindings/csharp/examples/Stake/Program.cs
loading...
bindings/wasm/examples/stake.mjs
loading...
2. Select a Validator
Fetch the active validators and pick the one to stake to.
- Rust
- Go
- Python
- Kotlin
- Swift
- C#
- WASM/TS
crates/iota-sdk/examples/stake.rs
loading...
bindings/go/examples/stake/main.go
loading...
bindings/python/examples/stake.py
loading...
bindings/kotlin/examples/Stake.kt
loading...
bindings/swift/examples/Stake.swift
loading...
bindings/csharp/examples/Stake/Program.cs
loading...
bindings/wasm/examples/stake.mjs
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.
- Rust
- Go
- Python
- Kotlin
- Swift
- C#
- WASM/TS
crates/iota-sdk/examples/stake.rs
loading...
bindings/go/examples/stake/main.go
loading...
bindings/python/examples/stake.py
loading...
bindings/kotlin/examples/Stake.kt
loading...
bindings/swift/examples/Stake.swift
loading...
bindings/csharp/examples/Stake/Program.cs
loading...
bindings/wasm/examples/stake.mjs
loading...
Expected Output
Staking to validator <validator-name>
Stake dry run was successful!
Full Example
- Rust
- Go
- Python
- Kotlin
- Swift
- C#
- WASM/TS
crates/iota-sdk/examples/stake.rs
loading...
bindings/go/examples/stake/main.go
loading...
bindings/python/examples/stake.py
loading...
bindings/kotlin/examples/Stake.kt
loading...
bindings/swift/examples/Stake.swift
loading...
bindings/csharp/examples/Stake/Program.cs
loading...
bindings/wasm/examples/stake.mjs
loading...