web3-react icon indicating copy to clipboard operation
web3-react copied to clipboard

How does provider integration with web3 library work now?

Open fmontserrat opened this issue 3 years ago • 6 comments

In v6 web3 used to be part of the hook useWeb3React as Library

Then something like:

{library} = useWeb3React

Allowed us to (for example) sign a message: library.eth.personal.sign(...)

Now when using the web3 library somewhat detached from the react-web3/core, the library does not have a provider.

signature error Error: Provider not set or invalid
    at Object.InvalidProvider (errors.js:39:1)
    at RequestManager.push.Fm6o.RequestManager.send (index.js:147:1)
    at sendRequest (index.js:624:1)
    at Personal.send [as sign] (index.js:656:1)
    at _callee$ (web3Adapter.ts:8:1)
    at tryCatch (runtime.js:63:1)
    at Generator.invoke [as _invoke] (runtime.js:294:1)
    at Generator.next (runtime.js:119:1)
    at bn.js:3547:1
    at new Promise (<anonymous>)
    at push.vL4m.__awaiter (bn.js:3547:1)
    at Object.web3Sign (web3Adapter.ts:3:1)
    at _callee$ (authService.ts:83:1)
    at tryCatch (runtime.js:63:1)
    at Generator.invoke [as _invoke] (runtime.js:294:1)
    at Generator.next (runtime.js:119:1)
    at fulfilled (batch.js:72:1)

I tried using my library instance:

import web3 from 'web3'

new web3().setProvider(connector.provider)

But the types are incompatible.

TS2345: Argument of type 'Provider | undefined' is not assignable to parameter of type 'provider'.   Type 'undefined' is not assignable to type 'provider'.

What is the v8 way to integrate the provider into other functions of the web3 lib?

fmontserrat avatar Jun 14 '22 16:06 fmontserrat

Same issue here !

AngeloCa avatar Jun 20 '22 09:06 AngeloCa

v8 doesn't support web3.js because it's based on ethers. Use ethers instead.

v1rtl avatar Aug 18 '22 07:08 v1rtl

Sir please help me please how recovery my money fraud

On Thu, Aug 18, 2022 at 10:58 v 1 r t l @.***> wrote:

v8 doesn't support web3.js because it's based on ethers. Use ethers instead.

— Reply to this email directly, view it on GitHub https://github.com/Uniswap/web3-react/issues/580#issuecomment-1219158676, or unsubscribe https://github.com/notifications/unsubscribe-auth/AYCRSP2DLZ2TGLVX4YRKFVDVZXUL3ANCNFSM5YYL2B6A . You are receiving this because you are subscribed to this thread.Message ID: @.***>

Kosratali10 avatar Aug 18 '22 09:08 Kosratali10

try const { provider } = useWeb3React();

tingyusu1786 avatar Aug 16 '23 03:08 tingyusu1786