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
Copy file name to clipboardExpand all lines: docs/v3/guidelines/quick-start/developing-smart-contracts/func-tolk-folder/deploying-to-network.mdx
+1Lines changed: 1 addition & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -57,6 +57,7 @@ Now that our smart contracts are fully tested, we are ready to deploy them to TO
57
57
Deployment scripts rely on the same wrappers that you have used in testing scripts. We will use one common script to deploy both of the previously deployed smart contracts. Update `deployHelloWorld.ts` with this code:
Copy file name to clipboardExpand all lines: docs/v3/guidelines/quick-start/developing-smart-contracts/tact-folder/tact-storage-and-get-methods.mdx
+33-32Lines changed: 33 additions & 32 deletions
Original file line number
Diff line number
Diff line change
@@ -60,7 +60,7 @@ Using this structure, a message can be sent to the contract from FunC.
60
60
The [contract](https://docs.tact-lang.org/book/contracts/) definition in Tact follows an object-oriented programming style:
61
61
62
62
```tact
63
-
contract CounterInternal {
63
+
contract HelloWorld {
64
64
...
65
65
}
66
66
```
@@ -76,7 +76,7 @@ counter: Int as uint32;
76
76
77
77
To ensure that only the contract owner can interact with specific functions, add an `owner` field:
78
78
79
-
```tact title="/contracts/counter_internal.tact"
79
+
```tact title="/contracts/hello_world.tact"
80
80
id: Int as uint32;
81
81
counter: Int as uint32;
82
82
owner: Address;
@@ -88,7 +88,7 @@ These fields are serialized similarly to structures and stored in the contract's
88
88
89
89
If you compile the contract at this stage, you will encounter the error: `Field "owner" is not set`. This is because the contract needs to initialize its fields upon deployment. Define an [`init()`](https://docs.tact-lang.org/book/contracts/#init-function/) function to do this:
To accept messages from other contracts, use a [receiver](https://docs.tact-lang.org/book/functions/#receiver-functions) function. Receiver functions automatically match the message's opcode and invoke the corresponding function:
102
102
103
-
```tact title="/contracts/counter_internal.tact"
103
+
```tact title="/contracts/hello_world.tact"
104
104
receive(msg: Add) {
105
105
self.counter += msg.amount;
106
106
self.notify("Cashback".asComment());
@@ -109,7 +109,7 @@ receive(msg: Add) {
109
109
110
110
For accepting messages with empty body you can add `recieve` function with no arguments:
111
111
112
-
```tact title="/contracts/counter_internal.tact"
112
+
```tact title="/contracts/hello_world.tact"
113
113
receive() {
114
114
cashback(sender())
115
115
}
@@ -120,7 +120,7 @@ receive() {
120
120
121
121
Tact also provides handy ways to share same logic through [traits](https://docs.tact-lang.org/book/types/#traits). To ensure that only the contract owner can send messages, use the `Ownable` trait, which provides built-in ownership checks:
Get function cannot be called from another contract.
150
150
:::
151
151
152
-
```tact title="/contracts/counter_internal.tact"
152
+
```tact title="/contracts/hello_world.tact"
153
153
get fun counter(): Int {
154
154
return self.counter;
155
155
}
@@ -159,7 +159,7 @@ Note, that the `owner` getter is automatically defined via the `Ownable` trait.
159
159
160
160
#### Complete contract
161
161
162
-
```tact title="/contracts/counter_internal.tact"
162
+
```tact title="/contracts/hello_world.tact"
163
163
import "@stdlib/ownable";
164
164
165
165
// message with opcode
@@ -169,7 +169,7 @@ message(0x7e8764ef) Add {
169
169
}
170
170
171
171
// Contract defenition. `Ownable` is a trait to share functionality.
172
-
contract CounterInternal with Ownable {
172
+
contract HelloWorld with Ownable {
173
173
174
174
// storage variables
175
175
id: Int as uint32;
@@ -233,7 +233,7 @@ Expected output should look like this:
233
233
234
234
[Wrappers](https://docs.tact-lang.org/book/compile/#wrap-ts) facilitate contract interaction from TypeScript. Unlike in FunC or Tolk, they are generated automatically during the build process:
0 commit comments