Internal JSON-RPC error using Unity SDK's ExecuteContractFunction method on Android

Hello,

I implemented my contract functions in my Unity project using the ExecuteContractFunction method and they work great when I build for WebGL using Metamask Chrome extension. However, in Android build I always get the ā€œInternal JSON-RPC errorā€ in my Metamask Mobile app. The authentication works flawlessly, I’m connected to the wallet.

Is there a way to properly debug the issue and identify what’s wrong?
Could there be any specific problem with ExecuteContractFunction method on Android? Is there any other method I could use for running a write contract function? I tried using this one: Moralis.Web3Api.Native.RunContractFunction but it fails since apparently it’s only for read functions.

This is my method:

public static async UniTask<string> ApproveToken()
        {
            var spender = GameManagerAddress;
#if UNITY_WEBGL
            string amount = (BigInteger.Pow(2, 256) - 1).ToString();
#else
            BigInteger amount = BigInteger.Pow(2, 256) - 1;
#endif
            object[] parameters = {
                spender,
                amount
            };

            // Set gas estimate
            HexBigInteger value = new HexBigInteger(0);
            HexBigInteger gas = new HexBigInteger(0);
            HexBigInteger gasPrice = new HexBigInteger(0);

            var result = await Moralis.ExecuteContractFunction(TokenAddress, TokenAbi, "approve", parameters, value, gas, gasPrice);
            return result;
        }

And here’s the contract: https://testnet.bscscan.com/address/0x6c139f04a9382b7fb394834dd75a609f64d8ac3b#code

Note: I tried speedy nodes’ RPC URL for Binance Testnet in my Metamask Mobile app but with the same result.

FYI this fails as well:

public static async UniTask<string> ApproveToken2()
        {
            var spender = GameManagerAddress;
            string amount = (BigInteger.Pow(2, 256) - 1).ToString();

            object[] parameters = {
                spender,
                amount
            };

            // Set gas estimate
            HexBigInteger value = new HexBigInteger(0);
            HexBigInteger gas = new HexBigInteger(0);

            MoralisUser user = await Moralis.GetUserAsync();
            string fromAddress = user.authData["moralisEth"]["id"].ToString();

            Moralis.InsertContractInstance("approve", TokenAbi, "97", TokenAddress);
            Function function = Moralis.EvmContractFunctionInstance("approve", "97", "approve");
            var result = await function.SendTransactionAsync(fromAddress, gas, value, parameters);
            return result;
        }

Any help, anyone, please? Is there a chance for a custom support from Moralis team? We plan to release soon.

I once happened to have the same error. Tried to clear Metamask’s cache memory there after it worked as champ.

did you found any solution for this error?.Please help if you did