Processing an incoming message in a transaction isn't always successful. The contract may encounter some error and fail.
This can be due to an explicit decision of the contract author, usually by writing a require()
on a condition that isn't met, or this may happen implicitly due to some computation error in run-time, like a math overflow.
When an error is thrown, the transaction reverts. This means that all persistent state changes that took place during this transaction, even those that happened before the error was thrown, are all reverted and return to their original values.
How would the sender of the incoming message know that the message they had sent was rejected due to an error?
All communication is via messages, so naturally the sender should receive a message about the error. TON will actually return the original message back to the sender and mark it as bounced - just like a snail mail letter that couldn't be delivered.
All Examplesimport "@stdlib/deploy"; contract Getters with Deployable { count: Int as uint32; init() { self.count = 17; } get fun counter(): Int { return self.count; } get fun location(): Address { return myAddress(); } get fun greeting(): String { return "hello world"; } get fun sum(a: Int, b: Int): Int { return a + b; } get fun and(a: Bool, b: Bool): Bool { return a && b; } get fun answer(a: Int): String { let sb: StringBuilder = beginString(); sb.append("The meaning of life is "); sb.append(a.toString()); return sb.toString(); } }