wagmi: [bug] useContractReads always returning a [null]

Is there an existing issue for this?

  • I have searched the existing issues

Package Version

0.5.5

Current Behavior

Trying to read one or multiple contracts using useContractReads always returns [null]

input:

import { erc721ABI, useContractReads } from 'wagmi';

[{
        addressOrName: '0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d',
        contractInterface: erc721ABI,
        functionName: 'tokenURI',
        args: 1,
        chainId: 1,
}]

Same object does succeed with useContractRead

image

Expected Behavior

No response

Steps To Reproduce

No response

Link to Minimal Reproducible Example (CodeSandbox, StackBlitz, etc.)

No response

Anything else?

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 23 (4 by maintainers)

Most upvoted comments

I’ll fork your code sandbox and hard code the data so you can see there is defintiely an issue here.

For example here is my localchain setup (using rainbowkit):

const localChain: Chain = {
  id: 31337,
  name: "Local",
  network: "local",
  nativeCurrency: {
    decimals: 18,
    name: "Local",
    symbol: "ETH",
  },
  rpcUrls: {
    default: "http://127.0.0.1:8545/",
  },
  testnet: false,
  multicall: {
    address: "0x5ba1e12693dc8f9c48aad8770482f4739beed696",
    blockCreated: 12336033,
  },
};

This does not work at all. I have to remove the multicall param for things to work.

@JohnSmithyy – got a codesandbox you can push up that reproduces this issue?

Unfortunately not since I cannot replicate the issue consistently on a codesandbox. It happens randomly on my local network, not sure why. I’m thinking it has something to do with multicall since moving to useContractRead for each function works without issues but useContractReads will return null values randomly time to time.

I’ve tried specifying the multicall contract/blocknumber since I’m forking the mainnet but it doesn’t like to cooperate for some reason.

I’m actually facing this exact same issue. useContractReads will randomly stop working and start returning null values.

Looking in my browser console, I do see that it says multicall is not supported on my local network which is fine because I assume that if it can’t do a multicall, it will just do each contract read in the reads function one after the other instead of a batch.

But not sure why it stops working all together randomly. My minimal example is pretty similar to what OP posted except I don’t pass in a chainid.