Comments (2)
connector, hooks
The same way you got connector
and hooks
from useWeb3React, you can also get a provider.
Everytime you're connected, you get a provider. the provider becomes undefined when you disconnect.
to fix:
instead of this:
const { connector, hooks } = useWeb3React();
You can also get the provider alongside connector and hooks like so
const { connector, hooks, provider } = useWeb3React();
And instead of creating your contract instance like this:
const contract = new Contract(abi, address { provider: 'http://127.0.0.1:8545' });
you can create it using the provider from web3-react
const contract = new Contract(abi, address, provider);
from web3-react.
Hi! I was also looking for an answer to the question, this code with web3.js works
const { connector } = useWeb3React();
...
const web3 = new Web3(connector.provider);
web3.eth.Contract(abi, address)
...
from web3-react.
Related Issues (20)
- Coinbase Connecting Issue
- Module parse failed: Unexpected token walletconnect-v2 HOT 1
- Create Fork
- @mousewifhat, kind reminder: please pay fee: **500 TWT** with the memo **27116** to the address `bnb158fgd782we4tz9vwwcj9pmmxvxhl6z46lfm7c8`.
- How to connect Trezor wallet using web3-react v8
- Why is `connector.deactivate` always undefined? HOT 1
- **The latest updates on your projects**. Learn more about [Vercel for Git ↗︎](https://vercel.link/github-learn-more)
- Walletconect v2 chains not supported
- V3-core
- TypeError: Object(...) is not a function (WalletConnectV2) HOT 1
- How can I sign a transaction using web3-react library?
- dotnet add package dotnetstandard-bip39 --version 1.0.2
- Something happend with intendation
- How can I send transaction to ethereum via metamask?
- tags` as well.beezywqp
- How can i connect okx wallet (web3-react v6) ??
- Did Uniswap abandon this repo?
- gm
- How can i use network connection as a fallback connector? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from web3-react.