hirosystems / stacks-blockchain-api

API for the Stacks blockchain
https://stacks-blockchain-api.vercel.app
GNU General Public License v3.0
178 stars 114 forks source link

Endpoint to retrieve all keys for a data-map #2168

Closed obycode closed 6 days ago

obycode commented 1 week ago

In the stacks-node, we have an RPC endpoint to retrieve a value from a data map, but we have no way to retrieve all of the keys currently in that map. Having a list of all keys in a data map is useful in many situations, and how to get these keys is an often asked question. The solution often recommended currently is to include a list in the contract that gets updated whenever map is updated, but this adds unnecessary on-chain cost. Alternatively, the set of keys can be tracked off-chain by each user.

This seems like something that the API could probably expose, since it can track the events and store this information in the databases (maybe it already does, I'm not sure).

zone117x commented 6 days ago

The API does not receive or store events like on data-map change.

If that event does exist on stacks-core, I don't think this API would be an appropriate service to handle them. I'd recommend creating a new service for something like "extended-clarity-data-store" which could focus on doing that at scale.

smcclellan commented 6 days ago

Closing due to above.