You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm attempting to retrieve transactions, but I am only receiving a single transaction involving TON transfer. Is it possible to also retrieve transactions with Jetton (USDT) transfers?
There should be two USDT transfers and one TON transfer visible for the address.
Code Sample:
package main
import (
"context"
"encoding/base64"
"log"
"github.com/xssnick/tonutils-go/address"
"github.com/xssnick/tonutils-go/liteclient"
"github.com/xssnick/tonutils-go/ton"
)
const (
num = 10
)
func main() {
client := liteclient.NewConnectionPool()
err := client.AddConnectionsFromConfigUrl(context.Background(), "https://ton.org/global.config.json")
if err != nil {
panic(err)
}
api := ton.NewAPIClient(client, ton.ProofCheckPolicyFast).WithRetry()
accountAddr := address.MustParseAddr("UQC7CECsMMrNJVcxJH8TlR-tK8yTS3gOC2JVvQdYyeC1RVZA")
// we need fresh block info to run get methods
b, err := api.CurrentMasterchainInfo(context.Background())
if err != nil {
log.Fatal(err)
}
// we use WaitForBlock to make sure block is ready,
// it is optional but escapes us from liteserver block not ready errors
res, err := api.WaitForBlock(b.SeqNo).GetAccount(context.Background(), b, accountAddr)
if err != nil {
log.Fatal(err)
}
lastTransactionId := res.LastTxHash
lastTransactionLT := res.LastTxLT
headSeen := false
for {
trxs, err := api.ListTransactions(context.Background(), accountAddr, num, lastTransactionLT, lastTransactionId)
if err != nil {
log.Fatal(err)
}
log.Printf("transaction count %d", len(trxs))
for i, tx := range trxs {
// should include only first time lastTransactionLT
if !headSeen {
headSeen = true
} else if i == 0 {
continue
}
if tx.IO.In == nil || tx.IO.In.Msg.SenderAddr().IsAddrNone() {
// external message should be omitted
continue
}
if tx.IO.Out != nil {
// no outgoing messages - this is incoming Toncoins
continue
}
// process trx
log.Printf("found in transaction hash %s", base64.StdEncoding.EncodeToString(tx.Hash))
}
if len(trxs) == 0 || (headSeen && len(trxs) == 1) {
break
}
lastTransactionId = trxs[0].Hash
lastTransactionLT = trxs[0].LT
}
}
Can you help me understand how to modify the code to retrieve Jetton transfer transactions alongside the TON transfer? Thanks!
The text was updated successfully, but these errors were encountered:
And log the number of transactions (output will be 6) log.Printf("transaction count %d", len(trxs))
I also print the transaction hashes (5 in msgs where i have recieved ton, and 1 out msg):
for i, tx := range trxs {
log.Printf("found transaction hash %s", base64.StdEncoding.EncodeToString(tx.Hash))
}
However, I'm not receiving two transactions where I received USDT. The hashes for these missing transactions are:
(5c508c90aa472e06fa063b9d0396fec1975e1f5760d982363b3035f5bf0f7122, eDdYeBMSmHRDDeYyRzlhmUAFg/MqlbAOOiGT4W+PRdA=)
These transactions don't appear in the response, and I'm unsure why they're missing. Any ideas on what might be causing this?
I'm attempting to retrieve transactions, but I am only receiving a single transaction involving TON transfer. Is it possible to also retrieve transactions with Jetton (USDT) transfers?
Explorer Link:
TONSCAN Explorer
There should be two USDT transfers and one TON transfer visible for the address.
Code Sample:
Can you help me understand how to modify the code to retrieve Jetton transfer transactions alongside the TON transfer? Thanks!
The text was updated successfully, but these errors were encountered: