Logo vun Ptbs

Ptbs

Organisatioun
MystenLabs
ptbs

Sui Programmable Transaction Blocks (PTBs). Use when writing, reviewing, or debugging code that composes multiple Sui transaction commands into a single atomic transaction — including TypeScript SDK `Transaction` usage, CLI PTB construction, gas coin handling, sponsored transactions, shared-object inputs, chaining command results, or troubleshooting PTB execution errors.

Iwwersiicht

EditeurMystenLabs
Repositoryskills
Skill-Nummptbs
Stären
21
Forks
12
Matgeliwwert Fichieren
7
LizenzApache-2.0
Linken
  • Instruktiounen am Markdown-Format

    Eng SKILL.md-Datei, déi de Modell bei Bedarf luet, soudatt nëmmen Token ufalen, wann eng Ufro tatsächlech dozou passt.

  • Funktionéiert mat all LLM

    KI-Skills si reng Markdown, keen ubidderspezifesche Code. Dofir funktionéiert dëse Skill mat GPT, Claude, Gemini, Grok oder engem lokale Modell.

  • 7 matgeliwwert Dateien

    Skripten, Virlagen a Referenzen, déi de Modell beim Schaffe liese kann. D'Dateie kënnen nëmme gelies ginn a ginn ni ausgeféiert.

  • Open Source

    Vum MystenLabs op GitHub verëffentlecht. Liest de Quelltext, ier Dir de Skill installéiert.

Installatioun

Installéiert de KI-Skill Ptbs an TypingMind, fir e mat all LLM ze benotzen, oder füügt en an en anere KI-Agent an, deen SKILL.md liest.

1

An TypingMind installéieren

TypingMind installéiert e Skill direkt aus sengem GitHub-Dossier — dobäi gëtt SKILL.md gelies, d'Ressourcedateie gi gebëndelt an d'Resultat gëtt lokal gespäichert.

  1. Maacht d'App op a gitt op Plugins → Skills.
  2. Wielt „Vun GitHub installéieren“.
  3. Pecht d'URL vum Skill-Dossier hei drënner an a bestätegt.
    https://github.com/MystenLabs/skills/tree/main/ptbs
  4. Aktivéiert de Skill an all Chat, an deem Dir e benotze wëllt.
Plugins → Skills → Skill afügen → Vu GitHub-URL, pecht dann d'URL vum Dossier an a klickt op Weider.
2

An engem anere KI-Agent installéieren

All KI-Agent, deen d'Format Agent Skills liest, kann dëse Skill benotzen — kopéiert den Dossier an de Skill-Verzeechnes vun deem KI-Agent.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/MystenLabs/skills.git /tmp/skills
mkdir -p .claude/skills
cp -r /tmp/skills/ptbs .claude/skills/ptbs
Start Claude Code nom Kopéieren nei, fir datt den neie Skill erkannt gëtt.

An TypingMind benotzen

Aktivéiert Ptbs an engem Chat vun TypingMind, an de Modell iwwerhëlt de Rescht. Den Numm an d'Beschreiwung stinn am System-Prompt. Soubal eng Ufro dozou passt, luet de Modell déi komplett Instruktioune selwer — Dir musst de Skill ni manuell opruffen, an et fale keng Token un, bis en tatsächlech benotzt gëtt.

De Modell luet Ptbs automatesch, soubal eng Ufro dozou passt.

Funktionéiert mat all KI-Modell

KI-Skills si reng Markdown-Instruktiounen amplaz vun ubidderspezifeschem Code. Dofir ass Ptbs net un de Modell gebonnen, fir deen de Skill geschriwwe gouf. Installéiert en eemol an TypingMind a benotzt e mat GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama oder engem lokale Modell, deen Dir selwer bedreift — alles mat Ären eegenen API-Keys.

  • Gëtt nëmme gelueden, wann et néideg ass

    De System-Prompt enthält nëmmen den Numm an d'Beschreiwung. D'Instruktioune gi bei der éischter passender Ufro gelueden, soudatt en onbenotzte Skill näischt kascht.

  • De Modell am lafende Chat wiesselen

    Well de Skill aus Instruktiounen amplaz vu Code besteet, funktionéiert en och no engem Modellwiessel — den nächste Modell liest déi selwecht SKILL.md-Datei.

Skill-Instruktiounen

Dëst ass den Inhalt vu SKILL.md, deen de Modell luet. Liest e virun der Installatioun — e Skill besteet aus Instruktiounen, déi Äre Modell befollegt.

Sui Programmable Transaction Blocks (PTBs)

MCP tool: When available in your environment, also query the Sui documentation MCP server (https://sui.mcp.kapa.ai) for up-to-date answers. Use it for verification and for details not covered by these reference files.

A PTB is one Sui transaction that batches up to 1,024 commands — Move calls, coin splits/merges, object transfers, vector construction, package publish/upgrade — executed in order, atomically (one command fails ⇒ whole block fails), sharing inputs and chaining results. PTBs are the only way to execute transactions on Sui; there is no "single call" mode.

This skill routes to focused reference files. Load only the ones relevant to the current task.

All patterns in this skill are derived from:

If unsure about any API, method signature, or error message, fetch the relevant page before answering. Do not guess or extrapolate from Ethereum, Solana, or other chains — PTBs have no direct analog.


Reference files

fundamentals — PTB data model

Path: fundamentals.md Load when: explaining what a PTB is, talking about Input, Argument, NestedResult, GasCoin, owned vs shared vs immutable vs receiving object references, pure-input BCS rules, command chaining semantics, or execution ordering / atomicity. Covers: PTB structure, Input (CallArg) and ObjectArg variants, pure input types, Argument enum, result chaining, execution semantics (borrow rules, move/copy, hot potato cliques, end-of-tx constraints), protocol limits.

commands — Command reference

Path: commands.md Load when: writing or reviewing any specific command — MoveCall, SplitCoins, MergeCoins, TransferObjects, MakeMoveVec, Publish, Upgrade — or debugging argument-type mismatches and return-value shape. Covers: signature, argument rules, return shape, and common pitfalls for each of the seven commands.

building — TypeScript SDK Transaction class

Path: building.md Load when: writing TS/JS code that constructs a PTB with @mysten/sui/transactions, configuring gas, building for wallets, serializing across services, or sending PTBs between app ↔ wallet ↔ sponsor. Covers: Transaction API (tx.moveCall, tx.splitCoins, tx.mergeCoins, tx.transferObjects, tx.makeMoveVec, tx.publish, tx.upgrade, tx.balance, tx.coin, tx.add, tx.object, tx.pure, tx.gas, tx.setSender/setGasPrice/setGasBudget/setGasPayment/setGasOwner), Inputs.*Ref helpers, result destructuring, build({ onlyTransactionKind: true }), Transaction.from / fromKind, sponsored transaction flow, signing & executing.

cli — Building PTBs from the CLI

Path: cli.md Load when: constructing PTBs from the command line using sui client ptb, scripting transactions without TypeScript, merging coins from the CLI, or teaching CLI-based workflows. Covers: sui client ptb syntax, chaining commands, common CLI PTB patterns (transfers, coin merges, Move calls), gas budget, previewing before execution.

troubleshooting — Common errors

Path: troubleshooting.md Load when: diagnosing a failing PTB — any ServerError, UnusedValueWithoutDrop, VMVerificationOrDeserializationError, No valid gas coins, InsufficientGas, shared-object congestion, or cryptic "transaction failed" output. Covers: each error category with the Move/PTB-level cause and concrete fix.

Routing guide

TaskLoad
"What is a PTB?" / conceptual explanationfundamentals
Writing a new PTB in TypeScriptbuilding + commands
Writing a new PTB from the CLIcli + commands
Reviewing a PTB for correctnessfundamentals + commands + building
A specific command fails type checkingcommands
Sponsored / gasless transactionsbuilding
Debugging a failing PTBtroubleshooting + (fundamentals if execution-semantics related)
Publishing or upgrading a package in a PTBcommands
Building PTB bytes across services (app/wallet/sponsor)building
Merging coins or simple operations from the CLIcli
Full code reviewall reference files

Skill Content

Key concepts

  • A PTB is the transaction. Every Sui transaction is a PTB — even a single moveCall is a one-command PTB. There is no non-PTB execution path.
  • Inputs vs commands. inputs are values fed in from outside (objects and BCS-encoded "pure" bytes). commands operate on those inputs and on each other's results. Commands reference values via the Argument enum: Input(i), GasCoin, Result(i), NestedResult(cmd, result).
  • Chaining. Each command produces an array of results. The next command can consume any result (by NestedResult(cmd, idx) or, when a command has exactly one return, Result(cmd)). The TS SDK surfaces this as destructurable values: const [coin] = tx.splitCoins(tx.gas, [tx.pure.u64(100)]);.
  • Atomicity. Commands execute in order. Any failure reverts the entire block; no partial effects.
  • End-of-tx constraints. Every non-drop value produced during execution must be consumed (transferred, destroyed, or fed into another command). Shared objects have exactly two legal endings: re-share or delete — they cannot be transferred or frozen. Gas coin is returned to its owner with unused gas refunded.

Rules

  1. tx.gas must be used by reference, except in transferObjects. To get an owned Coin<SUI> from the gas coin, use SplitCoins(tx.gas, [amount]) first.
  2. Leave gas config to the wallet when possible. Do not hardcode setGasBudget / setGasPrice / setGasPayment in app code that will be signed by a user wallet — the wallet dry-runs and selects coins correctly. Only set them for backend-signed flows.
  3. In app code that hands a PTB to a wallet, use await tx.toJSON() (not tx.build()). The wallet must perform gas logic and coin selection itself; building bytes in app code preempts that.
  4. Use Transaction.fromKind(kindBytes) for sponsored flows. Build in app with tx.build({ client, onlyTransactionKind: true }), send the kind-only bytes to the sponsor service, rehydrate there with fromKind, then setSender, setGasOwner, setGasPayment. The user (or either party) should submit the fully-signed transaction directly to a full node — not back through the sponsor service — to avoid censorship.
  5. Every non-drop value must be consumed. If moveCall returns a value you don't need, pass it to transferObjects (if it has key + store), to public_transfer, or to a destructor. UnusedValueWithoutDrop is the PTB-level error.
  6. Shared objects cannot be transferred, frozen, or consumed by value if passed as read-only (mutable: false). If you need mutable access, mark them mutable when building the input.
  7. Types coming from Move calls cannot be references. MoveCall results are values; if a Move function returns &T, it cannot be called from a PTB.
  8. For multi-return Move calls, use destructuring or array indexing. const [a, b] = tx.moveCall(...) or const r = tx.moveCall(...); r[0]; r[1];. Do not assume single-return shape.
  9. Cite the docs when unsure. Canonical sources above. Legacy /develop/transactions/ptbs/* URLs still render but prefer /concepts/transactions/prog-txn-blocks and /guides/developer/sui-101/building-ptb.

Common mistakes

  • Calling tx.pure(value) without a type. Untyped pure values fail at input resolution. Use typed helpers: tx.pure.u64(n), tx.pure.address(addr), tx.pure.string(s), or the generic tx.pure('u64', n).
  • Passing a string object ID to moveCall arguments without tx.object(...). Mixed-type arguments require explicit tx.object(id) wrapping; otherwise the SDK can't distinguish pure from object.
  • Transferring or freezing a shared object. Shared objects cannot be transferred or frozen — but they can be deleted. The two legal endings for a shared object in a PTB are re-share or delete. Do not include shared objects in transferObjects. Note that consuming a shared object by value permanently marks its hot-potato clique as "hot", which blocks subsequent non-public entry calls on any entangled value in that clique.
  • Forgetting to setSender on offline builds. When calling tx.build() without signing through a signer that sets the sender, the sender field stays empty and the build fails.
  • Treating multi-return moveCall results as single values. The return is a vector; index or destructure.
  • Using transfer::transfer / transfer::share_object on generic types from a PTB. Those entries require a module-private type param. From a PTB, use transfer::public_transfer / transfer::public_share_object, which require the type to have store.
  • Setting a gas budget that's too tight. A tx that exceeds budget aborts but still charges the gas coin. Prefer the SDK's dry-run-based auto-budget.
  • Not checking execution status. A transaction can be accepted by validators but fail at the Move level (assertion, out of gas, etc.). Always check result.$kind !== 'FailedTransaction' before treating an operation as successful. The tx digest alone does not mean the effects were applied.
  • Looping in app code to submit N individual transactions. Batch into one PTB (up to 1,024 ops). One PTB is cheaper and atomic.

Matgeliwwert Fichieren

De Modell liest dës Dateie bei Bedarf, wärend de Skill gelueden ass. Si ginn als liesbar Dateie bereetgestallt a ginn ni ausgeféiert.

Heefeg gestallte Froen

Wat mécht de KI-Skill Ptbs?

Sui Programmable Transaction Blocks (PTBs). Use when writing, reviewing, or debugging code that composes multiple Sui transaction commands into a single atomic transaction — including TypeScript SDK `Transaction` usage, CLI PTB construction, gas coin handling, sponsored transactions, shared-object inputs, chaining command results, or troubleshooting PTB execution errors.

Firwat Ptbs op TypingMind benotzen?

Well Dir en eemol installéiert a mat all Modell benotze kënnt. Ptbs besteet aus einfachem Markdown amplaz vun ubidderspezifeschem Code. Dee selwechte Skill funktionéiert also mat GPT-5, Claude, Gemini, Grok oder engem lokale Modell – an Dir kënnt de Modell matzen am Chat wiesselen, ouni datt de Skill ophält ze funktionéieren. TypingMind benotzt Är eegen API-Schlësselen, sou datt Dir d'Ubidder direkt bezuelt amplaz vun engem Abonnement pro Benotzerplaz. Är Skills a Chats bleiwen an Ärem eegene Späicher.

Wéi installéieren ech Ptbs an TypingMind?

Maacht an TypingMind Plugins → Skills → Vu GitHub installéieren op a setzt https://github.com/MystenLabs/skills/tree/main/ptbs an. TypingMind liest d'Datei SKILL.md, bündelt déi zougehéiereg Dateien an installéiert dat Ganzt als Skill, deen Dir pro Chat aktivéiere kënnt.

Wéi eng KI-Modeller kënnen Ptbs benotzen?

All Modell, deen Dir an TypingMind verbënnt. KI-Skills sinn einfach Markdown-Instruktiounen an net ubidderspezifesche Code. Dofir kënne GPT, Claude, Gemini, Grok a lokal Modeller dëse Skill lueden, wann eng Ufro dozou passt.

Wéi vill KI-Modeller kann ech mat Ptbs benotzen?

Esou vill Dir wëllt. Soulaang e Modell Skills ënnerstëtzt, kënnt Dir Ptbs domat benotzen – GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama a méi – alles op TypingMind mat Ären eegenen API-Schlësselen.

Ass de KI-Skill Ptbs gratis?

Jo. De Skill gëtt vum MystenLabs ënner der Lizenz Apache-2.0 op GitHub publizéiert. Dir bezuelt nëmmen Ären eegene KI-Ubidder fir d'Token, déi Dir benotzt.

Wat si KI-Skills?

E KI-Skill ass e weiderverwendbaart Pak vun Instruktiounen, dat engem KI-Modell bäibréngt, wéi en eng bestëmmt Aufgab erfëllt. E follegt dem oppenen Agent Skills-Format: eng Datei SKILL.md mat engem Numm an enger Beschreiwung, plus all Scripten, Virlagen oder Referenzdateien, déi de Modell eventuell brauch. De Modell liest d'Instruktiounen eréischt, wann Är Ufro zum Skill passt. En installéierte Skill kascht also näischt, bis e benotzt gëtt.

Wéi ënnerscheede sech KI-Skills vu Plugins oder MCP-Serveren?

E Plugin oder MCP-Server gëtt engem Modell nei Tools, déi en opruffe kann – Code, deen iergendwou leeft an e Resultat zeréckgëtt. E KI-Skill gëtt dem Modell dogéint Wëssen an eng Virgoensweis: wéi en eng Aufgab ugeet, wéi eng Schrëtt en nokënnt a wéi eng gutt Ausgab ausgesäit. Skills bestinn aus einfachem Markdown, brauche kee Server, keen API-Schlëssel a keng Lafzäitëmfeld a funktionéiere mat all Modell.

All weisen

Elo Ären eegene KI-Workspace ariichten

Abonnéiert Iech op eisen Newsletter, fir iwwer nei Funktiounen an zukünfteg Gewënnspiller informéiert ze ginn 👇