forked from ton-community/ton-docs
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New translations non-bouncable-messages.md (Chinese Simplified)
- Loading branch information
Showing
1 changed file
with
27 additions
and
0 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
...ntent-docs/current/develop/smart-contracts/guidelines/non-bouncable-messages.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# 非弹回消息 | ||
|
||
```mdx-code-block | ||
export const Highlight = ({children, color}) => ( | ||
<span | ||
style={{ | ||
backgroundColor: color, | ||
borderRadius: '2px', | ||
color: '#fff', | ||
padding: '0.2rem', | ||
}}> | ||
{children} | ||
</span> | ||
); | ||
``` | ||
|
||
几乎所有在智能合约之间发送的内部消息都应该是可弹回的,即应该设置它们的“bounce”位。然后,如果目标智能合约不存在,或者在处理此消息时抛出未处理的异常,消息将被“bounced”,携带原始值的剩余部分(减去所有消息传输和gas费用)。弹回消息的主体将包含32位的`0xffffffff`,紧接着是原始消息的256位,但是“bounce”标志位被清除,“bounced”标志位被设置。因此,所有智能合约都应检查所有入站消息的“bounced”标志,并且要么默默接受它们(通过立即以exit code 0终止),要么执行一些特殊处理来检测哪个出站查询失败了。弹回消息主体中包含的查询永远不应执行。 | ||
|
||
:::info | ||
弹回消息主体中包含的查询<Highlight color="#186E8A">永远不应执行</Highlight>。 | ||
::: | ||
|
||
在某些情况下,必须使用`不可弹回内部消息`。例如,没有发送至少一条不可弹回内部消息给它们,就无法创建新账户。除非这条消息包含一个带有新智能合约的代码和数据的`StateInit`,否则在不可弹回内部消息中拥有非空主体是没有意义的。 | ||
|
||
:::tip | ||
不允许最终用户(例如,钱包的用户)发送包含大量价值(例如,超过五个Toncoin)的不可弹回消息是一个好主意,或者如果他们这样做了就警告他们。更好的做法是先发送少量金额,接着初始化新的智能合约,然后再发送更大的金额。 | ||
::: |