Use Command Results as Arguments
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 build a Programmable Transaction Block that calls Move functions, assigns names to their results, and uses those named results (including nested results) as arguments to later commands.
Prerequisites
- The IOTA SDK installed for your target language
Steps
1. Initialize the Client and Sender
Connect to testnet, parse the sender address, and create a transaction builder.
- Rust
- Go
- Python
- Kotlin
- Swift
- C#
- WASM/TS
loading...
loading...
loading...
loading...
loading...
loading...
loading...
2. Call Move Functions and Name Their Results
Add two move_call commands and assign a name to each command's result so it can be referenced later.
- Rust
- Go
- Python
- Kotlin
- Swift
- C#
- WASM/TS
loading...
loading...
loading...
loading...
loading...
loading...
loading...
3. Use Named Results in a Split, Naming the Nested Results
Split the gas coin using the two named results as amounts. A split_coins command returns multiple values, so assign one name per nested result.
- Rust
- Go
- Python
- Kotlin
- Swift
- C#
- WASM/TS
loading...
loading...
loading...
loading...
loading...
loading...
loading...
4. Transfer the Results, Finish, and Dry-Run
Transfer the named coins to the sender, finish the transaction, and dry-run it to confirm it is valid.
- Rust
- Go
- Python
- Kotlin
- Swift
- C#
- WASM/TS
loading...
loading...
loading...
loading...
loading...
loading...
loading...
Expected Output
Signing Digest: <signing-digest-hex>
Txn Bytes: <base64-transaction-bytes>
Tx dry run was successful!
Full Example
- Rust
- Go
- Python
- Kotlin
- Swift
- C#
- WASM/TS
loading...
loading...
loading...
loading...
loading...
loading...
loading...