Skip to main content

Cells as data storage

In TON, a cell is a built material for the entire blockchain. The cell is a data structure containing:

  • up to 1023 bits of data
  • up to 4 references to other cells
  • cell stores bits and references separated.
  • cell forbids circular references: for any cell, none of its descendant cells can reference this original cell.

Thus, all cells constitute a directed acyclic graph (DAG). Here's a good picture to illustrate:



Cell types

Currently, there are five types of cells: one ordinary cell and four exotic cells. The exotic types are the following:

  • Pruned branch cell
  • Library reference cell
  • Merkle proof cell
  • Merkle update cell
tip

Cell flavors

A cell is an opaque object optimized for compact storage.

It deduplicates data: it only stores the content of several equivalent sub-cells referenced in different branches once. However, one cannot modify or read a cell directly because of its opaqueness. Thus, there are two additional flavors of the cells:

  • Builder is a flavor for constructing cells
  • Slice for a flavor for reading cells

Another unique cell flavor in TVM:

Serialization of data to cells

Any object in TON, like the message, block, or whole blockchain state, serializes to a cell.

A TL-B scheme describes the serialization process: a formal description of how this object can be serialized into builder or how to parse an object of a given type from the Slice. TL-B for cells is the same as TL or ProtoBuf for byte-streams.

If you want more details about cell serialization and deserialization, read Cell & Bag of Cells article.

See also