reactjsnext.jsweb3-react

In v8 how do we extract "library" from useWeb3React()


This is the code in v6 of "@web3-react/core" package

const { chainId, library } = useWeb3ReactCore<Web3Provider>()

In v8 library doesn't exist, how can I get it?

I need to use following methods:

await library.getBlockNumber()
const result = await library.call({
  to: call.address,
  data: call.callData,
})

Solution

  • I found the answer: replacing library with provider

    const { chainId, provider } = useWeb3ReactCore<Web3Provider>()
    

    This worked.