coopermaruyama/react-web3

Accessing the web3 object

jefflau opened this issue · 3 comments

Is there a way of accessing the web3 object directly? If I wanted to say send a transaction or look up a block how would I do this with this package?

Hey, Initially I was going to do this, and even now it would be just a line change. But the reason I did not do it is because it is already available on window. In other words, anywhere where you would want to access web3 in context, you would also be able to access it on window, so there really is no benefit to having it in context.

Closing this, feel free to re-open if the above does not address your concern

cjol commented

I'm using this in a TypeScript setting, and in that context, it is un-ideal to use window.web3. The reason for that is that window.web3 could be undefined (e.g. in a browser without Metamask). If the context passed it down, then I would be sure that it is not going to be undefined.