Introduction
What PTBVM is and why it exists.
PTBVM is a composition VM for Solana. You describe a plan, an ordered list of program calls, and PTBVM runs it as one atomic transaction, piping the on-chain result of each call into the next through a register file. It is the neutral substrate a team would otherwise hand-roll as its own router program, generalized once for any program.
The problem it solves
On Solana, the top-level instructions in a transaction run independently. There is no built-in way to feed one instruction's runtime output into the next: if a swap produces 150 tokens, your client has to read that number back and hard-code it into the deposit, or you deploy a bespoke program that does both. Sui's programmable transaction blocks chain call results natively. PTBVM brings the achievable part of that to the SVM.
Mental model
- Step. One CPI into an arbitrary program. It can capture its return value into a register.
- Register. A slot in an on-chain register file that carries a value from one step into a later step's instruction data.
- Obligation gate. A hot-potato counter. If a step opens an obligation and no later step closes it, the whole transaction reverts.
- Plan. The ordered list of steps, compiled to a single instruction against the PTBVM program.
The whole flow at a glance
The client compiles a plan to one execute instruction. On chain, the VM runs each step as a CPI, optionally captures its result into a register, splices that register into the next step, and finally runs the gate, which commits the whole transaction or reverts all of it.
In this section
- Your first plan: The shortest path from one program call to a two-step piped plan.