I am building a DAPP based on drizzle box. I am struggling to find out how can i get the web3 instance without initiating a new one I want to end up with something like :
this.props.web3.eth
Thanks
Ethereum Stack Exchange is a question and answer site for users of Ethereum, the decentralized application platform and smart contract enabled blockchain. It only takes a minute to sign up.
Sign up to join this communityAs described here : https://github.com/trufflesuite/drizzle-react/issues/22
This can be done via:
this.context.drizzle.web3...
In order to make this work, you have to pass the context variable to the constructor:
constructor(props, context) {
super(props)
...
}
and make shure you added drizzle to your context-types:
ExampleComponent.contextTypes = {
drizzle: PropTypes.object
}
If you have the drizzle object available, you just find it at drizzle.web3
If you use drizzle context or drizzle-react. drizzle is just an object that you can access directly. Make sure drizzle is in sync and not undefined. For example
if(drizzle !== undefinde) console.log(drizzle.web3)
and there it is.