Not getting response for walletconnect and Moralis.executeFunction

I am using moralis web3 provider with walletconnect to make contract call. The transaction is signed in the trustwallet but it doesn’t return success message to the browser thereby making it impossible to run then function

Code
const options = {

    contractAddress: presale_address,

    functionName: "buyTokens",

    abi: presale_abi,

    params: { bnbAmount: `${bnbprice}`},

    msgValue: `${bnbprice}`,

    from: account

  };

  await Moralis.executeFunction(options).then(status => {

    state.setState({ alert_head: "Congratulations!", alert_body: "Token purchased and successfully sent to your wallet", isProcessing: false });

    showAlert();

}

When I run this code, it will trigger wallet connect which takes me to trustwallet but after a succeful transaction it doesn’t return response to the browser for the continuation of then(…) function

I’m stuck here…

1 Like

Does it show something if you try this await Moralis.executeFunction(options).then((status) => console.log(status))?

No, It does’nt return anything if it was signed from from mobile wallets.
But it works fine with metamask browser extension.

1 Like

We need time to check. Do you use IOS or Android?

My phone is android OS

1 Like

We have the same issue when using wallet connect on IOS device

versions
“moralis”: “^0.0.90”,
“react-moralis”: “^0.2.6”,
“@walletconnect/web3-provider”: “^1.6.5”,

Hi @sakhro

We will add callback event support for the executeFunction in coming days :man_mechanic:

We’ll keep in touch with you :rocket:

Hi @Yomoo, Any updates on this functionality? Thanks!

Hi, I think that the functionality was added, can you try now?

i have exactly the same issue. the call functions all work. but the send functions don’t with walletconnect.

const receipt = await Moralis.executeFunction(options);
console.log(receipt)

this code just executes nothing for me…

I think that you should use events, events should work in latest Moralis sdk version, but that code should still send the transaction.

what do you mean? what events should i be using?


const tx = await Moralis.executeFunction(options);

tx.on("transactionHash", (hash) => { console.log(hash) })
  .on("receipt", (receipt) => { console.log(receipt) })
  .on("confirmation", (confirmationNumber, receipt) => { console.log(confirmationNumber,receipt) })
  .on("error", (error) => { console.log(error) });

Can you try this and see if any of these events fire and print to console (transactionHash, receipt etc)

It shows nothing in the console… when I use walletconnect with either metamast or trustwallet. I can connect. It does perform a read call. But when I make a transaction. Mrtamask/trustwallet doesn’t even open. Just nothing happens when I click the button. With normal mrtamask login. Everything does work.
I used https://docs.moralis.io/moralis-server/web3/web3 to make the dapp

can you share what you passed as options? did you use awaitReceipt = false?

const options = {
    contractAddress: "0xf684a651674046ce211b4956235ac001a96b3333",
    functionName: "mintForUser",
    abi: ABI,
    params: {
      user: address
    },
  };
  const tx = await Moralis.executeFunction(options);

tx.on("transactionHash", (hash) => { console.log(hash) })
  .on("receipt", (receipt) => { console.log(receipt) })
  .on("confirmation", (confirmationNumber, receipt) => { console.log(confirmationNumber,receipt) })
  .on("error", (error) => { console.log(error) });

This is the code i used. (ABI is the whole ABI)
For metamask login it works perfectly. But with walletconnect, the wallet doesn’t even open when I start this function.

can you try a syntax similar to this one?

mainly using awaitReceipt = false and using Moralis.enableWeb3({ provider: 'walletconnect' })

Yup. Same thing with awaitReceipt: false. Nothing shows up in console. And trustwallet doesn’t open with the transaction. Just a button and nothing happens…

I’ll need some time to test it, can you share a minimal html + js example that doesn’t work for you?

Wait i think I found something. Is there a function on how to check which provider is used?
So I can make an if function. If provider of connected = trustwallet. Do this
Else do this