Search code examples
nearprotocol

How to get the transaction fees of Near transactions and which operations involves Near amount?


https://explorer.near.org/blocks/99qdUGNmGMMQQdKGmgA7Lf6PjaXAHgVVy53DLHJZpcbb

Block - 35866073 has 5 transactions

ChunkHash - GwMUrTgEfqEaV9s8ngvqUn9c4hi4G8Ywpggoy4VDwnok

5 transactionHshses

TransactionHash 2 - AMDbiQUJx2Dd9FfbaYYbNj2D6T6xPJMHgWCZ4RTrN1UU

Transfer from comchien.near to 85a577d5db02df7830c8ad3db76ca6a90dee6f176c8478eb12dbf30d8d2d54ee - 5.58572

TransactionFee - ? there is some transaction Fee shown in explorer but in Json structure i dont see the transaction fee , can you plese help how can i get the transaction fee

TransactionHash 2- 6Beo8SFyjPjjtFnT3b2aEGDHgPY9HxGZ17vWvpSN733c

I can see storage_deposit , near_deposit and ft_transfer_call. Does all the amount gets transferred to wrap.near. And same transaction Fees is missing in json struture.


Solution

  • Transactions in NEAR are just inputs. To see the outputs (execution outcomes), you need to query transaction details using tx RPC to see transaction_outcome -> outcome -> tokens_burned field. That is the transaction initial processing fee. Next, you need to fetch receipt execution outcomes (well, it is right there in the tx RPC response) and sum all the receipts_outcome -> outcome -> tokens_burned. That is exactly what NEAR Explorer does.

    You also could find this doc useful where I explain all balance changes there.