#How to get all persistent storage from a contract?

15 messages · Page 1 of 1 (latest)

languid cairn
#

I am looking for a way to get all the storage (persistent in that case, but could be other) from a contract using a RPC call.

I've tried with Stella and it gave me the following #🔹|stella-help-old message

But this seems to only give me the admin storage key/val, not the rest.

I am trying to get all this basically https://stellar.expert/explorer/testnet/contract/CAP52ERGUZ65UNPHP36CQBHYUPEUG2TT4NPVEV7CREWRT7UCPD7PRWEE/storage

I could scrap that page, but I don't think it's the right approach and would incur load on stellar.expert for nothing. @fickle turtle I suppose you are using a DB to get all that? Or do you have another way? (In the future I will also have a DB for my project.)

Thanks in advance!

cloud pollen
#

The RPC doesn't have a way to do that. Today is technically has access to the data to support it, but in the future it may not. Worth discussing in an issue at https://github.com/stellar/soroban-rpc.

#

A way I do this for analysis / less real time, is to pull the data from history archives.

languid cairn
#

Ok thanks I will open this as a discussion on the repo then 😃

cloud pollen
#

If you’d like example code for how to fetch data from history archives, you could have a look at:

https://github.com/stellar/stellar-cli/pull/1601

The steps are:

  1. Download the history json for a ledger, or the latest one
  2. Download the buckets referenced in the json
  3. Search the buckets in order they appear in the json (order matters), keeping track of entries already seen and skipping any you see a second time in later buckets
languid cairn
#

Oh thanks I see 🙏👍 maybe I can try to do something like this in JS for my dApp.

cloud pollen
#

Worth noting, history archives don't contain every ledger, they contain every 64th ledger, and they are typically up to 5 minutes in the past because of that.

languid cairn
#

Good to know 👍 would not be an issue for my use case.

For now I went around with using a different logic. I wanted to have a fast search on the frontend with a galerie showing all registered projects. In the end I will use this galerie to show featured projects and if the search does not return a project from this gallery, I will do a real onchain call to check if the project exists there. UX seems to be ok to me.

dim wigeon
languid cairn
dim wigeon
languid cairn
languid cairn