Skip to main content

Use Command Results as Arguments

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 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.

crates/iota-sdk/examples/tx_command_results.rs
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.

crates/iota-sdk/examples/tx_command_results.rs
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.

crates/iota-sdk/examples/tx_command_results.rs
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.

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

Expected Output

Signing Digest: <signing-digest-hex>
Txn Bytes: <base64-transaction-bytes>
Tx dry run was successful!

Full Example

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