-
Notifications
You must be signed in to change notification settings - Fork 370
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding overrides object to useCall hook, breaks and throws error #1011
Comments
Hi @gsteenkamp89, what is the purpose of adding the overrides object in this case? |
In my case, the view function (somewhat erroneously imo) uses function getNetAmount(address user) external view returns (uint256 memory _amount) {
uint256 _amount = amounts[user].totalAmount - amounts[msg.sender].expenses
return _amount;
} Here the author of the contract should've used |
I realized that this problem has occurred before and was raised here. Unfortunately, we currently know that it cannot be done if the call is going through Multicall. The only solution at this point is to call the method directly on the contract instance like in this example: const [balance, setBalance] = useState('0')
const { account, library } = useEthers()
const contract = new Contract(wethAddress, wethInterface, library)
useEffect(() => {
const getBalance = async () => {
if (account) {
const currentBalance = await contract.balanceOf(account, {
from: account,
})
setBalance(currentBalance.toString())
}
}
void getBalance()
}, [account, contract]) You can also use |
This is exactly what I ended up doing 😅 |
Describe the bug
When adding
overrides
object to theuseCall
hook, there is an error thrown. Not adding the overrides produces the desired result, but I am unable to add a "from" address to the call.This works:
This does not. It returns undefined.
The error in console:
Invalid contract call:
address=0x07f20dAbe6DA77858b81e2b08c555477268bd92A method=getStakingAmount args=0xC54070dA79E7E3e2c95D3a91fe98A42000e65a48,[object Object]
To Reproduce
call a view function using useCall. Check resuult. then call again with overrides object
{ from : "SOME_ADDRESS" }
Software versions
The text was updated successfully, but these errors were encountered: