PTB Builder Handbook β
A Beginnerβs Guide to Move and Programmable Transaction Blocks
Foreword β
This handbook is a short guide for those who are new to the Move language and Programmable Transaction Blocks (PTBs). Move is a language designed to safely manage digital assets on blockchains. By following this guide, you will write and run code, and experience token issuance and PTB construction firsthand. With just 2β3 hours of practice, you can directly experience the power of Move and PTBs.
Table of Contents β
- Introduction to Move
- Environment Setup
- Install Sui CLI (basic)
- Install VS Code β Sui Extension
- Quick Start
- CLI Quick Start
- VS Code β Sui Extension Quick Start
- Objects and Resources
- PTB Practice π
- Further Reading
1. Introduction to Move β
π‘ Key Terms Preview β
- Move: An asset-centric smart contract language for blockchains
- Resource: A value that cannot be copied or deleted, only moved
- Module: The basic unit of Move code (contains functions and types)
What is Move? β
- Move is a programming language designed to safely manage blockchain assets.
- It started in Facebookβs Libra project (2018) and is now used in Sui, Aptos, and other blockchains.
- The name comes from the action of βmoving values instead of copying themβ, reflecting its asset-centric model.
Core Values of Move β
- Security: Prevents assets from being copied or deleted at the language level
- Expressiveness: Flexible design of asset-related logic
- Accessibility: Easy to use for both smart contracts and applications
Key Features of Move β
- Resource Types: Digital assets cannot be copied/deleted, only moved
- Ability System: Strictly controls how values are created, stored, and transferred
- Module System: Supports code reuse and encapsulation
- PTB (Programmable Transaction Block): Batch multiple operations into a single transaction
Move on Sui β
- Object-Centric Model: Assets are managed as objects
- Unique Object IDs: Each object has a globally unique identifier
- Parallel Execution: Transactions without conflicts can be executed simultaneously
- Entry Functions: Special entry points callable by anyone
2. Environment Setup β
π‘ Key Terms Preview β
- Sui CLI: Basic tool for building, testing, and deploying Move packages
- VS Code Extension: GUI-based toolkit for development
- Workspace: Project unit managed by the VS Code Extension
- Explorer View: Project navigation/creation menu in VS Code
2.1 Install Sui CLI β
- macOS / Linux / WSL:
brew install sui
- Windows:
choco install sui
Check installation:
sui --version
β οΈ Sui CLI is required to build and run Move code. Install it first before continuing.
2.2 Install VS Code β Sui Extension β
The Sui Extension lets you compile, deploy, and test Move smart contracts, and also visually build and execute PTBs inside VS Code.
Key Features β
- Compile & Deploy
- Upgrade Support (
upgrade.toml
) - Object Explorer
- Package Explorer
- Built-in PTB Builder (drag-and-drop)
Installation β
- Open VS Code β Extensions (β§βX / Ctrl+Shift+X)
- Search for
Sui Extension
and install - Restart VS Code
β οΈ Requirement: Sui CLI must be installed first.
3. Quick Start β
π‘ Key Terms Preview β
- Build: Compile Move code into modules
- Test: Run unit tests
- Deploy: Upload a package to the network
- Package Explorer: UI to view/call deployed modules and functions
3.1 CLI Quick Start β
sui move new hello_move
cd hello_move
sui move build
sui move test
3.2 VS Code β Extension Quick Start β
- In Explorer View, right-click β New Move Project
- Choose the Hello World template
- Click the Sui Extension icon in the Activity Bar
- In Workspace, select the
hello_move
package and run Build / Test / Deploy - After deployment, a new Package Card appears in the Package Explorer
π§ Get Testnet Tokens β
To run tests, you need Testnet SUI. π Claim from the official Faucet.
4. Objects and Resources β
π‘ Key Terms Preview β
- Coin: Object that represents a token
- TreasuryCap: Object with mint/burn authority
- Entry Function: A function callable directly from outside
After learning Move basics, you can try out real coins and permission models. Use the Sui Extension template Sui Move Intro Course: Fungible Token (Managed) to quickly understand coin issuance and the TreasuryCap
model.
π Using the Template (VS Code Sui Extension)
- Right-click in Explorer β New Move Project
- Select Sui Move Intro Course: Fungible Token (Managed)
- In Sui Extension β Workspace, run Build/Test/Deploy
Key Code Snippets β
Define Coin Type β
public struct MANAGED has drop {}
Initialization β
fun init(witness: MANAGED, ctx: &mut TxContext) {
let (treasury_cap, metadata) = sui::coin::create_currency<MANAGED>(
witness, 2, b"MANAGED", b"MNG", b"", std::option::none(), ctx
);
sui::transfer::public_freeze_object(metadata);
sui::transfer::public_transfer(treasury_cap, sui::tx_context::sender(ctx));
}
Mint / Burn β
public fun mint(
treasury_cap: &mut TreasuryCap<MANAGED>,
amount: u64,
recipient: address,
ctx: &mut TxContext,
) {
treasury_cap.mint_and_transfer(amount, recipient, ctx)
}
public fun burn(treasury_cap: &mut TreasuryCap<MANAGED>, coin: Coin<MANAGED>) {
treasury_cap.burn(coin);
}
Only accounts holding the
TreasuryCap
can call mint/burn.
5. PTB Practice π β
5.1 Preparation β
- Build & Deploy
- In Owner Objects Explorer, check that you own
TreasuryCap<...::MANAGED>
5.2 Running in the Extension β
After deployment, open Package Explorer
Select the
mint
function β enter arguments (treasury_cap
, amount, recipient)Run β new
Coin<MANAGED>
is created
5.3 Running in PTB Builder β
Open PTB Builder
Add a node:
moveCall β managed::mint
Enter arguments:
object(treasuryCapId)
pure.u64(amount)
pure.address(recipient)
Execute β check Transaction Digest
β‘οΈ PTB Builder automatically generates TypeScript code for executed configurations. Use Export/Copy to integrate into your project.
5.4 Using ptb.wal.app β
Web-based PTB Builder: ptb.wal.app
Features:
- Build and execute PTBs
- Enter
tx digest
β visualize transactions - Export PTBs as files
- Convert PTBs into TypeScript code
6. Further Reading β
- π The Move Book
- π PTB Builder Online
- π§βπ» Sui Extension (VS Code Marketplace)