2

I am using Truffle for writing smart contract and using drizzle and drizzle-react for communicating with smart contract.

I have configured as tutorial said. After that, I try to print out:

this.props.contracts.MyContract

It will print a bunch of public state, public method on smart contracts ... So I think when come to this step, there is no problem.

But when I try to call method as tutorial:

this.props.contracts.MyContract.methods.set(this.state.storageAmount).send()

I meet exception because inside this.props.contracts.MyContract, there is no methods object, so it will undefined. What am I wrong ? Please tell me.

1

contracts can be accessed via context in component. make sure that you defined drizzle context types and assign contracts as this.contracts = context.drizzle.contracts in your component.

btw see my pr on github

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.