Skip to content

Commit

Permalink
feat: make receiver in Tact template refund remaining value
Browse files Browse the repository at this point in the history
Deploy returns excessive funds when the user uses `@stdlib/deploy` and
`Deployable` trait. Therefore, it would be nice to showcase how to do
the same in `receive()` functions right in the counter template.

Related links:
* tact-lang/tact-docs#231
* tact-lang/tact-docs#232
  • Loading branch information
novusnota committed May 25, 2024
1 parent c17c1b8 commit 8cf4c8e
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/templates/tact/counter/contracts/contract.tact.template
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ contract {{name}} with Deployable {

receive(msg: Add) {
self.counter += msg.amount;

// Notify the caller that the receiver was executed and forward remaining value back
self.notify("Cashback".asComment());
}

get fun counter(): Int {
Expand Down

0 comments on commit 8cf4c8e

Please sign in to comment.