Skip to content
This repository was archived by the owner on Dec 12, 2024. It is now read-only.

Commit a241764

Browse files
committed
chore: Started the big move
1 parent df1b928 commit a241764

31 files changed

+209
-165
lines changed

pages/_meta.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ export default {
1515
title: "Cookbook",
1616
type: 'page',
1717
},
18-
language: {
19-
title: "Language",
18+
ref: {
19+
title: "Reference",
2020
type: 'page',
2121
},
2222
ecosystem: {

pages/language/_meta.js

Lines changed: 0 additions & 20 deletions
This file was deleted.

pages/language/libs/_meta.js

Lines changed: 0 additions & 9 deletions
This file was deleted.

pages/language/ref/_meta.js

Lines changed: 0 additions & 8 deletions
This file was deleted.

pages/ref/_meta.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
export default {
2+
index: 'Overview',
3+
spec: 'Specification',
4+
evolution: 'Evolution',
5+
'-- API': {
6+
type: 'separator',
7+
title: 'API Reference',
8+
},
9+
'api-base': 'Base trait',
10+
'api-comptime': 'Compile-time',
11+
'api-common': 'Common', // what does it mean???
12+
'api-strings': 'Strings', // text.tact + ...
13+
'api-random': 'Random',
14+
'api-math': 'Math',
15+
'api-cells': 'Cells, Builders and Slices',
16+
'api-advanced': 'Advanced',
17+
'-- Stdlib': {
18+
type: 'separator',
19+
title: 'Standard Libraries',
20+
},
21+
'standard-libraries': 'Overview',
22+
'stdlib-config': '@stdlib/config',
23+
'stdlib-content': '@stdlib/content',
24+
'stdlib-deploy': '@stdlib/deploy',
25+
'stdlib-dns': '@stdlib/dns',
26+
'stdlib-ownable': '@stdlib/ownable',
27+
'stdlib-stoppable': '@stdlib/stoppable',
28+
'-- Community': {
29+
type: 'separator',
30+
},
31+
'telegram-link': {
32+
title: '✈️ Telegram',
33+
href: 'https://t.me/tactlang',
34+
newWindow: true
35+
},
36+
'xtwitter-link': {
37+
title: '🐦 X/Twitter',
38+
href: 'https://twitter.com/tact_language',
39+
newWindow: true
40+
},
41+
}
File renamed without changes.

pages/ref/api-base.mdx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Base trait
2+
3+
import { Callout } from 'nextra-theme-docs'
4+
5+
Every [contract](/book/contracts) and [trait](/book/types#traits) in Tact implicitly inherits the `Base{:tact}` trait, which contains a number of the most useful [internal functions (methods)](/book/contracts#internal-functions) for any kind of contract.
6+
7+
<Callout emoji="🚨">
8+
9+
This page is a stub. [Contributions are welcome!](https://github.com/tact-lang/tact-docs/issues)
10+
11+
</Callout>
File renamed without changes.

pages/language/ref/common.mdx renamed to pages/ref/api-common.mdx

Lines changed: 5 additions & 122 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
import { Callout } from 'nextra-theme-docs'
44

5-
List of a basic functions that are available in all smart contracts.
5+
List of the most commonly used built-in [global static functions](/book/functions#global-static-functions).
6+
67

78
## sender
89

@@ -32,21 +33,6 @@ receive() {
3233

3334
</Callout>
3435

35-
## require
36-
37-
```tact
38-
fun require(condition: Bool, error: String);
39-
```
40-
41-
Checks the `condition` and throws an exception with `error` message if the `condition` is `false{:tact}`. Does nothing otherwise.
42-
43-
Usage example:
44-
45-
```tact
46-
// now() has to return a value greater than 1000, otherwise an error message will be thrown
47-
require(now() > 1000, "We're in the first 1000 seconds of 1 January 1970!");
48-
```
49-
5036
## now
5137

5238
```tact
@@ -164,23 +150,11 @@ let hereBeDragons: Address = contractAddressExt(0, initPkg.code, initPkg.data);
164150

165151
</Callout>
166152

167-
## address
168-
169-
```tact
170-
fun address(s: String): Address;
171-
```
172-
173-
A compile-time function that converts a [`String{:tact}`][p] with an address into the Address type.
153+
<Callout>
174154

175-
Usage example:
155+
For this function to work, the compiler option `debug` has to be set to `true{:tact}` for the current project in the [configuration file](/book/config). Read more about debugging on the dedicated page: [Debugging](/book/debug).
176156

177-
```tact
178-
contract Example {
179-
// Persistent state variables
180-
addr: Address =
181-
address("EQCD39VS5jcptHL8vMjEXrzGaRcCVYto7HUn4bpAOg8xqB2N"); // works at compile-time!
182-
}
183-
```
157+
</Callout>
184158

185159
## emit
186160

@@ -196,97 +170,6 @@ Usage example:
196170
emit("Catch me if you can".asComment()); // asComment() converts a String to a Cell
197171
```
198172

199-
## cell
200-
201-
```tact
202-
fun cell(bocBase64: String): Cell;
203-
```
204-
205-
A compile-time function that embeds a base64-encoded [BoC](https://docs.ton.org/develop/data-formats/cell-boc#bag-of-cells) `bocBase64` as a [`Cell{:tact}`][p] into the contract.
206-
207-
Usage example:
208-
209-
```tact
210-
// Init package for Wallet V3R1 as a base64-encoded BoC:
211-
cell("te6cckEBAQEAYgAAwP8AIN0gggFMl7qXMO1E0NcLH+Ck8mCDCNcYINMf0x/TH/gjE7vyY+1E0NMf0x/T/9FRMrryoVFEuvKiBPkBVBBV+RDyo/gAkyDXSpbTB9QC+wDo0QGkyMsfyx/L/8ntVD++buA=");
212-
```
213-
214-
<Callout>
215-
216-
**Useful links:**\
217-
[Bag of Cells in TON Docs](https://docs.ton.org/develop/data-formats/cell-boc#bag-of-cells)
218-
219-
</Callout>
220-
221-
## ton
222-
223-
```tact
224-
fun ton(value: String): Int;
225-
```
226-
227-
A compile-time function that converts the given Toncoins `value` from a human-readable format [`String{:tact}`][p] to the nanoToncoins [`Int{:tact}`][int] format.
228-
229-
Usage example:
230-
231-
```tact
232-
ton("1"); // 10^9 nanoToncoins, which is equal to one Toncoin
233-
ton("0.1"); // 10^8 nanoToncoins, which is equal to 0.1 Toncoin
234-
ton("0.000000001"); // 1 nanoToncoin, which is equal to 10^-9 Toncoins
235-
```
236-
237-
## dump
238-
239-
```tact
240-
fun dump(arg);
241-
```
242-
243-
Prints the argument `arg` to the contract's debug console. Evaluated only if `debug` option is set in the [configuration file](/book/config), otherwise does nothing.
244-
245-
Can be applied to the following list of types and values:
246-
247-
* [`Int{:tact}`][int]
248-
* [`Bool{:tact}`][bool]
249-
* [`Builder{:tact}`][p], [`Cell{:tact}`][p] or [`Slice{:tact}`][p]
250-
* [`String{:tact}`][p] or [`StringBuilder{:tact}`][p]
251-
* [`map<k, v>{:tact}`](/book/maps)
252-
* [Optionals and `null{:tact}` value](/book/optionals)
253-
* `void`, which is implicitly returned when a function doesn't have return value defined
254-
255-
Usage examples:
256-
257-
```tact
258-
// Int
259-
dump(42);
260-
261-
// Bool
262-
dump(true);
263-
dump(false);
264-
265-
// Builder, Cell or Slice
266-
dump(beginCell()); // Builder
267-
dump(emptyCell()); // Cell
268-
dump(emptyCell().asSlice()); // Slice
269-
270-
// String or StringBuilder
271-
dump("Hello, my name is..."); // String
272-
dump(beginTailString()); // StringBuilder
273-
274-
// Maps
275-
let m: map<Int, Int> = emptyMap();
276-
m.set(2 + 2, 4);
277-
dump(m);
278-
279-
// Special values
280-
dump(null);
281-
dump(emit("msg".asComment())); // As emit() function doesn't return a value, dump() would print #DEBUG#: void.
282-
```
283-
284-
<Callout>
285-
286-
For this function to work, the compiler option `debug` has to be set to `true{:tact}` for the current project in the [configuration file](/book/config). Read more about debugging on the dedicated page: [Debugging](/book/debug).
287-
288-
</Callout>
289-
290173
## context
291174

292175
```tact

pages/ref/api-comptime.mdx

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Compile-time
2+
3+
import { Callout } from 'nextra-theme-docs'
4+
5+
This page lists all the built-in [global static functions](/book/functions#global-static-functions), which are evaluated at the time of building the Tact project (compile-time).
6+
7+
## address
8+
9+
```tact
10+
fun address(s: String): Address;
11+
```
12+
13+
A compile-time function that converts a [`String{:tact}`][p] with an address into the Address type.
14+
15+
Usage example:
16+
17+
```tact
18+
contract Example {
19+
// Persistent state variables
20+
addr: Address =
21+
address("EQCD39VS5jcptHL8vMjEXrzGaRcCVYto7HUn4bpAOg8xqB2N"); // works at compile-time!
22+
}
23+
```
24+
25+
## cell
26+
27+
```tact
28+
fun cell(bocBase64: String): Cell;
29+
```
30+
31+
A compile-time function that embeds a base64-encoded [BoC](https://docs.ton.org/develop/data-formats/cell-boc#bag-of-cells) `bocBase64` as a [`Cell{:tact}`][p] into the contract.
32+
33+
Usage example:
34+
35+
```tact
36+
// Init package for Wallet V3R1 as a base64-encoded BoC:
37+
cell("te6cckEBAQEAYgAAwP8AIN0gggFMl7qXMO1E0NcLH+Ck8mCDCNcYINMf0x/TH/gjE7vyY+1E0NMf0x/T/9FRMrryoVFEuvKiBPkBVBBV+RDyo/gAkyDXSpbTB9QC+wDo0QGkyMsfyx/L/8ntVD++buA=");
38+
```
39+
40+
<Callout>
41+
42+
**Useful links:**\
43+
[Bag of Cells in TON Docs](https://docs.ton.org/develop/data-formats/cell-boc#bag-of-cells)
44+
45+
</Callout>
46+
47+
## ton
48+
49+
```tact
50+
fun ton(value: String): Int;
51+
```
52+
53+
A compile-time function that converts the given Toncoins `value` from a human-readable format [`String{:tact}`][p] to the nanoToncoins [`Int{:tact}`][int] format.
54+
55+
Usage example:
56+
57+
```tact
58+
ton("1"); // 10^9 nanoToncoins, which is equal to one Toncoin
59+
ton("0.1"); // 10^8 nanoToncoins, which is equal to 0.1 Toncoin
60+
ton("0.000000001"); // 1 nanoToncoin, which is equal to 10^-9 Toncoins
61+
```
62+
63+
[p]: /book/types#primitive-types
64+
[bool]: /book/types#booleans
65+
[int]: /book/integers

0 commit comments

Comments
 (0)