Git Product home page Git Product logo

tact-by-example's People

Contributors

anton-trunov avatar arashnm80 avatar howardpen9 avatar mhbdev avatar novusnota avatar programcrafter avatar sc-one avatar talkol avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

tact-by-example's Issues

How check it's deployed?

in the explainations: https://tact-by-example.org/06-contract-deploy-another , we have this:
When sending any message to a contract, we can attach its stateInit by specifying the code and data fields of the message. This will deploy the contract if it has not already been deployed. If the contract has already been deployed, these fields will be ignored.

Is that meaning it searches in all block chains to find the same address? or how it's doing? And if we send a value below the minimum requirement for storage, what happens?

Light/dark mode requested

Gratitude to all those who contributed to the creation of Tact. I had a pleasant experience recently while reading the website. I was sitting by the beach, enjoying the comments that were elegantly presented in code. However, the absence of a light mode compelled me to return home. It appears that having both dark and light modes has become a standard feature for nearly every website.

Localisation

Maybe someone's already working on it or is it going to be planned?

scroll up on page change

I think it would be easier to read the documents if it goes to the page start when next example or prev example are clicked. currently it stays at the bottom of screen for both of the description and code sections.

which way efficient?

sending init data for each message to the child contract has less cost or saving that id uint32 (or address) in my parent contract?

For the Tact code in 03 - Contract Message, here is my suggestion:

Target:

  • the original code didn't properly set with target as TargetValue(since it is Int)
  • the second contract with message Reach will need parse the counter contract address. To better understanding and implement / test on test-net. here is my update:

import "@stdlib/deploy";

message CounterValue {
    value: Int as uint32;
}

////////////////////////////////////////////////////////////////////////////
// this is our famous Counter contract, we've seen it before
// this contract is very annoying, it only allows to increment +1 at a time!

contract Counter with Deployable {

    val: Int as uint32;

    init() {
        self.val = 0;
    }

    // step 6: this contract allows anyone to ask it to increment by 1 (ie. the other contract)
    receive("increment") {
        self.val = self.val + 1;
        reply(CounterValue{value: self.val}.toCell());
    }

    // step 3: this contract replies with its current value to anyone asking (ie. the other contract)
    receive("query") {
        reply(CounterValue{value: self.val}.toCell());
    }

    get fun value(): Int {
        return self.val;
    }
}

message Reach {
    target_value: Int as uint32;
}

////////////////////////////////////////////////////////////////////////////
// let's write a second helper contract to make our lives a little easier
// it will keep incrementing the previous contract as many times as we need!

contract BulkAdder with Deployable {

    target_value: Int as uint32;

    init() {
        self.target_value = 10;
    }


    // step 1: users will send this message to tell us what target value we need to reach
    receive(msg: Reach) {
        self.target_value = msg.target_value;
        let CounterAddressInit: StateInit = initOf Counter();

        // step 2: this contract will query the current counter value from the other contract
        send(SendParameters{
            to: contractAddress(CounterAddressInit),
            value: 0, /// TODO: https://github.com/tact-lang/tact/issues/31
            mode: SendRemainingValue + SendIgnoreErrors, /// TODO: issues/31
            body: "query".asComment(),
            data: CounterAddressInit.data,
            code: CounterAddressInit.code
        });
    }

    // step 4: the other contract will tell us what is its current value by sending us this message
    receive(msg: CounterValue) {
        if (msg.value < self.target_value) {
            // step 5: if its value is too low, send it another message to increment it by +1 more
            send(SendParameters{
                to: sender(),
                value: 0, /// TODO: same issue 31
                mode: SendRemainingValue + SendIgnoreErrors, /// TODO: https://github.com/tact-lang/tact/issues/31
                body: "increment".asComment()
            });
        }
    }
}

Same Code cant be deployed?!

Hello, I'm a beginner in TON and relative stuff, and I learn those sometimes.
So my question is: how do two developers from around the world who have the same idea deploy their code?

For example, both want to have a counter, and their codes will be equal. So can they deploy their contract?
because in this scenario, their bytecode will be the same! (reference: https://tact-by-example.org/06-calc-contract-address) So the result will be the same unique address !?

I know we can use init and change that with init data.
but it means we should store more variable (and use more gas) just because we have the same idea as another?

results are very hard to read

the box in lower right corner is very small and shows only 1 or 2 lines at a time so most of results are unreadable and I have to copy and paste them to an outer editor every time. can you do sth about it?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.