0

I am using the following Drizzle (Truffle) component to call a function from a smart contract:

<ContractData contract="Market" method="priceOf" methodArgs={this.props.id}/>

The result is a React Element that contains number in Wei: 4000000000000000

Now, I am saving this in the state, and this is rendered when this.state.price is rendered. However, when I want to pass {this.state.price} as props price={this.state.price}, it does not work, the error message is that the React element can't be cloned.

Is there any way to get/parse/query/copy the raw data of the React Element? I need that 4000000000000000 as a number (Number() and parseInt() are giving NaN, toString() gives [object Object])

0

I think what you want to do is move away from the drizzle-react-component ContractData and go back to using drizzle to query contract state.

Using CacheCall to get contract state.

https://truffleframework.com/docs/drizzle/getting-started/contract-interaction.

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.