2

I am unsure of the best way to do this. I have a pool contract with a state variable of the total balance of the pool. I want to show a line chart on my dApp that shows how the balance of the pool has changed for the past X (let's say 30) days.

My question is what is the best way to query for this data and are there any tools that would be ideal for such situations (if I want to add more graphs in the future, for example).

1 Answer 1

1

If this needs to be encoded into your smart contract logic you will likely need to actually keep the state in the smart contract storage.

Otherwise if this is just for analytics you can use the graph to aggregate that information over time. Here's an example of how uniswap makes their analytics page using the graph: https://github.com/Uniswap/uniswap-v2-subgraph

1
  • Thanks for the suggestion! I had been looking into The Graph a bit and was unsure about how they charge query fees. Also there is the question of being able to run it with a private testnet (mainnet fork). Is it possible to host our own graph node to aggregate our smart contract data to avoid paying query fees?
    – alphawaves
    Commented Apr 20, 2021 at 11:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.