T
TOLK lang
@tolk_lang
12.06.2025 09:12
🫧 Tolk v0.99: universal message composition

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 more
2. Universal createExternalLogMessage — emit logs efficiently
3. 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 computation
3. Supports different workchains
4. Supports sharding (formerly splitDepth)
5. Integrated with auto-serialization of body
6. 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.
🔥 25
18
🍾 11
😱 3
🆒 3
17 5.5K

Обсуждение 0

Обсуждение не доступно в веб-версии. Чтобы написать комментарий, перейдите в приложение Telegram.

Обсудить в Telegram
T

TOLK lang

844
Channel devoted to TOLK — "next-generation FunC" — a language for writing smart contracts in TON
Открыть в Telegram