Sui Client PTB CLI
The client ptb command allows you to specify the transactions for execution in a programmable transaction block (PTB) directly from your CLI or through bash scripts.
The examples in this document were tested using a bash shell environment. Your experience might vary depending on how your shell interprets the input values (for example, zsh requires quotes around passed values in brackets: "[]"; whereas bash accepts them without quotes). On Windows, you might need to add even more quotes around arguments passed (for example, --assign "forge @<FORGE-ID>").
Commands
The following list itemizes all the available args for the sui client ptb command. Use the --help for a long help version that includes some examples on how to use this command.
$ sui client ptb --help
console-output/sui-client-ptb-help.mdxDesign philosophy and concepts
The main philosophy behind the CLI PTB support is to enable a user to build and execute a PTB from the command line. Bash scripts can be used to construct and execute the PTB just as you would do from the command line, providing great flexibility when it comes to automating different tasks.
Besides using existing traditional PTB related concepts, we introduce a few new and important concepts for this command.
All the following examples were tested using a bash shell environment and your experience may vary depending on how your shell interprets the input values (e.g., zsh requires to pass values in brackets by adding quotes around it: "[]"; bash accepts them without quotes).
Types
Sometimes, CLI PTBs require that you specify the type of a value or variable. For instance, in the following example you must provide the <u64> type when calling the 0x1::option::is_none function.
$ sui client ptb \
--assign my_variable none \
--move-call 0x1::option::is_none "<u64>" my_variable \
--gas-budget 50000000
To pass in multiple types, delimit them with a comma:
...
--move-call package::module::function "<u64,u8,u256>" \
...
Strings
CLI PTBs support string literals as inputs, which will be encoded as pure values that can be used as inputs to vector<u8>, std::ascii::String and std::string::String parameters. The following example previews a transaction block that passes the string "Hello, world" to a function m::f in a package $PKG (its ID is held in an environment variable).
$ sui client ptb --move-call "$PKG::m::f" '"Hello, world"' --gas-budget 10000000 --preview
Double-quoted string literals tend to also be valid syntax for shells (like bash), so when inputting PTBs on the command-line, remember to wrap the entire string in single-quotes so that its double-quotes are interpreted literally, as in the previous example.