You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<p>This contract has a state variable that persists between contract calls, the counter value. When persisted, it's encoded as a <code>uint32</code> - a 32-bit unsigned integer. Contracts pay rent in proportion to the amount of persistent space they consume, so compact representations are encouraged.</p>
63
+
<p>This is a simple counter contract that allows users to increment its value.</p>
64
+
<p>This contract has a state variable <code>val</code> that persists between contract calls - the counter value. When persisted, this variable is encoded <code>as uint32</code> - a 32-bit unsigned integer. Contracts pay rent in proportion to the amount of persistent space they consume, so compact representations are encouraged.</p>
64
65
<p>State variables should be initialized in <code>init()</code> that runs on deployment of the contract.</p>
<p>This contract can receive messages. Unlike getters that are read-only and are free to call, messages can do write operations and change the persistent state. Incoming messages are processed in <code>receive()</code> methods as transactions and cost gas for the sender.</p>
67
-
<p>After deploying the contract, send the <code>increment</code> message by pressing the <spanclass="mdButton grape">Send increment</span> button and then call the getter to see that the value indeed changed.</p>
67
+
<p>This contract can receive <em>messages</em> from users. Unlike getters that are just read-only, messages can do write operations and change the contract's persistent state. Incoming messages are processed in <code>receive()</code> methods as transactions and cost gas for the sender.</p>
68
+
<p>After deploying the contract, send the <code>increment</code> message by pressing the <spanclass="mdButton grape">Send increment</span> button in order to increase the counter value by one. Afterwards, call the getter<code>value()</code> to see that the value indeed changed.</p>
<p>This is probably the simplest possible Tact program. It will provide callers with the classic output "hello world".</p>
64
-
<p>Tact lets you write smart contracts. This code defines a single contract named <code>HelloWorld</code>. Smart contracts must be deployed on-chain to be usable, try to deploy this contract by pressing the <spanclass="mdButton blue">Deploy</span> button.</p>
64
+
<p>Tact lets you write smart contracts. This code defines a single contract named <code>HelloWorld</code>. Smart contracts must be deployed to the blockchain network to be usable, try to deploy this contract by pressing the <spanclass="mdButton blue">Deploy</span> button.</p>
65
+
<p>Contract deployments usually cost gas. This learning tool deploys to an <ahref="https://github.com/tact-lang/tact-emulator">emulator</a> of TON blockchain, so gas is emulated TON coin (which is free).</p>
<p>Contracts can have <em>getters</em> like <code>greeting()</code>. These are special functions that allow users to query information from the contract. Try to call the getter by pressing the <spanclass="mdButton teal">Get greeting</span> button.</p>
67
+
<p>Contracts can have <em>getters</em> like <code>greeting()</code>. Getters are special external interface functions that allow users to query information from the contract. Try to call the getter by pressing the <spanclass="mdButton teal">Get greeting</span> button. Calling getters is free and does not cost gas.</p>
68
+
<p>Getter declarations in Tact always start with the <code>get</code> prefix. The getter must also specify its return type - <code>String</code> in this case. If we were to omit the <code>get</code> from the function declaration, external users would no longer be able call this function and it would essentially become a private method.</p>
0 commit comments