Is there an efficient way to solve the verification of a particular transaction in the server? For example, I want the user to transfer 100 XYZ tokens. But while confirming the transaction in the server, I don't want to check the transfer instructions. Is there a nonce/hashing mechanism that can be used here? This leads to unnecessary fetching of the transaction instructions and double verifying them.
1 Answer
If all you care about is the movement of tokens from account to account, you can use the getTransaction
API.
The relevant parts of the response are these:
result.meta.{pre|post}Balances
– Array of u64 lamport balances from before/after the transaction was processedresult.meta.{pre|post}TokenBalances
– List of token balances from before/after the transaction was processed or omitted if token balance recording was not yet enabled during this transaction. Read more about this data structure here.
The balances are in the same order as the accounts in result.transaction.message.accountKeys
.