TGViewer
TOLK lang TOLK lang @tolk_lang Β· 809 subscribers
Post #21 5.34K
🫧 Tolk v0.13 (Release candidate): Auto-packing to/from cells

We've finally reached the point we've been working toward for the past six months: automatic (de)serialization of anything into cells. From simple structs to unions, generics, and even nested references β€” it just works.

The goal? To replace TL/B entirely with declarative, type-safe definitions. The compiler takes care of packing, loading, estimating, error handling, and more.

βœ… Notable changes in Tolk v0.13:

1. Auto-packing to/from cells/slices/builders
2. Type address
3. Lateinit variables, default parameters, and other minor features

PR on GitHub with detailed info.

βœ” Auto-serialization: short demo


struct Point {
x: int8;
y: int8;
}

var value: Point = { x: 10, y: 20 };

// makes a cell containing "0A14"
var c = value.toCell();
// back to { x: 10, y: 20 }
var p = Point.fromCell(c);


Key features:

* supports all types: unions, tensors, nullables, generics, atomics, ...
* allows to specify prefixes (particularly, opcodes)
* allows to manage cell references and when to load them
* lets you control error codes and other behavior
* unpacks data from a cell or a slice, mutate it or not
* packs data to a cell or a builder
* warns if data potentially exceeds 1023 bits
* more efficient than manual serialization
* will seamlessly integrate with message sending/receiving in Tolk v1.0

βœ” Pack or unpack β€” anywhere

T.fromCell, T.fromSlice, slice.loadAny<T>, builder.storeAny<T>, and other methods give both high-level and low-level API.


// low-level is allowed:
beginCell()
.storeUint(1, 32) // mix manual
.storeAny(myStruct) // with auto


βœ” Serialization prefixes and opcodes


struct (0x7362d09c) TransferNotification {
queryId: uint64;
...
}


They are not limited to 32 bits β€” you can describe any TL/B constructors:

struct (0b001) AssetSimple { ... }
struct (0b100) AssetBooking { ... }
type Asset = AssetSimple | AssetBooking | ...;


βœ” Typed cells


struct A {
    ref1: cell;         // untyped ref
    ref2: Cell<Inner>;  // typed ref
    ref3: Cell<int256>?; // maybe ref
}


Typed cells give you full control over when content is unpacked β€” nothing is loaded unless you call .load() manually:

a.ref2.field // error
a.ref2.load().field // ok


// Yes, point.toCell() really gives you Cell<Point>

βœ” Granular options

Accurately adjust serialization behaviour (for example, error codes):


Point.fromSlice(s, {
assertEndAfterReading: false
})


βœ” Built-in type `address`


struct Wallet {
owner: address;
}


* integrated with auto-serialization, while still a slice under the hood
* comparable: if (senderAddress == wallet.owner)
* introspectable: isInternal(), getWorkchain(), etc.

βœ” Some other features

Described in detail in the full changelog and mirrored in the documentation.

🌳 We're just a couple of steps away from Tolk v1.0 β€” with message sending and handling, gas optimizations, and one secret feature. There is still a lot of work ahead, but today we're closer to the release than ever before.
  • πŸ”₯ 13
  • ❀‍πŸ”₯ 5
  • πŸŽ‰ 3
  • πŸ€” 1
More from @tolk_lang
  1. Jun 23, 2026🫧 Tolk v1.4.x: internal progress and maintenance Since the v1.4 release we've published T…
  2. May 11, 2026🫧 TON enters a new era of smart-contract development I promised this would happen in May.…
  3. Mar 27, 2026🫧 Tolk v1.3: moving toward a general-purpose language After the previous post, this relea…
  4. Mar 19, 2026🫧 Tolk v1.3... not released yet: what's happening inside I know it has been quiet. The la…
  5. Dec 5, 2025🫧 Tolk documentation β€” now complete and available for learning from scratch From now on,…
  6. Nov 14, 2025🫧 Tolk v1.2: rich bounced messages, cheap deployment, and a breaking change that you'll l…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook β†’Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 β†’