Hi,
I would need all the parameters that you used to figure it out,
you can also test on https://admin.moralis.io/web3Api in /{address}/function endpoint where you should have better error messages.
In front end it may be easier to use Moralis.executeFunction
at a first look it looks like this code didn’t use function_name
Yep in plain vanilla JS it worked for me as well.
Can you give an example on how to run this in react with the parameters. runContract function doesn’t mention parameters in the documentation. Thanks.
That one did work. Have you tried with the native useWeb3Execute function hook.
That was the one that sent me through this rabbit hole. I think it is good to report to the team that that specific hook was sending me the errors mentioned above. And as you can see, all the parameters were sent exactly in the same way. I think there is something wrong with that hook.
I am having the same problem with useWeb3ExecuteFunction(). The hook doesn’t seem to take chain as a parameter. How does it know which chain to execute the function on? Do I have to call enableWeb3() before using this hook? Is there any working code that successfully runs useWeb3ExecuteFunction() on non-ethereum chain? thanks
in particular useWeb3ExecuteFunction will use current web3 instance and it depends on what chain is selected there in metamask or in what wallet are you using
I ran the website locally. After authenticate, I can executeFunction no problem.
However, if I were to refresh the page, even though I’m still logged in, executeFunction no longer works. To make it work again, I’d have to logout then log back in.
This is the reason why I couldn’t get useWeb3ExecuteFunction to work previously. Can you please kindly take a look. It feels like a bug to me.
I think that you have to use something like Moralis.enableWeb3() before using executeFunction
The reason is that executeFunction uses a web3 connection to MetaMask.
Thank you. Do you mind also showing me how to do this properly in the react-moralis framework? I find your code in this repository (https://github.com/MoralisWeb3/demo-apps/tree/main/react-moralis-examples) extremely helpful. It’ll be nice if you could add code there for using web3 api to call a read only function.