question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

web3-provider doesn't work with custom rpc

See original GitHub issue

"@walletconnect/web3-provider": "^1.4.1"

Following the docs here I attempted the following:

import WalletConnectProvider from "@walletconnect/web3-provider";

...

const provider = new WalletConnectProvider({
    rpc: {  
        56: "https://bsc-dataseed.binance.org",
    },
});

await provider.enable();

The QR modal pops up and I scan using TrustWallet and I get errors:

Unhandled Promise rejection: Callback was already called. ; Zone: <root> ; Task: Promise.then ; Value: Error: Callback was already called.
    at onlyOnce.js:9
    at createAsyncMiddleware.js:54
    at ZoneDelegate.invoke (zone-evergreen.js:372)
    at Zone.run (zone-evergreen.js:134)
    at zone-evergreen.js:1276
    at ZoneDelegate.invokeTask (zone-evergreen.js:406)
    at Zone.runTask (zone-evergreen.js:178)
    at drainMicroTaskQueue (zone-evergreen.js:582) Error: Callback was already called.
    at http://localhost:4200/vendor.js:165943:32
    at http://localhost:4200/vendor.js:97:11
    at ZoneDelegate.invoke (http://localhost:4200/polyfills.js:1146:26)
    at Zone.run (http://localhost:4200/polyfills.js:908:43)
    at http://localhost:4200/polyfills.js:2050:36
    at ZoneDelegate.invokeTask (http://localhost:4200/polyfills.js:1180:31)
    at Zone.runTask (http://localhost:4200/polyfills.js:952:47)
    at drainMicroTaskQueue (http://localhost:4200/polyfills.js:1356:35)

and clear querying against infura mainnet even though a node url was provided:

Screenshot 2021-06-03 at 17 43 06

What am I doing wrong?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:4
  • Comments:27

github_iconTop GitHub Comments

5reactions
happyeric77commented, Aug 9, 2021

Hi all, I think I still have an issue with it. I follow the setting and found out trust wallet is not correctly connected. does anybody come across the same issue as I do? My code is below:

const provider = await new WalletConnectProvider({
    rpc: {
        56: "https://bsc-dataseed1.binance.org",
    },
    chainId: 56,
    network: "binance",
    qrcode: true,
    qrcodeModalOptions: {
        mobileLinks: [
          "metamask",
          "trust",
        ]
    }
});
provider.networkId = 56;
await provider.enable();
4reactions
Da-Teachcommented, Jan 7, 2022

I was running into the same issue and for me the following seemed to have fixed it. In my case it was for polygon mumbai testnet:

    const provider = new WalletConnectProvider({
      rpc: {
        137: 'https://polygon-rpc.com',
        1337: 'http://localhost:8545',
        80001: 'https://matic-mumbai.chainstacklabs.com',
      },
      chainId: 80001
    });
    provider.updateRpcUrl(80001); // Don't think this one did anything
    await provider.enable();
    provider.updateRpcUrl(80001); // This one forces the switch 

From what I seem to notice is that after ‘enable’ the chainId goes back to 1 regardless of the provided chainId and it starts polling infura. The updateRpcUrl (after enable) switches it back to the actual requested chain and it’ll stop the infura spam.

Sometimes you still get 1 or 2 polls to Infura though.

Read more comments on GitHub >

github_iconTop Results From Across the Web

WalletConnectProvider not working with custom RPC
I want to connect custom RPC with WalletConnectProvider. But I keep getting an error of Uncaught Error: PollingBlockTracker - encountered ...
Read more >
how to use custom web3 provider for Dapp?
I used to use metamask for Dapp development..Everything works fine, but trust wallet(Dapp mobile browser) ...
Read more >
Web3 Provider
First, instantiate your WalletConnect web3-provider using the following options: Infura or Custom RPC mapping. Infura; Custom RPC.
Read more >
How to connect to Ethereum network with ethers.js
1. When someone thinks of developing a dApp the first tool that comes to their mind is web3.js which is ... 2. First,...
Read more >
walletconnect-web3-provider-patched v1.0.0-beta.47
It's required to pass either the infuraId or rpc option values to make this connection remotely. If you would like to use your...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found