2

I'm new to solana network and technology. I'm developing an application to confirm transaction receive to a specific wallet address on solana network. Right now I'm using this API "api.mainnet-beta.solana.com" .My question is how to get amount and symbol of a transaction ?

1 Answer 1

6

Assuming you've already identified the transactions that are interesting to you, you will find preTokenBalance and postTokenBalance fields in the transaction metadata, both with this structure.

  • To get the transfer amount, first coerce the uiTokenAmount field(s) into a number however is most convenient for the language you're using. Then take the difference of the two.

  • The mint field can then be used to query something like the Solflare Unified Token List API for the extended token metadata, which contains they symbol.

2
  • Just wanted to add this regarding token symbol and name : with the token metadata being moved onchain, one can directly fetch the metadata account of a token and deserialize it, the new metaplex sdk does it farily trivially, this way if you dont trust an api and want to directly get it via the contract you can do so. Commented Jul 13, 2022 at 7:34
  • For metaplex, this might be useful chainstack.com/…
    – Ake
    Commented Dec 28, 2023 at 1:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.