I have set up drizzle to be able to connect to my smart contract from my react-application. After some fiddling, I decided to make this function in my smart contract:

/*** test ***/
uint numberFive = 5;

function getNumber() public view returns (uint) { 
    return numberFive;

Then I tried to output the number on my page.

class Logged extends Component {
  constructor(props, context) {
    this.contracts = context.drizzle.contracts;
    this.methods = this.contracts.ItemOwnership.methods;
    this.numberKey = this.contracts.ItemOwnership.methods.getNumber.cacheCall();


  render() {
    // If the data isn't here yet, show loading
    if(!(this.numberKey in this.props.ItemOwnership.getNumber )) {
      return (
        <h1>Not retrieved yet</h1>
    let number = this.props.ItemOwnership.getNumber[this.numberKey].value;
    return (
        <Container className="logged-in">
            <Col className="center">
              <h4>You are logged in to:</h4>
              <h6>{this.props.account} </h6>
        <br />

const mapStateToProps = state => {
  return {
    account: state.accounts[0],
    ItemOwnership: state.contracts.ItemOwnership,

Logged.contextTypes = {
  drizzle: PropTypes.object,
export default drizzleConnect(Logged, mapStateToProps);

The test above returns null. However, cacheCall does update the value, as seen in this image of the drizzle store: enter image description here

1 Answer 1


Solved. Setting metamask to main net then back to localhost resolved this

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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