Skip to content

Commit

Permalink
ExtraCurrency receive example
Browse files Browse the repository at this point in the history
  • Loading branch information
xssnick authored Jan 24, 2025
1 parent 642950d commit 0b9e7e9
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions example/accept-payments/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,21 @@ func main() {
ti := tx.IO.In.AsInternal()
src := ti.SrcAddr

if !ti.ExtraCurrencies.IsEmpty() {
kv, err := ti.ExtraCurrencies.LoadAll()
if err != nil {
log.Fatalln("load extra currencies err: ", err.Error())
return
}

for _, dictKV := range kv {
currencyId := dictKV.Key.MustLoadUInt(32)
amount := dictKV.Value.MustLoadVarUInt(32)

log.Println("received", amount.String(), "ExtraCurrency with id", currencyId, "from", src.String())
}
}

// verify that event sender is our jetton wallet
if ti.SrcAddr.Equals(treasuryJettonWallet.Address()) {
var transfer jetton.TransferNotification
Expand All @@ -86,8 +101,10 @@ func main() {
}
}

// show received ton amount
log.Println("received", ti.Amount.String(), "TON from", src.String())
if ti.Amount.Nano().Sign() > 0 {
// show received ton amount
log.Println("received", ti.Amount.String(), "TON from", src.String())
}
}

// update last processed lt and save it in db
Expand Down

1 comment on commit 0b9e7e9

@Sahil0140
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

Please sign in to comment.