baking-bad / tzkt

😼 Awesome Tezos blockchain indexer and API
https://tzkt.io
MIT License
183 stars 35 forks source link

Support for smart contracts and big maps #21

Closed amzid closed 3 years ago

amzid commented 3 years ago

I am working on Tezos Reward Distributor and we are using tzkt as a possible backend api for fetching blockchain data. We are now working on adding support for delegations in the form of dexter contracts and we would like to extend the current tzkt provider implementation with the needed endpoints to extract data from big maps at any given block, i.e. given a block level and a big map id, I would like to get the list of values stored in this big map at that specific block. That would be great if this feature can be added to tzkt for us to enable support for the dexter delegations using tzkt.

argonau7 commented 3 years ago

Yes this would be great to have ASAP!

Groxan commented 3 years ago

Thank you for your interest! We're already working on contract storage and lazy storage (aka big_maps) indexing.

Groxan commented 3 years ago

Hey! We have implemented bigmaps indexing. For now, it is available on staging and will be in prod in a few weeks, after more tests. The API is more or less stable and likely won't be changed, so you can already play with it.

There are two ways to access bigmaps: 1) By ptr: /bigmaps/543 (see docs) 2) By name: /contracts/{dexter}/bigmaps/accounts (see docs)

And there are two endpoints to access keys: 1) Current keys: /keys (see docs) 2) At specific block: /historical_keys/{level} (see docs)

As far as I understand, you need historical keys, so the second endpoint is your choice. In all other cases I strongly recommend avoid accessing historical keys, because this endpoint is much slower than current keys due to data aggregation.

You can also use filters, pagination and selection, for example: /historical_keys/1400000?active=true&value.balance.ne=0&select=key,value

Feel free to leave any feedback or ask any questions.

Groxan commented 3 years ago

Done in v1.5