This update introduces a high-level, type-safe way to compose and send messages to other contracts.
No more manual beginCell().storeUint(...).storeRef(...) boilerplate. Just describe the message in a literal, and let the compiler do the rest.
β Notable changes in Tolk v0.99:
1. Universal
createMessage β control body, extra currency, stateInit, and more2. Universal
createExternalLogMessage β emit logs efficiently3. Sharding β calculate addresses "close to another contract"
PR on GitHub with detailed info.
β createMessage: short demo
val reply = createMessage({
bounce: false,
value: ton("0.05"),
dest: senderAddress,
body: RequestedInfo { ... }
});
reply.send(SEND_MODE_REGULAR);
Key features:
1. Supports extra currencies
2. Supports
stateInit with automatic address computation3. Supports different workchains
4. Supports sharding (formerly splitDepth)
5. Integrated with auto-serialization of
body6. Automatically detects "body ref or not"
β Union types as the foundation
Almost every field is a union β flexible API while staying strictly typed:
// value: either tons, or tons + extra currencies
value: ton("1.5")
value: (ton("1.5"), extraDict)
// destination: various forms
dest: someAddress
dest: (workchain, hash)
β Body: inline or ref?
Don't think about refs β the compiler does:
- small structs are inlined
- large ones are wrapped in a ref
- detected at compile-time β no runtime checks
// any serializable struct β no toCell!
body: RequestedInfo { ... }
Don't need body? Just leave it out.
β Deployment: a variant of "destination"
dest: {
workchain: BASECHAIN,
stateInit: { code, data },
}
The beauty of TON is that it doesn't have a dedicated deployment mechanism. You just send a message to some void β and if this void doesn't exist, but you've attached a way to initialize it β it's initialized immediately, and accepts your message.
β Sharding!
Built-in features to calculate an address "in the shard of contract B."
dest: {
...
toShard: {
fixedPrefixLength: 8,
closeTo: ownerAddress,
}
}
Perfect for optimized sharded jettons. All the hashing, StateInit packing, and bit-level work is done automatically.
βοΈ What about gas costs?
Even with all this flexibility,
createMessage is not bloated. The compiler unfolds all union branches and constant conditions at compile time, producing flat, minimal code β often more optimal than hand-crafted cell composition.β v0.99? So, what's next?
Yes, it's the last version before the final release. Tolk now covers the entire initial roadmap and is ready for real-world use. On top of that, we'll add several compiler optimizations and rewrite standard contracts from FunC to Tolk β to demonstrate how exactly everything ties together.