Skip to main content
Programmable Transaction Blocks (PTBs) are Sui’s most powerful feature, allowing you to compose multiple commands in one atomic transaction.

Key Concepts

  • Atomic: All commands succeed or all fail
  • Composable: Chain outputs from one command as inputs to another
  • Efficient: One transaction fee for multiple operations
  • Gas: Uses gas coin for payments and references

Basic Example

From crates/sui-sdk/examples/programmable_transactions_api.rs:

TypeScript Example

Advanced Patterns

Multi-step DeFi transaction

NFT minting and listing

Flash Loan Pattern

From examples/move/flash_lender:

Transaction Commands

SplitCoins

Split a coin into multiple coins:

MergeCoins

Merge multiple coins into one:

TransferObjects

Transfer objects to an address:

MoveCall

Call a Move function:

MakeMoveVec

Create a vector of objects:

Publish

Publish a new package:

Gas Management

Using gas coin

Setting gas budget

Best Practices

1. Minimize transactions

2. Chain results efficiently

3. Handle errors atomically

All commands in a PTB succeed or fail together - design accordingly.

Next Steps