Address
is another primitive data type. It represents standard addresses on the TON blockchain. Every smart contract on TON is identifiable by its address. Think of this as a unique id.
TON is divided into multiple chains called workchains. This allows to balance the load more effectively. One of the internal fields of the address is the workchain id:
0
- The standard workchain, for regular users. Your contracts will be here.
-1
- The masterchain, usually for validators. Gas on this chain is significantly more expensive, but you'll probably never use it.
There are multiple ways on TON to represent the same address. Notice in the contract that the bouncable and non-bouncable representations of the same address actually generate the exact same value. Inside the contract, it doesn't matter which representation you use.
Most addresses take 264-bit to store (8-bit for the workchain id and 256-bit for the account id). This means that storing 1000 addresses costs about 0.189 TON per year.
All Examplesimport "@stdlib/deploy"; contract Bools with Deployable { // contract persistent state variables b1: Bool = true; b2: Bool = false; b3: Bool; init() { self.b3 = !self.b2; } receive("show all") { dump(self.b1); dump(self.b2); dump(self.b3); } receive("show ops") { let b: Bool = true; // temporary variable dump(b); b = self.b1 && self.b2 || !self.b3; dump(b); dump(self.b1 == true); dump(self.b1 == self.b2); dump(self.b1 != self.b2); } get fun result(): Bool { return self.b1; } }