Sure there's an easy answer to this - but can't get useContractRead to get the balance of an access token... #1715
Replies: 7 comments 17 replies
-
Not sure if this will do it, but noticed that it's wrong: const { data: accessTokenBalance, error, warning } = useContractRead({
address: accessTokenAddress,
- accessTokenABI,
+ abi: accessTokenABI,
functionName: 'balanceOf',
args: [address],
}); |
Beta Was this translation helpful? Give feedback.
-
not sure if this is even related but I'm getting this error back onload the to 0x here is the accessToken address and the second is the test wallet address with loads of extra zeroes in it. Feel like I'm running up against the limits of my understanding here tbh - but I think this is related to the issue I'm having as I don't think the access token address is passed anywhere else in my code. I'm looking at the ethers documentation for Call exceptions but not getting anywhere. |
Beta Was this translation helpful? Give feedback.
-
Can u add "isSuccess" state in useContractRead and console it ? |
Beta Was this translation helpful? Give feedback.
-
try by hardcoding your address. If it works then there is case that hook run before obtaining address |
Beta Was this translation helpful? Give feedback.
-
Tried setting up a new project with rainbowkit and having my index.tsx do nothing else -with every value hardcoded into useContractRead - except make this call and it gives the same result.
Is the problem with the way that rainbowkit has setup the default app.tsx? Or have I failed to alter something here that needs altering?
Going slightly mad with this. |
Beta Was this translation helpful? Give feedback.
-
Error: missing revert data in call exception; Transaction reverted without a reason string [ See: https://links.ethers.org/v5-errors-CALL_EXCEPTION ] (transaction={"to":"0x03D3d03F559cB0c17ea0A9fc92c9be3779C50fb2","data":"0x70a08231000000000000000000000000de78830f452685fa02244051e90cf5bd6a4db637","accessList":null}, code=CALL_EXCEPTION, version=providers/5.7.2) Back to this error - I don't know what is being referred to when it says "accessList":null? |
Beta Was this translation helpful? Give feedback.
-
Have also tried to use the exact same method to call balanceOf on a deployed contract that I didn't write and get the same result - so I'm pretty sure the issue is not with the contract. |
Beta Was this translation helpful? Give feedback.
-
Hi, I'm trying to useContractRead to call the balanceOf function from a contract that is deployed on Goerli like this:
The console correctly logs the address, accessTokenAddress and ABI - but the accessTokenBalance just comes back as undefined.
I am able to call the function successfully with the right value returned on both remix and etherscan.
I had a similar problem with usePrepareContractWrite that ended up being down to using language from the wrong version of wagmi - but I don't think this is the problem here as I think this should match the syntax in the up to date documentation. I believe I have the latest wagmi version in my project.
Any help hugely appreciated. Thanks...
Beta Was this translation helpful? Give feedback.
All reactions