|
1 | 1 | # Configuration
|
2 | 2 |
|
3 |
| -`tact.config.json` is an entry point to Tact projects. It is a JSON file that contains the list of all projects and compiler parameters. |
| 3 | +import { Callout } from 'nextra/components' |
4 | 4 |
|
5 |
| -## Project description |
| 5 | +The behavior of Tact compiler can be customized using its configuration file, `tact.config.json` — a JSON file that contains the list of settings according to the specific [schema](#schema). |
6 | 6 |
|
7 |
| -Each project is described by the following fields: |
8 |
| -* `name` is the name of a project. All generated files are prefixed with this name. |
9 |
| -* `path` is the path to a root Tact file. |
10 |
| -* `output` is the path to a directory where all generated files will be placed. |
11 |
| -* `parameters` is a dictionary of parameters that will be passed to a compiler. |
12 |
| -* `experimental` is a dictionary of experimental features that will be enabled for this project. |
| 7 | +This page lists all of the configuration options as they're structured in the [schema](#schema). Look for table of contents on the right to easily navigate them. |
13 | 8 |
|
14 |
| -## Parameters |
| 9 | +<Callout> |
15 | 10 |
|
16 |
| -Tact support next parameters: |
17 |
| -* `debug: true`. Enables debug output of a contract. It is useful for debugging purposes. Enabling this contract would report that it was compiled in debug mode using the `supported_interfaces` method. |
18 |
| -* `masterchain: true`. Enables [masterchain support](/language/guides/masterchain) in the contract. |
| 11 | + The only requirement for that file is to be a valid JSON with [proper fields](#schema), so it can be named arbitrarily. However, naming your config file as `tact.config.json` is a common convention encouraged and supported by all tools working with Tact. |
19 | 12 |
|
20 |
| -## Example |
| 13 | +</Callout> |
21 | 14 |
|
22 |
| -```json |
| 15 | +## `$schema` [#schema] |
| 16 | + |
| 17 | +A [JSON schema](https://json-schema.org/) file is available for editors to provide autocompletion and hover hints: [configSchema.json](http://raw.githubusercontent.com/tact-lang/tact/main/grammar/configSchema.json). |
| 18 | + |
| 19 | +Simply add the `$schema` field on top your configuration file: |
| 20 | + |
| 21 | +```json filename="tact.config.json" {2} |
| 22 | +{ |
| 23 | + "$schema": "http://raw.githubusercontent.com/tact-lang/tact/main/grammar/configSchema.json", |
| 24 | + "projects": [] |
| 25 | +} |
| 26 | +``` |
| 27 | + |
| 28 | +## `projects` [#projects] |
| 29 | + |
| 30 | +List of Tact projects with respective compilation options. Each `.tact` file represents its own Tact project. |
| 31 | + |
| 32 | +```json filename="tact.config.json" {3,4} |
| 33 | +{ |
| 34 | + "projects": [ |
| 35 | + { }, |
| 36 | + { } |
| 37 | + ] |
| 38 | +} |
| 39 | +``` |
| 40 | + |
| 41 | +### `name` [#projects-name] |
| 42 | + |
| 43 | +Name of the project. All generated files are prefixed with it. |
| 44 | + |
| 45 | +In [Blueprint][bp], `name` refers to the name of the contract itself. |
| 46 | + |
| 47 | +```json filename="tact.config.json" {4,7} |
| 48 | +{ |
| 49 | + "projects": [ |
| 50 | + { |
| 51 | + "name": "some_prefix" |
| 52 | + }, |
| 53 | + { |
| 54 | + "name": "ContractUnderBlueprint" |
| 55 | + } |
| 56 | + ] |
| 57 | +} |
| 58 | +``` |
| 59 | + |
| 60 | +### `path` [#projects-path] |
| 61 | + |
| 62 | +Path to the project's Tact file. You can only specify one Tact file per project. |
| 63 | + |
| 64 | +In [Blueprint][bp], `path` is superseded by the `target` field in `wrappers/ContractName.compile.ts`. |
| 65 | + |
| 66 | +```json filename="tact.config.json" {5} |
| 67 | +{ |
| 68 | + "projects": [ |
| 69 | + { |
| 70 | + "name": "some_prefix", |
| 71 | + "path": "./contract.tact" |
| 72 | + } |
| 73 | + ] |
| 74 | +} |
| 75 | +``` |
| 76 | + |
| 77 | +### `output` [#projects-output] |
| 78 | + |
| 79 | +Path to the directory where all generated files will be placed. |
| 80 | + |
| 81 | +In [Blueprint][bp], `output` is not used and all generated files are always placed in `build/ProjectName/`. |
| 82 | + |
| 83 | +```json filename="tact.config.json" {6} |
| 84 | +{ |
| 85 | + "projects": [ |
| 86 | + { |
| 87 | + "name": "some_prefix", |
| 88 | + "path": "./contract.tact", |
| 89 | + "output": "./contract_output" |
| 90 | + } |
| 91 | + ] |
| 92 | +} |
| 93 | +``` |
| 94 | + |
| 95 | +### `options` [#projects-options] |
| 96 | + |
| 97 | +Compilation options for the project. |
| 98 | + |
| 99 | +In [Blueprint][bp], they act as default unless modified in `wrappers/ContractName.compile.ts`. |
| 100 | + |
| 101 | +```json filename="tact.config.json" {7,11} |
| 102 | +{ |
| 103 | + "projects": [ |
| 104 | + { |
| 105 | + "name": "some_prefix", |
| 106 | + "path": "./contract.tact", |
| 107 | + "output": "./contract_output", |
| 108 | + "options": {} |
| 109 | + }, |
| 110 | + { |
| 111 | + "name": "ContractUnderBlueprint", |
| 112 | + "options": {} |
| 113 | + } |
| 114 | + ] |
| 115 | +} |
| 116 | +``` |
| 117 | + |
| 118 | +#### `debug` [#options-debug] |
| 119 | + |
| 120 | +`false{:json}` by default. |
| 121 | + |
| 122 | +If set to `true{:json}`, enables debug output of a contract and allows usage of [`dump(){:tact}`](/ref/api-debug#dump) function, which is useful for [debugging purposes](/book/debug). With this option enabled, the contract will report that it was compiled in debug mode using the `supported_interfaces` method. |
| 123 | + |
| 124 | +```json filename="tact.config.json" {8,14} |
23 | 125 | {
|
24 | 126 | "projects": [
|
25 | 127 | {
|
26 |
| - "name": "sample", |
27 |
| - "path": "./sources/sample.tact", |
28 |
| - "output": "./sources/output", |
| 128 | + "name": "some_prefix", |
| 129 | + "path": "./contract.tact", |
| 130 | + "output": "./contract_output", |
| 131 | + "options": { |
| 132 | + "debug": true |
| 133 | + } |
| 134 | + }, |
| 135 | + { |
| 136 | + "name": "ContractUnderBlueprint", |
| 137 | + "options": { |
| 138 | + "debug": true |
| 139 | + } |
| 140 | + } |
| 141 | + ] |
| 142 | +} |
| 143 | +``` |
| 144 | + |
| 145 | +<Callout> |
| 146 | + |
| 147 | + Read more on the dedicated page: [Debugging](/book/debug). |
| 148 | + |
| 149 | +</Callout> |
| 150 | + |
| 151 | +#### `masterchain` [#options-masterchain] |
| 152 | + |
| 153 | +`false{:json}` by default. |
| 154 | + |
| 155 | +If set to `true{:json}`, enables [masterchain](/book/masterchain) support. |
| 156 | + |
| 157 | +```json filename="tact.config.json" {8,14} |
| 158 | +{ |
| 159 | + "projects": [ |
| 160 | + { |
| 161 | + "name": "some_prefix", |
| 162 | + "path": "./contract.tact", |
| 163 | + "output": "./contract_output", |
| 164 | + "options": { |
| 165 | + "masterchain": true |
| 166 | + } |
| 167 | + }, |
| 168 | + { |
| 169 | + "name": "ContractUnderBlueprint", |
| 170 | + "options": { |
| 171 | + "masterchain": true |
| 172 | + } |
| 173 | + } |
| 174 | + ] |
| 175 | +} |
| 176 | +``` |
| 177 | + |
| 178 | +<Callout> |
| 179 | + |
| 180 | + Read more on the dedicated page: [Masterchain](/book/masterchain). |
| 181 | + |
| 182 | +</Callout> |
| 183 | + |
| 184 | +#### `external` [#options-external] |
| 185 | + |
| 186 | +`false{:json}` by default. |
| 187 | + |
| 188 | +If set to `true{:json}`, enables support of [external](/book/external) message receivers. |
| 189 | + |
| 190 | +```json filename="tact.config.json" {8,14} |
| 191 | +{ |
| 192 | + "projects": [ |
| 193 | + { |
| 194 | + "name": "some_prefix", |
| 195 | + "path": "./contract.tact", |
| 196 | + "output": "./contract_output", |
| 197 | + "options": { |
| 198 | + "external": true |
| 199 | + } |
| 200 | + }, |
| 201 | + { |
| 202 | + "name": "ContractUnderBlueprint", |
| 203 | + "options": { |
| 204 | + "external": true |
| 205 | + } |
| 206 | + } |
| 207 | + ] |
| 208 | +} |
| 209 | +``` |
| 210 | + |
| 211 | +<Callout> |
| 212 | + |
| 213 | + Read more on the dedicated page: [External messages](/book/external). |
| 214 | + |
| 215 | +</Callout> |
| 216 | + |
| 217 | +#### `experimental` [#options-experimental] |
| 218 | + |
| 219 | +Experimental options that might be removed in the future. Use with caution! |
| 220 | + |
| 221 | +```json filename="tact.config.json" {8,14} |
| 222 | +{ |
| 223 | + "projects": [ |
| 224 | + { |
| 225 | + "name": "some_prefix", |
| 226 | + "path": "./contract.tact", |
| 227 | + "output": "./contract_output", |
| 228 | + "options": { |
| 229 | + "experimental": {} |
| 230 | + } |
| 231 | + }, |
| 232 | + { |
| 233 | + "name": "ContractUnderBlueprint", |
| 234 | + "options": { |
| 235 | + "experimental": {} |
| 236 | + } |
| 237 | + } |
| 238 | + ] |
| 239 | +} |
| 240 | +``` |
| 241 | + |
| 242 | +##### `inline` [#experimental-inline] |
| 243 | + |
| 244 | +`false{:json}` by default. |
| 245 | + |
| 246 | +If set to `true{:json}`, enables inlining of all functions in contracts. This can reduce gas usage at the cost of bigger contracts. |
| 247 | + |
| 248 | +```json filename="tact.config.json" {9,17} |
| 249 | +{ |
| 250 | + "projects": [ |
| 251 | + { |
| 252 | + "name": "some_prefix", |
| 253 | + "path": "./contract.tact", |
| 254 | + "output": "./contract_output", |
29 | 255 | "options": {
|
30 |
| - "debug": true, |
31 | 256 | "experimental": {
|
32 | 257 | "inline": true
|
33 | 258 | }
|
34 | 259 | }
|
| 260 | + }, |
| 261 | + { |
| 262 | + "name": "ContractUnderBlueprint", |
| 263 | + "options": { |
| 264 | + "experimental": { |
| 265 | + "inline": true |
| 266 | + } |
| 267 | + } |
| 268 | + } |
| 269 | + ] |
| 270 | +} |
| 271 | +``` |
| 272 | + |
| 273 | +### `mode` [#projects-mode] |
| 274 | + |
| 275 | +Compilation mode of the project. Valid values are: |
| 276 | + |
| 277 | +Value | Description |
| 278 | +:------------------- | :---------- |
| 279 | +`"full"{:json}` | (default) Runs the whole pipeline of the compilation and emits FunC code, BoC and various utility files, including wrappers for TypeScript. |
| 280 | +`"checkOnly"{:json}` | Only performs syntax and type checking, preventing further compilation. |
| 281 | +`"funcOnly"{:json}` | Only outputs intermediate FunC code, preventing further compilation. |
| 282 | + |
| 283 | +In [Blueprint][bp], `mode` is always set to `"full"{:json}` and cannot be overwritten. |
| 284 | + |
| 285 | +```json filename="tact.config.json" {7,13} |
| 286 | +{ |
| 287 | + "projects": [ |
| 288 | + { |
| 289 | + "name": "some_prefix", |
| 290 | + "path": "./contract.tact", |
| 291 | + "output": "./contract_output", |
| 292 | + "mode": "full" |
| 293 | + }, |
| 294 | + { |
| 295 | + "name": "func_only", |
| 296 | + "path": "./contract.tact", |
| 297 | + "output": "./contract_output", |
| 298 | + "mode": "funcOnly" |
35 | 299 | }
|
36 | 300 | ]
|
37 | 301 | }
|
38 | 302 | ```
|
39 | 303 |
|
40 |
| -## Experimental |
| 304 | +## Full example |
41 | 305 |
|
42 |
| -Tact support next experimental parameters: |
| 306 | +```json filename="tact.config.json" copy=false |
| 307 | +{ |
| 308 | + "$schema": "http://raw.githubusercontent.com/tact-lang/tact/main/grammar/configSchema.json", |
| 309 | + "projects": [ |
| 310 | + { |
| 311 | + "name": "basic", |
| 312 | + "path": "./basic.tact", |
| 313 | + "output": "./basic_output", |
| 314 | + "mode": "full" |
| 315 | + }, |
| 316 | + { |
| 317 | + "name": "func_only", |
| 318 | + "path": "./basic.tact", |
| 319 | + "output": "./basic_output", |
| 320 | + "mode": "funcOnly" |
| 321 | + }, |
| 322 | + { |
| 323 | + "name": "debugPrefix", |
| 324 | + "path": "./contracts/contract.tact", |
| 325 | + "output": "./contracts/output", |
| 326 | + "options": { |
| 327 | + "debug": true |
| 328 | + } |
| 329 | + }, |
| 330 | + { |
| 331 | + "name": "ContractUnderBlueprint", |
| 332 | + "options": { |
| 333 | + "debug": false, |
| 334 | + "masterchain": false, |
| 335 | + "external": false, |
| 336 | + "experimental": { |
| 337 | + "inline": false |
| 338 | + } |
| 339 | + } |
| 340 | + } |
| 341 | + ] |
| 342 | +} |
| 343 | +``` |
43 | 344 |
|
44 |
| -* `inline: true`. Enables inlining of all functions in contracts. Could reduce gas usage at the cost of a bigger contract. |
| 345 | +[bp]: https://github.com/ton-org/blueprint |
0 commit comments