awesome-tact
awesome-tact copied to clipboard
Add https://learnxinyminutes.com/docs/tact
We might want to refurbish https://learnxinyminutes.com/docs/tact a bit
Yeah, it's definitely needs correction in many places
For the future reference, this counter contract may be used to showcase Tact at the beginning of the page, then proceed with explanations. Or, this can be put to some later parts, once every detail is explained prior.
import "@stdlib/deploy"; // one of the standard libraries
// Defining a new Message type, which consists of two fields
message Add {
queryId: Int as uint64; // unsigned integer value stored in 8 bytes
amount: Int as uint32; // unsigned integer value stored in 4 bytes
}
// Defining a contract with the Deployable trait from @stdlib/deploy:
contract SimpleCounter with Deployable {
// Persistent state variables of the contract:
id: Int as uint32;
counter: Int as uint32;
// This gets run when the contract is deployed.
// All state variables have to be initialized with either of:
// 1. default values in their definition above
// 2. assignments in the init()
init(id: Int) { // <- you can pass values for deployment
self.id = id; // <- store the id passed on deployment
self.counter = 0; // <- reset the counter
}
// Register a receiver of messages from other contracts.
// Messages in Tact can be one of the two:
// 1. Message type, as defined above
// 2. String type, like "I am the message!"
receive(msg: Add) {
self.counter += msg.amount; // <- increase the counter
}
// This is a getter function, which are special external interface functions
// that allow users to query information from the contract.
get fun counter(): Int {
return self.counter; // <- return the counter value
}
// Another getter function, but for the id:
get fun id(): Int {
return self.id; // <- return the id value
}
}
Just checked X in Y recently and didn't find the Tact there. Turns out (found it by running git log --all -1 -- tact.html.markdown in the repo) that the Tact and some other programming languages got removed on April 29th.
See the commit: https://github.com/adambard/learnxinyminutes-docs/commit/d2efe1c0f929c0186b1489e71f2882649bc79961 And the motivation behind it: https://github.com/adambard/learnxinyminutes-docs/pull/4912
Therefore, I don't think it's feasible to expect Tact there. So we should just continue to improve the docs. Perhaps, the "primer" ("tour" or "overview", to be determined) page is to be introduced there to mimic the nice idea of "learn X in Y minutes" scenic tour. I'm thinking to put it under Book→Cheatsheets may be reasonable.
As an aside, Bitcoin uses https://en.bitcoin.it/wiki/Script, which is a Forth-like stack-based programming language (albeit without loops), so I thought it may have some research on optimizations in it. May help with our future transition to Fift or TVM backends from the current FunC one
Therefore, I don't think it's feasible to expect Tact there. So we should just continue to improve the docs. Perhaps, the "primer" ("tour" or "overview", to be determined) page is to be introduced there to mimic the nice idea of "learn X in Y minutes" scenic tour. I'm thinking to put it under Book→Cheatsheets may be reasonable
Excellent idea! Let's move this stuff there. Could you please open an issue in tact-docs for that?
Could you please open an issue in tact-docs for that?
Sure, here it is: https://github.com/tact-lang/tact/issues/1161
Closing this, since we have the corresponding issue in tact-docs