blocto / solana-go-sdk

Solana Golang SDK
https://blocto.github.io/solana-go-sdk/
MIT License
373 stars 96 forks source link

Confirm transactions #70

Closed scottywm closed 2 years ago

scottywm commented 2 years ago

Hello, I'm using the below code to get the transaction data.

c := client.NewClient(rpc.MainnetRPCEndpoint)

tr, err := c.GetTransaction(context.Background(), sig)

The problem I'm having is that I don't know how to extract the data out of the response (tr) that I need, as I'm needing the transaction amount, sender and receiver token addresses.

What do I do to get this data from the response (tr)

Thanks

Scott

yihau commented 2 years ago

A tx is composed by signatures and a message. A message is composed by instructions. SOL transfer, token transfer, stake ... all of these actions are instructions. so you can parse instructions to know what a tx do. For decoding instruction, you can take a look at https://solanacookbook.com/guides/serialization.html#setting-up-for-borsh-serialization

yihau commented 2 years ago

and I think the issue is related to Solana concept instead of this SDK. You can ask this kind of question here https://solana.stackexchange.com.