xssnick / tonutils-go

TON SDK Library in pure Golang for interacting with The Open Network ecosystem using native protocols, such as ADNL, RLDP and etc.
Apache License 2.0
464 stars 95 forks source link

jetton comment cannot be parsed #213

Closed daewoochen closed 1 month ago

daewoochen commented 1 month ago
  1. Send jetton tranfer transaction with comment comment, _ := wallet.CreateCommentCell("hello world!") transferPayload, _ := tokenWallet.BuildTransferPayloadV2(to, w.Address(), amountTokens, tlb.MustFromTON("0.1"), comment, nil)
  2. However, the refs field of transferPayload is empty and does not contain a comment cell. When I get tx.IO.In.AsInternal().Body.RefsNum() through api.SubscribeOnTransactions, it is 0, so I can't get the comment.
  3. I modified the flag of the ForwardPayload field of the jetton.TransferPayload structure from tlb:"either . ^" to tlb:"either ^ ." or tlb:"maybe ^", the refs field of transferPayload obtained through tokenWallet.BuildTransferPayloadV2 is not 0. When I get tx.IO.In.AsInternal().Body.RefsNum() through api.SubscribeOnTransactions, it is not 0, so I can get the comment. So why does this happen? What is the correct way to use it? Thank you.
xssnick commented 1 month ago

either . ^ tries to pack your data to the same cell if it is enough free bits, if not - it will be saved as a reference, so it is normal behaviour, short comment can be stored in the same cell with previous data, this way transaction will be cheaper.

If for some reason you want to store payload as reference you can do it by wrapping your cell to comment = cell.BeginCell().MustStoreRef(comment).EndCell()

daewoochen commented 1 month ago

This issue has been resolved, thanks!