metamask-mobile icon indicating copy to clipboard operation
metamask-mobile copied to clipboard

WalletConnect - Metamask fails to receive the transaction

Open VexyCats opened this issue 4 years ago • 42 comments

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 avatar Dec 04 '20 03:12 VexyCats

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

VexyCats avatar Dec 13 '20 04:12 VexyCats

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

rigwild avatar Mar 18 '21 01:03 rigwild

Any updates on this issue?

toki-sean avatar Apr 24 '21 04:04 toki-sean

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!

omnat avatar Apr 26 '21 18:04 omnat

Looks like @hexyls and @Mi-Lan seen it too (https://github.com/protofire/omen-exchange/pull/1821#issuecomment-820971060)

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.

rigwild avatar Apr 27 '21 07:04 rigwild

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

jonathankoh24 avatar Apr 27 '21 08:04 jonathankoh24

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

StillFantastic avatar May 07 '21 03:05 StillFantastic

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.

nithronium avatar May 07 '21 13:05 nithronium

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.

jeromevvb avatar Jun 09 '21 08:06 jeromevvb

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 avatar Jul 24 '21 20:07 mhorsley30896

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

mhorsley30896 avatar Jul 24 '21 20:07 mhorsley30896

@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.

StillFantastic avatar Jul 25 '21 04:07 StillFantastic

@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

mhorsley30896 avatar Jul 25 '21 10:07 mhorsley30896

@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.

StillFantastic avatar Jul 25 '21 10:07 StillFantastic

@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.

rigwild avatar Jul 25 '21 11:07 rigwild

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.

andrepimenta avatar Aug 17 '21 16:08 andrepimenta

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 ?

saveriocastellano avatar Oct 20 '21 01:10 saveriocastellano

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

hnvn avatar Nov 27 '21 17:11 hnvn

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.

just-a-normal-human avatar Nov 29 '21 15:11 just-a-normal-human

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.

nexus6nexus6 avatar Dec 07 '21 21:12 nexus6nexus6

+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

alexanderMontague avatar Dec 22 '21 21:12 alexanderMontague

+1 seeing the same issue.

un7c0rn avatar Jan 03 '22 21:01 un7c0rn

@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.

un7c0rn avatar Jan 04 '22 20:01 un7c0rn

+1 on the same issue

I have the following experience.

Both Desktop -> Mobile as Mobile -> Mobile connecting (getAccounts/requestAccounts) works all the time. In my app I'm primarily using personal sign to do "log in with wallet/NFT"-type of logic. What I notice is that the sign confirmation is less stable. This is especially the case after setting up the connection, then doing a full page refresh, and then doing the personal sign. Restarting MetaMask on iOS suddenly pops up the sign confirmation dialog.

I've now set up my own WalletConnect v1 relay server. It does seem to be a lot more stable. 🎉 But I'd need to load test a bit with more testers to confirm.

It almost seems like sockets from dApp<->WalletConnect relay<->MetaMask iOS are mixed or temporarily broken and then suddenly reconnect upon MetaMask mobile restart.

michiels avatar Jan 04 '22 21:01 michiels

Some additional info.

If I have the websocket logs open in browser there's definitely messages going from the dApp/browser to the relay via the socket. But no return messages (from MetaMask). Only when restarting MetaMask suddenly get response information in the socket and MetaMask suddenly shows confirmation dialog.

Still not 100% reproducable, so that's weird.

To attempt to reproduce:

  1. Create a new "login with wallet/NFT" flow on Clubcard dApp:
curl https://app.clubcard.dev/api/v1/access_intents \
  -H 'Content-Type: application/json' \
  -d '{"description": "MetaMask issue test",
      "profile_name": "Clubcard",
      "return_url": "https://clubcard.notion.site/Hi-MetaMask-tester-16e886a5429d45c1a6c36d947f9d9d37"}'
  1. Connect your wallet via WalletConnect option. Scan QR. Connect in MetaMask mobile.
  2. Wait for page to update. Press Sign & Continue button.
  3. Confirm request in MetaMask <-- This may not work until you restart MetaMask mobile client.
  4. Land on confirmation page I set up on my Notion.

michiels avatar Jan 04 '22 21:01 michiels

FYI all in this thread. Is this the fix we needed? https://github.com/WalletConnect/walletconnect-monorepo/pull/682

michiels avatar Jan 11 '22 21:01 michiels

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

ValentinCPE avatar Jan 23 '22 23:01 ValentinCPE

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.

@intergalacticspacehighway Do you think it will be fixed quckly ?

ValentinCPE avatar Jan 27 '22 09:01 ValentinCPE

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.

gantunesr avatar Jan 27 '22 11:01 gantunesr