6

For various use cases it's valuable to display historical data of the balance on some account.

What is the best way to query this data from NEAR protocol?

ilblackdragon
  • 1,834
  • 12
  • 12
  • Did you solve this problem? Struggling with this right now, can't connect to the indexer, it says available connection slots are full... – Be Kind Jan 25 '23 at 23:10

1 Answers1

0

You'll get the account transaction history from this url:

https://helper.mainnet.near.org/account/<ACCOUNT_NAME>/activity?offset=<TIME_STAMP_NANOS>&limit=<NUMBER_OF_TRANSACTIONS>

Use the block timestamp of the latest transaction in the result to ask for the previous chunk of transactions (given you set the limit to a number that doesn't include all the trasaction). when you've found the initial transaction. Accumulate deposit (look at the signer_id to determine direction) and gas amounts to get the balance after each transaction.

Peter Salomonsen
  • 5,525
  • 2
  • 24
  • 38