Programmable Transaction Blocks
The Kotlin SDK does a great job by abstracting PTB construction using a simple expressive Domain Specific Language as we'll explore below.
The programmableTx {}
DSL block is the top most block that creates a typed scope for PTB construction. Within it, we can call all available commands, pass their results to the next command and so forth.
For example, the Sui moveCall
command expects a mandatory target
argument, optionalarguments
, and typedArguments
argument. The natural mapping for these is the moveCall
within programmableTx
DSL, where each property (target, arguments, and typedArgument) is used directly with matching names.
Let's see how to call hello_world
Move function in the hello_wolrd
module of 0x883393ee444fb828aa0e977670cf233b0078b41d144e6208719557cb3888244d
package. The function has the following signature:
Things to note, the function expects a u64
as an argument. Has no type parameters. The module name and package. Click on it for details.
Given the above properties, we can call it as follows:
You can also pass results from one command to the next by storing them in a variable, as shown below:
Transaction Block Dry Run
Simulate a transaction before execution:
Sign And Execute Transaction Block
Once you've constructed, you can sign and execute it:
In the next section of Transactions, we're going to see how to visually compose PTBs using PTB Studio.