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

Commit 64e3950

Browse files
authored
Merge pull request #10 from defi-pickle/send-modes
feat: message modes documentation
2 parents 51841ca + bfc7a74 commit 64e3950

File tree

2 files changed

+42
-6
lines changed

2 files changed

+42
-6
lines changed

pages/language/ref/_meta.json

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
{
2-
"common": "Common",
3-
"strings": "Strings",
4-
"random": "Random",
5-
"math": "Math",
6-
"cells": "Cells, Builders and Slices",
7-
"advanced": "Advanced"
2+
"common": "Common",
3+
"strings": "Strings",
4+
"random": "Random",
5+
"math": "Math",
6+
"cells": "Cells, Builders and Slices",
7+
"message-modes": "Message modes",
8+
"advanced": "Advanced"
89
}

pages/language/ref/message-modes.mdx

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { Callout } from 'nextra-theme-docs';
2+
3+
# Message modes
4+
5+
As you might've noticed, we send messages with `mode` param. To figure out the mode that best suits your needs, take a look at the following table:
6+
7+
| Name | Mode | Description |
8+
| -------------------- | ---- | ---------------------------------------------------------------------------------------------------------------------- |
9+
| SendPayGasSeparately | 1 | Pay transfer fees separately from the message value |
10+
| SendIgnoreErrors | 2 | Ignore any errors arising while processing this message during the action phase |
11+
| SendDestroyIfZero | 32 | Current account must be destroyed if its resulting balance is zero (often used with Mode 128) |
12+
| SendRemainingValue | 64 | Carry all the remaining value of the inbound message in addition to the value initially indicated in the new message |
13+
| SendRemainingBalance | 128 | Carry all the remaining balance of the current smart contract instead of the value originally indicated in the message |
14+
15+
## Combining modes
16+
17+
You can also join modes with _flags_ (modes: 1, 2, 32) in one message, for example:
18+
19+
```tact
20+
let to: Address = ...;
21+
let value: Int = ton("1");
22+
send(SendParameters{
23+
to: to,
24+
value: value,
25+
mode: SendRemainingValue + SendIgnoreErrors,
26+
bounce: true,
27+
body: "Hello, World!".asComment()
28+
});
29+
```
30+
31+
# What to read next?
32+
33+
This article was inspired by the following materials:
34+
35+
- [https://docs.ton.org/develop/smart-contracts/messages#message-modes](https://docs.ton.org/develop/smart-contracts/messages#message-modes)

0 commit comments

Comments
 (0)