Single-contract communication
This page lists examples of communication of a single deployed contract with other contracts on blockchain.
For examples of communication between multiple deployed contracts see: Multi-contract communication.
How to make a basic reply
▶️ Open in Web IDEHow to send a simple message
▶️ Open in Web IDEHow to send a message with the entire balance
If we need to send the whole balance of the smart contract, then we should use the SendRemainingBalance
send mode. Alternatively, we can use mode: 128
, which has the same meaning.
How to send a message with the remaining value
If we want to make a reply to the same sender, we can use the mode SendRemainingValue
(i.e. mode: 64
), which carries all the remaining value of the inbound message in addition to the value initially indicated in the new message.
It’s often useful to add the SendIgnoreErrors
flag too, in order to ignore any errors arising while processing this message during the action phaseL
The latter example is identical to using a .reply()
function.
How to send a message with a long text comment
If we need to send a message with a lengthy text comment, we should create a String
that consists of more than characters. To do this, we can utilize the StringBuilder
primitive type and its methods called beginComment()
and append()
. Prior to sending, we should convert this string into a cell using the toCell()
method.