Issue: JSON RPC Queries

When interacting with an ethereum rpc interface for building DApps with JS or TS, the huge amount of communication round trips becomes a huge burden. The UI just takes a couple of to many seconds to load.

existing solution with blockchain indexers

I know that there are indexing solutions around, that are just build to target that problem, for example "the graph protocol". I do not have much insight on those, but it seems to be another layer of complexity that makes especially real decentralization harder. However, i guess a lot of the modern DApps would not be possible without.

idea: client side query cache

i was questioning myself, if i just could cache the result of the request in the browsers storage, like in an IndexedDB. Most DApps would only query a small subset of views of a small set of contracts anyway. This might be especially meaningful for DApps that allow to browse the past (fat archive rpc nodes), as well for chains to do not have a steady stream of block updates.

Assumption: I assume that json rpc calls return deterministic results for each call for each block. please let me know if this assumption is wrong.

how does it compare to indexers ?

The proposed solution might not be as flexible or fast than using a real blockchain indexer, but it would not add up an additional back-end requirement. ("Blockchain only" Dapp)

The performance of this approach can be further boosted by including "view" functions on the contract level for UI use in order to reduce the number of round-trips.

my tech stack

i currently use the following technology stack for developing DApps:

  • ethereum 1 like EVM chain
  • openethereum as RPC backend
  • typescript
  • typechain
  • web3
  • mobx
  • react

i believe a solution like that, should not be dependend on a UI Layer like react, but integration with something reactive (lazy loading) is a must have, as well as UI Components to manage the cache.

competitor: drizzle

I was also thinking about to look up the drizzle framework. But no update for 2 years made me very cautious, but it is the closest thing i could find a solution for.

?? how to cache responses of rpc api in dapps ??

So how do you cache your contract states ? I can't believe that everyone relies on the graph, and all others do not cache their results. i really believe that caching in a generic way would be technical possible and viable, but also, this requirement would be a project on its own.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.