Closed tung-eh closed 4 years ago
If you want to initialize a contract in that method, you would have to instantiate your own Web3.js object (because as you say, there is no web3
instance at the time of initialization). This is why it's recommended to use the mainstream approach of just passing in the Truffle artifact.
Alternatively, you can do this asynchronously (i.e. waiting until the drizzleContext
is available) so you don't need to create your own web3
instance.
Yeah, I followed the second way - asynchronously init the contract after component mounted. Thank you.
According to the drizzle docs, I can initial contract with object like
How can I get the
web3
instance to do it. As I know, I can get the web3 instance fromdizzleContext
but this object need to be create to pass toDrizzleContext.Provider
- whendrizzleContext
is not available.I'm new to
Ethereum
anddrizzle
, sorry if I misunderstood anything.