tact-lang / tact-docs

Tact main documentation
https://docs.tact-lang.org
54 stars 41 forks source link

Document Tact language limitations due to blockchain/TVM/validator limitations #105

Open anton-trunov opened 6 months ago

anton-trunov commented 6 months ago

For instance, how large maps can be, etc.

0kenx commented 5 months ago

This limit is contradictory to our tests. We deployed a contract on testnet and added 66k entries to a map.

https://testnet.tonviewer.com/kQDrXvmitxbGvjpXwRtc5NMuN_4tDkJ83f3myVK04VrviF2v

import "@stdlib/deploy";
import "@stdlib/ownable";
import "./utils/transfer_helpers";

message Increment {
    count: Int;
}

contract MapOnlineTest with Deployable, OwnableTransferable {
    const STORAGE_GAS_RESERVE: Int = ton("0.2");

    owner: Address;
    logo: Int;
    total_map: map<Int, Int>;
    total: Int = 0;

    init(owner: Address, logo: Int) {
        self.owner = owner;
        self.logo = logo;
    }

    receive("fund gas") {}

    receive(msg: Increment) {
        self.requireOwner();
        repeat (msg.count) {
            self.total_map.set(self.total, 1);
            self.total = self.total + 1;
        }

    }

    receive("withdraw dust") {
        self.requireOwner();
        send_ton(
            self.owner,
            myBalance() - self.STORAGE_GAS_RESERVE, 
            false,
            "Dust withdrawn".asComment()
        );
    }

    get fun balance(): Int {
        return myBalance();
    }

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

    get fun total_map(index: Int): Int? {
        return self.total_map.get(index);
    }
}