Question: How to query contract event messages?
Closed this issue · 1 comments
fico308 commented
I need to monitor the transfer events of our NFTs, and I've attempted several methods to retrieve this information:
explorerclient.GetAccountTxs
: This method only returns the user's transactions and does not include contract transactions.
txsResp, err := explorerClient.GetAccountTxs(ctx, explorerPB.GetAccountTxsRequest{
Address: "inj1n96zr06eqttpef7prspntlc7uqdumyq4ugq23w",
After: 19750950, // [after, before],
Before: 19750951,
})
if err != nil {
panic(err)
}
str, _ := json.MarshalIndent(txsResp, "", " ")
fmt.Println(string(str))
// output: {"paging": {}}
explorerPBClient.GetContractTxs
: It only provides the total transaction count without detailed information.
client := explorerPB.NewInjectiveExplorerRPCClient(explorerClient.QueryClient())
txsResp, err := client.GetContractTxs(ctx, &explorerPB.GetContractTxsRequest{
Address: "inj1n96zr06eqttpef7prspntlc7uqdumyq4ugq23w",
FromNumber: 19750950, // [after, before],
ToNumber: 19750951,
})
// output: {"paging": { "total": 3 }}
explorerclient.GetTxs
: While this method returns all transactions, it requires manual parsing of tx.messages to filter out contract transactions, which is not an efficient solution for my needs.
txsResp, err := explorerClient.GetTxs(ctx, explorerPB.GetTxsRequest{
After: 19750950, // [after, before],
Before: 19750951,
})
// output: {"paging": { ... }, "data": { ... }}
Is there an easier way to fetch contract messages?
aarmoa commented
This is a question and not an issue. Questions should be posted in the support channel in Discord.