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
{{ message }}
This repository was archived by the owner on Dec 12, 2024. It is now read-only.
Copy file name to clipboardExpand all lines: pages/book/bounced.mdx
+13-11Lines changed: 13 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -2,34 +2,36 @@ import { Callout } from 'nextra-theme-docs'
2
2
3
3
# Bounced messages
4
4
5
-
When a contract sends a message with a flag bounce set to true, then if the message wasn't processed properly, it would bounce back to the sender. This is useful when you want to make sure that the message was processed properly and if not - revert the changes.
5
+
When a contract sends a message with a flag `bounce` set to `true{:tact}`, then if the message wasn't processed properly, it would bounce back to the sender. This is useful when you want to make sure that the message was processed properly and if not — revert the changes.
6
6
7
7
## Caveats
8
8
9
-
Currently in TON bounced messages have only 224 usable data bits in the message and no references. This means that you can't recover much of the data from the bounced message. This is a limitation of the TON blockchain and will be fixed in the future. Tact helps you to check if your message fits the limit and if not - it will suggest to use a special type modifier`bounced<T>` for the receiver that would construct a partial representation that fits into the required limits.
9
+
Currently, bounced messages in TON have only 224 usable data bits in the message body and don't have any references. This means that you can't recover much of the data from the bounced message. This is a limitation of the TON blockchain and will be fixed in the future. Tact helps you to check if your message fits the limit and in case it doesn't — suggests using a special type constructor`bounced<T>{:tact}` for the bounced message receiver, that would construct a partial representation of the message that fits into the required limits.
10
10
11
-
## Bounced messages in Tact
11
+
## Bounced message receiver
12
12
13
13
<Callouttype="warning"emoji="⚠️">
14
-
Bounced text messages are not supported yet.
14
+
15
+
Bounced text messages are not supported yet.
16
+
15
17
</Callout>
16
18
17
-
To receive a bounced message you need to define a `bounced` receiver in your contract or a trait:
19
+
To receive a bounced message, define a `bounced`[receiver function](/book/contracts#receiver-functions)in your [contract](/book/contracts) or a [trait](/book/types#traits):
18
20
19
-
```tact
21
+
```tact {2-4}
20
22
contract MyContract {
21
-
bounced(src: bounced<MyMessage>) {
23
+
bounced(msg: bounced<MyMessage>) {
22
24
// ...
23
25
}
24
26
}
25
27
```
26
28
27
-
To process bounced messages manually, you can use a fallback definition that handles raw `Slice` instead of a message:
29
+
To process bounced messages manually, you can use a fallback definition that handles a raw [`Slice{:tact}`](/book/types#primitive-types) directly. Note, that such receiver will get **all** the bounced messages produced by your contract:
Copy file name to clipboardExpand all lines: pages/book/types.mdx
+2Lines changed: 2 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -44,6 +44,8 @@ Using individual means of storage often becomes cumbersome, so there are ways to
44
44
*[Structs and Messages](#structs-and-messages) — data structures with typed fields.
45
45
*[Optionals](#optionals) — `null{:tact}` values for variables or fields of [Structs and Messages](#structs-and-messages).
46
46
47
+
In addition to the composite types above, Tact provides a special type constructor [`bounced<T>{:tact}`](/book/bounced), which can only be specified in [bounced message receivers](/book/bounced).
48
+
47
49
Note, while [contracts](#contracts) and [traits](#traits) are also considered a part of the Tacts type system, one can't pass them around like [Structs and Messages](#structs-and-messages). Instead, it's possible to obtain the initial state of the given contract by using the [`initOf{:tact}`](/book/expressions#initof) expression.
0 commit comments