Skip to content
This repository has been archived by the owner on Mar 11, 2024. It is now read-only.

How to get the web3 instance? #37

Closed
vertangelx opened this issue May 29, 2018 · 3 comments
Closed

How to get the web3 instance? #37

vertangelx opened this issue May 29, 2018 · 3 comments
Labels

Comments

@vertangelx
Copy link

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?

@robtg4
Copy link

robtg4 commented Aug 20, 2018

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
}

@stale
Copy link

stale bot commented Jan 16, 2019

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.

@stale stale bot added the wontfix label Jan 16, 2019
@stale
Copy link

stale bot commented Jan 23, 2019

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.

@stale stale bot closed this as completed Jan 23, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants