Skip to main content
T TON Adoption
← Glossary
NODE/03 · Term

Builder

TVM type for constructing a cell step by step. Bits and references are appended to a builder, then sealed into an immutable cell.

Aliases: ton builder, tvm builder

Builder is a TVM type symmetric to slice. Where slice is a cursor for reading a cell, builder is the mutable buffer for constructing a new cell. You append bits, integers, and references to it, then seal the result into a cell.

Lifecycle

begin_cell()                  ;; create an empty builder
   .store_uint(0xf8a7ea5, 32) ;; append a 32-bit opcode
   .store_uint(0, 64)         ;; append query_id
   .store_coins(amount)       ;; append a VarUInteger amount
   .store_slice(addr)         ;; append destination address
   .end_cell()                ;; seal as cell

After end_cell() the cell is immutable; you can store it, embed it in an outgoing message, or place it in a dictionary.

What a builder holds

At any moment a builder tracks:

  • The current bit buffer (accumulated bits, up to 1023).
  • A list of references to child cells (up to 4).

Exceeding either limit raises a compile- or run-time error. When data exceeds a single cell’s capacity you build a tree — push some bytes into a child cell and store a reference to it.

Builder vs Cell vs Slice

TypeRoleMutability
Builderconstruct a new cellmutable
Cellhold dataimmutable
Sliceread a cellread-only cursor

The “read → rebuild” loop in TVM is always slice → builder → cell: parse a slice, write into a builder along the way, seal at the end.

In Tact and Tolk

High-level languages mostly hide builders: the compiler emits serialisation code from message/struct declarations. Developers drop down to builder/slice manually only when optimising hot paths or working with custom binary formats.

Related terms