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.

WalletConnectProvider not working with Web3.js

See original GitHub issue

I was following the code written in here https://docs.walletconnect.org/quick-start/dapps/web3-provider But it seems that the Web3 class cannot be initialized with the WalletConnectProvider class or any of its properties from what I can see.

Argument of type 'WalletConnectProvider' is not assignable to parameter of type 'provider'.
  Type 'WalletConnectProvider' is not assignable to type 'string'

I’m using web3 ^1.2.11 and @walletconnect/web3-provider ^1.2.1 on TypeScript. Is the doc outdated or is there something that I am missing?

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
limcheekincommented, Aug 25, 2021

I have the same issue with the following versions:

"web3": "^1.5.2",
"@walletconnect/web3-provider": "^1.6.4"

I found the following workaround might be helpful to someone having the issue in the future:

import WalletConnectProvider from "@walletconnect/web3-provider"
import { JsonRpcPayload, JsonRpcResponse } from 'web3-core-helpers';
import { AbstractProvider } from 'web3-core/types'

export declare class WalletConnectWeb3Provider extends WalletConnectProvider implements AbstractProvider {
  sendAsync(payload: JsonRpcPayload, callback: (error: Error | null, result?: JsonRpcResponse) => void): void;
}

// then in your code
const provider = new WalletConnectProvider({
  infuraId: "[YOUR_INFURA_ID]",
});

await provider.enable()

const web3 = new Web3(provider as WalletConnectWeb3Provider)

Hope this help.

0reactions
finessevanescommented, Dec 1, 2022

@hoonsubin, @crypto-yang, @limcheekin are either on of you still experiencing this issue?

Read more comments on GitHub >

github_iconTop Results From Across the Web

e is not a constructor - WalletConnectProvider model not ...
i have fixed the problem, by adding const WalletConnectProvider = window.WalletConnectProvider.default; inside constructor().
Read more >
Web3 with WalletConnectProvider is not responding when ...
I am using angular with walletconnectprovider and web3 I have this issue with calling any methods from the contract where web3 is not...
Read more >
@walletconnect/web3-provider - npm
Start using @walletconnect/web3-provider in your project by running `npm i ... import Web3 from "web3"; import WalletConnectProvider from ...
Read more >
Connecting to web3 with Web3Modal, react & ethers.js
I'm writing this article solely with hope that one day it ends up high in web searches for this specific problem & it...
Read more >
Web3Modal Demo - CodePen Embed
Web3Modal.default; const WalletConnectProvider = window. ... is a BigNumber instance // https://github.com/indutny/bn.js/ const ethBalance = web3.utils.
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