Skip to content
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

WalletConnect - Metamask fails to receive the transaction #2045

Closed
VexyCats opened this issue Dec 4, 2020 · 47 comments
Closed

WalletConnect - Metamask fails to receive the transaction #2045

VexyCats opened this issue Dec 4, 2020 · 47 comments
Labels
community Issues or PRs opened by the MM community deeplinks Deeplinks related issue or bug Sev3-low A possible confusion or deception that is only hypothetical & has no known instances in the wild team-sdk SDK team type-bug Something isn't working

Comments

@VexyCats
Copy link

VexyCats commented Dec 4, 2020

Describe the bug

When a user using walletconnect on our dapp - sends a transaction - only SOMETIMES does it actually appear and notify them in their wallets that they have a transaction to sign.

Sometimes it won't appear at all for users.

To Reproduce

Go to mintable.app - connect metamask via walletconnect.
Go to browse, find an item and try to buy that item. (You'll need an account created tho)
Transaction will appear once you press buy

Wallet may or may not have a transaction appear.

Using any other wallet - trust wallet, rainbow, or others - they appear immediately and without issue.

Tried disabling the walletconnect session, tried restarting metamask and restarting the connection via walletconnect on the site.

Tried disconnecting and reconnecting. Nothing seems to affect it.

TL;DR - when disconnecting every session on metamask mobile - it will send the transaction on a fresh connect - after reloading the dapp and trying to send another transaction - nothing will appear in Metamask.

_provider: WalletConnectProvider
accounts: ["0xBxxxxxxxxxxxxxxxxxxxxxx57"]
bridge: "https://bridge.walletconnect.org"
chainId: 1
connectCallbacks: []
connected: true
currentBlock: {number: Uint8Array(3), hash: Uint8Array(32), parentHash: Uint8Array(32), nonce: Uint8Array(8), mixHash: Uint8Array(32), …}
http: HTTPConnection {_events: {…}, _eventsCount: 2, _maxListeners: undefined, url: "https://mainnet.infura.io/v3/xxxxxxxxxxxxxxxxxxxxxxxxx"}
infuraId: "cxxxxxxxxxxxxxxxxxxxxxxxe"
isConnecting: false
networkId: 1
qrcode: true
qrcodeModalOptions: undefined
rpc: null
rpcUrl: "https://mainnet.infura.io/v3/c7xxxxxxxxxxxxxxxxx"

And our contract call:

  const contractInstance = await getDeployedContract(ABI, address);
    return contractInstance.methods[methodName](...params)
      .send(transactionDetails)
      .on("transactionHash", (txhash) => {
                .............

Note: WalletConnect team has told me this is a problem with metamask and need to bring it up here opposed to them.

The context of the example is:

User connects to the dapp via wallet connect to their metamask. Metamask shows "do you want to connect" and does so. We can access their account and balance, etc.

User tries to make a contract call, the transaction object is exactly the same as for metamask browser, coinbase wallet, trust wallet, fortmatic - but when its sent to the user's phone from walletconnect <> metamask mobile - nothing appears on their phone at all.

Sometimes if you disconnect and refresh the app then reconnect - it will send it once, but if you reload the page or come back in a few minutes - it won't send the transaction to their phone
For example - I just closed all my connections on metamask, then i reloaded the dapp - reconnected to metamask - and then submitted a transaction - and it was sent to metamask.

Now I'm going to reject this transaction - reload the dapp and try to send it again.

I'm asked to reconnect my wallet - I select walletconnect - no QR code is needed as its already got an active session, web3 is working - I can see the account in metamask mobile, I can fetch data using web3 from the contract - but when I submit the transaction to call the contract - nothing. Nothing happens, the dapp is showing its awaiting tx confirmation from the user - but the metamask mobile app doesnt have a transaction to accept. It never receives it

@VexyCats VexyCats added the type-bug Something isn't working label Dec 4, 2020
@VexyCats
Copy link
Author

Hey @estebanmino Can you provide some help here? Or maybe @omnat?

@omnat omnat added the deeplinks Deeplinks related issue or bug label Dec 16, 2020
@rigwild
Copy link

rigwild commented Mar 18, 2021

I noticed the same behavior. Very randomly, MetaMask does not show the prompt to confirm. Sometimes, the prompts arrives after like x seconds, again, very randomly.

I though WalletConnect bridge server might be too flooded with requests, so I self-hosted one myself, same result.

Couldn't it be a timing issue? MetaMask loading screen can be long (+ the password/biometrics prompt), maybe the WalletConnect request is received during this loading screen and not handled?

EDIT:
After some more testing...

  1. This happens a lot when doing mobile app <-> MetaMask mobile (I have tested multiple browser apps).
  2. This bug happens a lot less when doing computer browser <-> MetaMask mobile

@toki-sean
Copy link

Any updates on this issue?

@omnat
Copy link
Contributor

omnat commented Apr 26, 2021

Hi @rigwild @VexyCats thanks! Any other steps for reproduction will help a lot. We haven't been able to reproduce this issue on our end. Some questions to investigate when & why WalletConnect pop-up isn't loading

  1. Is it site dependent? Could be due to implementation issues on the web3 site/dapp
  2. Does it happen in certain browser state? Does it fix itself if you clear browser history + cookies? Does it happen when you have many tabs open in the MetaMask browser?
  3. Does it happen for certain types of sign methods and not others?
  4. Did this behavior start happening in a certain version - if yes which one? Are you testing with latest app version?

Thanks for helping with the investigation of this issue!

@rigwild
Copy link

rigwild commented Apr 27, 2021

Looks like @hexyls and @Mi-Lan seen it too (protofire/omen-exchange#1821 (comment))

For me:

Is it site dependent? Could be due to implementation issues on the web3 site/dapp

Probably not as multiple different people have experienced the same behavior and the bug happens randomly.

Does it happen in certain browser state? Does it fix itself if you clear browser history + cookies?

Had to try losts of different web browsers for testing our app (chrome, mozilla, brave, opera, all mobile and desktop) and it happens randomly on all of it (even on incognito mode).

Does it happen when you have many tabs open in the MetaMask browser?

Will have to try that one. Probably not the issue but I will check it later this day.

Does it happen for certain types of sign methods and not others?

ETH send request or ETH contract interaction confirmation.

Did this behavior start happening in a certain version - if yes which one? Are you testing with latest app version?

Only used latest versions (MetaMask mobile Android from Google Play and latest version of WalletConnect). I tried self-hosting WalletConnect bridge server, same result.

I don't have access to other mobile wallets, can anyone test with another one and tell us if this is an issue with those too? If yes, it is an issue from WalletConnect.

@jonathankoh24
Copy link

I'm running into this issue as well. For me it sometimes works, and other times after I restart metamask, the tx confirmation pops up

Is it site dependent? Could be due to implementation issues on the web3 site/dapp

I'm running into this when using wallet connect in react native -- Tried it with withWalletConnect https://docs.walletconnect.org/quick-start/dapps/react-native

Does it happen in certain browser state? Does it fix itself if you clear browser history + cookies?

Tried on android + expo. Tried restarting and same result.

Does it happen for certain types of sign methods and not others?

Does not happen on connect request, everything else is failing.

Did this behavior start happening in a certain version - if yes which one? Are you testing with latest app version?

Only used latest version from Google Play Store and latest WalletConnect

@StillFantastic
Copy link

I believe I encountered the same issue, sometimes have to restart metamask app to receive the pop up

@nithronium
Copy link

I have encountered the same error too with different testers on different browsers/computers.

  1. It is not site dependent.
  2. I believe it happens if QR code is read and connect approved and phone screen is locked. Metamask might be taking itself to a locked state and not listening for incoming requests.
  3. It happens on all methods except connect or disconnect.
  4. I don't know about previous versions. Using latest versions of Metamask on iOS.

@jeromevvb
Copy link

I'm having the same issue when i'm using WalletConnect with a browser with MetaMask extension. If i switch to private navigation all good.

@mhorsley30896
Copy link

mhorsley30896 commented Jul 24, 2021

I am having a similar issue; however for me it not transactions but the request to start the session itself that intermittently fails to appear. Works absolutely fine on desktop, but trying to connect metamask mobile via web3modal I very intermittently get asked to approve the session. Works with every other wallet (trust, rainbow etc.) no problem on desktop

@mhorsley30896
Copy link

Indeed, I have just tested on example.walletconnect.org and no session request ever appears in the app

@StillFantastic
Copy link

StillFantastic commented Jul 25, 2021

@mhorsley30896 I guess it's because the official walletconnect bridge server is overload. In my case using a self-hosted bridge solves the problem you mentioned.

@mhorsley30896
Copy link

@StillFantastic ah yeah, that makes sense as I was seeing intermittent 429 and 502 response codes. Would you be so kind as to point me in the right direction for documentation in hosting my own bridge? It’s not something I’ve ever done before

@StillFantastic
Copy link

StillFantastic commented Jul 25, 2021

@mhorsley30896 https://github.com/WalletConnect/node-walletconnect-bridge
This is the one we're currently using although it seems like the repo is deprecated. Not sure whether the newer version(in README) is compatible with walletconnect v1.

@rigwild
Copy link

rigwild commented Jul 25, 2021

@StillFantastic it might be overloaded right now but there is an issue with metamask anyway.

See my previous answer:

I thought WalletConnect bridge server might be too flooded with requests, so I self-hosted one myself, same result.

@andrepimenta andrepimenta added the Sev3-low A possible confusion or deception that is only hypothetical & has no known instances in the wild label Aug 17, 2021
@andrepimenta
Copy link
Member

As a workaround for now can you try closing the app completely and opening it again? We will look into this in the future though.

@saveriocastellano
Copy link

I’m experiencing exactly the same issue when connecting the MetaMask mobile wallet on iOS via Wallet Connect: only rarely MetaMask receives the connect request from the website, most times it does not.
Same problem happens when calling a contract method that requires a transaction to be approved by MetaMask: most of the times the MetaMask app does not receive the request. This is very frustrating.
This is definitely a problem with the MetaMask mobile app, I have tried other wallets like BitPay and Trust Wallet and they both work fine with wallet connect.
Any plan to fix this problem ?

@hnvn
Copy link

hnvn commented Nov 27, 2021

Same issue here, tested on the latest version v3.7.0. I have to restart MetaMask app to get the confirm popup worked.

@just-a-normal-human
Copy link

just-a-normal-human commented Nov 29, 2021

Same problem here, but restart doesnt work, I can connect and disconnect but not interact in any other way using metamask mobile. Very strange that this issue is not getting any attention.

I can also add that I updated to the latest version 3.7.0 and the problem still persists.

@nexus6nexus6
Copy link

We have the same issues. We're initiating the connection with metamask from our webapp on mobiles using walletconnect and the connect popup appears randomly. Sometimes it's almost instant but lots of times you need to wait for 15seconds or more to get it on mobile metamask. The second step in our user flow is signing a message and this works even more randomly. It helps if I restart the metamask app. It works fine when using desktop browser and metamask plugin. It works better if using desktop browser and QR code scanner on metamask mobile.

@alexanderMontague
Copy link

+1 Authenticating with wallet connect works just dandy, redirects to Metamask mobile and connection is granted. What is even more odd is that it seems "regular" interactions are received by Metamask and approval can be granted. "Regular" transactions like transferring ETH/tokens to from addresses do show up. What does not show up is interacting with write methods on a custom smart contract.

No idea whats going on here but frustrating as well.

Happening on React Web app + Wallet Connect + Web3 React with ethers.js
IOS Metamask

@un7c0rn
Copy link

un7c0rn commented Jan 3, 2022

+1 seeing the same issue.

@un7c0rn
Copy link

un7c0rn commented Jan 4, 2022

@alexanderMontague were you able to find a workaround for this? I'm having the exact same problem, everything works consistently except interacting with write methods on a custom smart contract.

@ValentinGuevara
Copy link

Hey everyone, I’ve tried all day long to sign a transaction on MetaMask sent by my DApp test iOS application. Unfortunately, I can easily connect my MetaMask account at first but I’m unable to have my transaction signed. I see I have a good intent cause I’m forwarded to MetaMask app when I call connector.signTransaction. But when I’m on the UI, nothing happens. I’m totally screwed. I don’t know what I could try more

@intergalacticspacehighway
Copy link

intergalacticspacehighway commented Jan 27, 2022

Same issue. I am guessing most of the issues are happening due to using older walletconnect client in metamask (1.5.1). Lots of releases have been made. I can see @gantunesr working here has upgraded the client.

@ValentinGuevara
Copy link

@intergalacticspacehighway Do you think it will be fixed quckly ?

@gantunesr
Copy link
Member

Hey @intergalacticspacehighway and @ValentinCPE, you can follow the current work related to WC in the issues #3581 and #3583. And the PRs #3637 and and #3627.

@xrpdevs
Copy link

xrpdevs commented Mar 5, 2022

A workaround is to delete window.localStorage item for walletconnect, which will allow user to go through the process signing in with the QR code again, and hopefully manages to complete their transaction before screen timeout on iphone w/metamask mobile. HTH someone.

@charleslukes
Copy link

experiencing same issue, after connection with the QR code, no other requests or transactions works. its seems like on screen lock metamask makes all sessions inactive.

@un7c0rn
Copy link

un7c0rn commented Mar 8, 2022

Fix:

  • Ensure WC version 1.7.1+
  • Host your own load balanced bridge with an SSL cert (see [1])
  • Do this (or similar) whenever you want to delete the connection (e.g. to change the wallet or the account):
function removeWalletConnectFromLocalStorage() {
  localStorage.removeItem("walletconnect");
  localStorage.removeItem("WALLETCONNECT_DEEPLINK_CHOICE");
}

[1] https://twitter.com/michiels/status/1478494782590750722

@gantunesr
Copy link
Member

Hey everyone, WalletConnect got an enhancement in the last release v4.2.0

Can you verify if this is still an issue??

@intergalacticspacehighway @ValentinCPE @charleslukes @xrpdevs @VexyCats

@BigMadCode
Copy link

Is there still no fix to this? anyone?

@BigMadCode
Copy link

Fix:

  • Ensure WC version 1.7.1+
  • Host your own load balanced bridge with an SSL cert (see [1])
  • Do this (or similar) whenever you want to delete the connection (e.g. to change the wallet or the account):
function removeWalletConnectFromLocalStorage() {
  localStorage.removeItem("walletconnect");
  localStorage.removeItem("WALLETCONNECT_DEEPLINK_CHOICE");
}

[1] https://twitter.com/michiels/status/1478494782590750722

Is this a fix for the transaction issue? because all this seems to do is disconnect the account.

@un7c0rn
Copy link

un7c0rn commented Mar 20, 2022

Fix:

  • Ensure WC version 1.7.1+
  • Host your own load balanced bridge with an SSL cert (see [1])
  • Do this (or similar) whenever you want to delete the connection (e.g. to change the wallet or the account):
function removeWalletConnectFromLocalStorage() {
  localStorage.removeItem("walletconnect");
  localStorage.removeItem("WALLETCONNECT_DEEPLINK_CHOICE");
}

[1] https://twitter.com/michiels/status/1478494782590750722

Is this a fix for the transaction issue? because all this seems to do is disconnect the account.

The code snippet is for disconnecting the account on mobile which lets your re-initiate the WalletConnect QR modal forcefully. The bullets above solve the transaction issue.

@Naguz
Copy link

Naguz commented May 6, 2022

The severity of this bug should be changed. "A possible confusion or deception that is only hypothetical & has no known instances in the wild" is obviously not the right category for a bug that often makes it impossible to interact with smart contracts in any way on a variety of dApps. Experiencing this problem repeatedly with Stellaswap. Clearing private data in settings, clearing app cache, deleting cookies in browser etc. does not work. It forces a new wallet conenction response, but the transaction request never appears in the app when initating a contract interaction.

As the MM built-in browser is basically unusable at the moment as well (see #4162) this makes it a major PITA to use MM mobile atm.

@geoshak
Copy link

geoshak commented Jun 7, 2022

We are building a dApp that uses WalletConnect on mobile browsers to connect with Metamask mobile, and we are experiencing the same issue when trying to connect the webapp to Metamask.

Sometimes the Metamask 'connect website' will not work, but on a second attempt it will work, or sometimes it requires closing the app and then trying again.

@zaydadnan08
Copy link

@michiels Did the monorepo change work -- I can't figure out how I'm supposed to use this new server, or which bridge the requests should be made to. For reference, I am using a wallet connect dart sdk on a mobile to mobile connection

@zihangg
Copy link

zihangg commented Jun 27, 2022

+1 on this issue.

Using other wallets through WC gets me unstable signatures. Signs in with the wallet some times but often times not. Need multiple refreshes to properly sign in.

Using REACT & ethers.js.

@ZuulAndRibbon
Copy link

same problem on this issue.i use walletconnect to connect to the wallet in mobile phone,but when i request the method from the contract,metamask don't pop up comfirm dialog

@CascadiaTech
Copy link

Any update on this? I have the same issue, walletconnect is perfect on desktop but mobile no requests go through. should i update WC cause its been patched? if not someone send over where we are at with fixing this and I can go for a bit of a deep dive.

@mustafa-demirci
Copy link

+1 Same issue here

@Akis-GitHub
Copy link

yeah metamask is unusable. I'm searching for alternative wallet app to use with walletconnect

@CascadiaTech
Copy link

I found with myself I just needed to add an extra step for mobile signing. Check out the function below I use for sending transactions via metamask on mobile.

import { Contract } from '@ethersproject/contracts'
import { ExternalProvider, JsonRpcFetchFunc, Web3Provider } from '@ethersproject/providers'
import { useWeb3React } from '@web3-react/core'
import { parseEther } from '@ethersproject/units'
const context = useWeb3React()
const { library } = context

async function handleMint() {

try {
const data = NFTAbiObject /// just import your abi as an object.
const abi = data
const contractaddress = '0x00000000000000000000' // contract address
const provider = new Web3Provider(library?.provider as ExternalProvider | JsonRpcFetchFunc)
const signer = provider.getSigner()
console.log(signer)
const contract = new Contract(contractaddress, abi, signer)
const ethervalue = PurchasedNftAmount * 0.125
const etherstringvalue = JSON.stringify(ethervalue)
const MintNFT = await contract.Mint(NftAmount, { value: parseEther(etherstringvalue) }) //.claim()
const awaitsigning = await signer.signTransaction(MintNFT)
//this above step what I was missing. this is not necessary with desktop transactions
const FinalTransaction = await awaitsigning
return FinalTransaction
} catch (error) {
console.log(error)
setLoading(false)
} finally {
setLoading(false)
}

}

Hope this helps someone!

@christopherferreira9
Copy link
Contributor

Hi all! WalletConnect v1 is no longer supported. Please update WalletConnect to v2 with the supported MetaMask wallet (v7.4.0)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community Issues or PRs opened by the MM community deeplinks Deeplinks related issue or bug Sev3-low A possible confusion or deception that is only hypothetical & has no known instances in the wild team-sdk SDK team type-bug Something isn't working
Projects
None yet
Development

No branches or pull requests