Capturing aeternity balances at a point in time

Hello

How could I capture the balances of all accounts at a point in time ?

I know about aeknow for personal use, I was hoping to do this through the sophia language or with the SDK.

Just one image of the balances and associated accounts, to be stored and referenced in a smart contract.

Is this possible? My idea is to set different statuses for users with different aeternity balances.

Thank you!

as documented in the api docs Aeternity node API documentation this is easily possible, also this is exposed using the sdk aepp-sdk-js/node.js at a14d13adddec8fb1dd2a2ef10e8bf795e3c913f0 · aeternity/aepp-sdk-js · GitHub

due to computational efforts of this, it can’t be accessed from within a sophia contract

1 Like

Do these statements evaluate to true?

The height works as a timestamp.

If I input the a block height (current is 284453) and a public key (ak_) I can access the balance of the account ak_ at this time.

These balances will not change as long as a consistent height is given?

These balances are accessible for over a year?

Thank you so much for your help. It is truly appreciated.

yes, all of this is possible.

In current implementation yes, maybe this functionality will be deprecated or only available with special configuration in future versions of the full node.

1 Like

If you want to access a particular (account) state from a year ago you should make sure not to switch on garbage collection though… It is off by default, but if you enable it you won’t be able to get old balances.

2 Likes

Yes, here we take advantage of the MPT implementation and we can look at accounts at certain height. As Hans pointed out, if the GC is enabled - you wouldn’t be able to access already garbage collected data.

@worcestergulag I am not aware if we have an endpoint for getting all accounts, you’d likely have to traverse the state tree itself. And if you do so - you might not need the endpoint at all in this case - you have your balance in the trie as well.

A different approach would be using the middleware, cc @danielaivanova.chain and @karol.chain