About smart contract application snapshot - General - Algorand

About smart contract application snapshot

post by yfmao on Jan 21, 2021

I am wondering about the snapshot functionality of smart contract. Given the application ids I would like to take snapshots, is it possible to take the lastest updates of those apps using the algo-sdk functions?

post by JasonW on Jan 21, 2021

Do you mean the state values for stateful smart contracts?

post by yfmao on Jan 21, 2021

@JasonW Yes, I am asking for the solution returning the state values of many apps (e.g. like 50-100 apps) of a given time stamp.

post by JasonW on Jan 22, 2021

You may be able to do some of this using the indexer. Specifically search the chain for all applications, loop through these, and then look up the creator account to get the global state of each contract. The local state would be a bit more complex as the current values are stored in the ledger under the individual accounts that have opted in. Algorand Developer Docs

post by yfmao on Jan 22, 2021

Thanks for your response @JasonW .

I think I am focused on the availability of returning the state values of a certain timestamp, so maybe the input of the solution should contain the time variable. The indexer function you mentioned seems only including the round number as input.

Any ideas on how to search the global states with date-time limitations?

post by tsachi on Jan 22, 2021

I’m not sure if my suggestion would be helpful or not, but I figured it won’t hurt suggesting.

What I’m hearing from you is that you need to have a single “source” that would include the “master-hash”. Would it be possible for you to construct the applications (which are known in advance) in a Merkle-tree like way, so that every update to an application also updates its parent, and its parent-parent and ending with the root ?

With the current limitation of 16 transactions/group, you can have 2^16 applications there, which is quite a large number.

post by yfmao on Jan 22, 2021

Thanks @tsachi for your reply.

Your idea sounds interesting. I think I could take use of your idea along with using the round number to search among the smart contract apps.

But I have a question about using the round number here. I am focused on finding the corresponding transaction time given the round number. Is there anything in algo sdk or indexer client that could return the exact timestamp of a certain round number?

post by tsachi on Jan 22, 2021

Hmm. Transactions don’t have a time of their own. The block header does contain a timestamp, which is monotonic and uniform on the network.

Would that satisfy what you’re looking for?