Slice
TVM type representing a read-only cursor over a cell, used for parsing. To read a cell's contents you turn it into a slice.
Aliases: ton slice, tvm slice
Slice is one of the core TVM types — a read-only cursor over a cell. If a cell is a container of bits and references, a slice is the position from which contents are read: “read 32 bits”, “read the next reference”, and so on.
Lifecycle
A typical TVM cell-reading pattern:
begin_parseturns a cell into a slice — a cursor at the start.load_uint(n),load_addr(),load_ref()— operations that read by type. Each one advances the cursor.end_parseasserts the slice was fully consumed (anything left over is an error).
Tact and Tolk hide this from you: the compiler generates parsing code from message/struct declarations. In FunC the slice is always explicit.
Slice vs Cell
| Property | Cell | Slice |
|---|---|---|
| Purpose | hold data | read data |
| Mutability | immutable | cursor advances |
| Used in | storage, message body | parsing |
| Created from | builder.end() | cell.begin_parse() |
A cell is the “file”; a slice is the “open reader with a position”.
Things to keep in mind
- A slice doesn’t copy data. It points at the same cell and tracks its current position and remaining bits.
- If a slice still has a child reference, you read it with
load_ref()and thenbegin_parse()on the resulting cell — recursively. - Gas depends on what you read, not on what the source cell holds. Reading only what you need is a real optimisation.
Slices are the foundation of all parsing: message bodies, contract storage, ABI arguments.