Skip to main content

Batch Multiple Commands with PTB

In this lesson, you'll use PTB Builder to build a PTB from scratch that combines multiple transfer commands into a single transaction. It's not difficult—follow the steps and you'll have it done in no time.

What is a PTB (Programmable Transaction Block)?

On Sui, you can combine multiple commands into a single transaction. This is called a PTB (Programmable Transaction Block).

Using a PTB gives you the following benefits:

  • Reduce per-transaction overhead — You still pay for the work done by each command, but you save on signature costs and base transaction fees by combining them
  • Atomicity — Either all commands succeed, or they all fail (no half-finished states)
  • Efficient — Complete multiple commands with a single signature
How PTB works

If you send "1 SUI to A" and "2 SUI to B" as separate transactions, you need 2 signatures and pay transaction overhead twice. With a PTB, you only need 1 signature and 1 transaction overhead—while still paying for each command's execution.


Prerequisites

Before starting this lesson, make sure you have completed the following:


Build a Multi-Command PTB with PTB Builder

The visual editor below is empty—only the Start and End nodes are present.

Follow the guide in the top-left corner to add and connect nodes, building multiple transfer commands into a single transaction. First, connect your Slush wallet using the wallet icon in the top-right corner of the site header.


Verify in Explorer

After executing the transaction, verify the results in Explorer:

  1. Click the link next to the displayed Transaction Digest
  2. Suiscan (or another Explorer) will open
  3. In the Transactions section, confirm that the following commands are included:
    • SplitCoins — splits your gas coin into amounts for each transfer
    • TransferObjects — appears twice, once for each recipient

Verify Success

You've completed this lesson if you can check off the following:

  • Added nodes to an empty PTB Builder and built a multi-command PTB
  • Connected the gas node to SplitCoins commands
  • Executed multiple commands as a single transaction
  • Confirmed in Explorer that SplitCoins and two TransferObjects commands are included

Common Issues

Wallet won't connect

Execute button is not clickable

  • Make sure your wallet is connected
  • Make sure all nodes are properly connected
  • The flow must be connected without breaks from Start to End

Transaction fails

  • Make sure you have enough gas balance
  • The balance of the source SUI coin (gas) must exceed the total transfer amount plus gas fees
  • If your balance is insufficient, get more SUI from the Faucet

What You Did in This Lesson

  • Understood the concept of PTB (Programmable Transaction Block)
  • Added and connected nodes from an empty PTB Builder to build a multi-command PTB
  • Executed multiple commands as a single transaction
  • Verified the results in Explorer