How to get the web3 instance?
vertangelx opened this issue · comments
I need to perform something using the web3
instance, like
this.props.web3.eth.getBalance(address)
Drizzle only provides us with state.web3.status
, not the web3
instance itself. However there are some unused files that might be able to help us achieve this in source/util/web3
.
Any ideas on how we can expose/access the actual web3
instance?
Should be this.context.drizzle.web3.eth.getBalance(address) - need to make sure that you are passing 'context' variable in constructor - should look like this:
class ComponentName extends Component {
constructor(props, context) {
super(props)
/* local state variables */
this.state = {
tokenName: '',
tokenBalance: 0,
}
this.handleClose = this.handleClose.bind(this);
this.handleCloseAgain = this.handleCloseAgain.bind(this);
}
...
}
ComponentName.contextTypes = {
drizzle: PropTypes.object
}
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
This issue has been closed, but can be re-opened if further comments indicate that the problem persists. Feel free to tag maintainers if there is no reply to further comments.