question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add Caching/Limits to Contract Calls

See original GitHub issue

With useContractCall and useContractCalls it’s mentioned the data is updated every block.

This approach can get expensive when paying for a node service (Infura/Alchemy)

Any discussions for adding caching or limiting fetches?

Personally, I’ve been using react-query to wrap my contract call and had a lot of success.

Would be great to add at a minimum the ability to limit refetches and/or also the ability cache requests and only refetch if certain parameters in the state have been met i.e. a certain function has been called/broadcast/confirmed or another state change in the application.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

7reactions
marekkirejczykcommented, Apr 11, 2021

Interesting, we could add CallOptions with refreshFrequency parameter:

const wethBalance = useContractCall({
  abi: wethInterface,
  address: '0xA243FEB70BaCF6cD77431269e68135cf470051b4',
  method: 'balanceOf',
  args: [account], {
    refreshFrequency: eachBlock
  });

With options like: eachBlock, everyBlock(n), never

Application configuration could include defaultRefreshFrequency.

eachBlock could be a function, returns true or false for given multicall and block.

2reactions
kamescgcommented, Apr 11, 2021

That sounds like a great place to start.

BTW great library! Really liking it so far - very easy to use.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Contract to Contract calls and an ABI come to Algorand
The AVM now supports Contract to Contract calling and grouped inner ... Algorand added the ability for smart contracts to issue “inner ...
Read more >
Calling a smart contract from JavaScript
In this tutorial we'll see how to call a smart contract function from JavaScript. First is reading the state of a smart contract...
Read more >
Call Smart Contract From Another Smart Contract
In this developer tutorial, learn how to call a smart contract from another smart contract in an EVM environment using Solidity.
Read more >
Calling functions of other contracts on Solidity
It is used to encode contract calls for the EVM and to read data out of transactions. There is a clear specification of...
Read more >
Contracts Calling Arbitrary Functions
In this post, I'll show how smart contracts can use low-level message ... To enable making arbitrary function calls, I'm going to use...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found