[SOLVED] Moralis v2 runContractFunction vs v1 executeFunction

I’ve just upgraded Moralis to the newer v2 in my project, which was previously using Moralis v1. Currently trying to execute a smart contract function that is payable using runContractFunction, but i’ve learned that this function only allows to retrieve readonly data? This was not the case with the executeFunction API provided by Moralis v1… Are there any similar APIs provided by Moralis v2 which provide the same functionality as executeFunction in v1, or any workarounds for this?

this is the error i’m facing:

{"message":"Function `tokenExchange` is not read only"}

You will need to use ethers.js (which is what executeFunction uses) to interact with smart contract write functions. If you are using a React app, you can look at wagmi.

Thank you! After some trial and error I managed to get it working with wagmi!