0

I'm trying to call the storeQueryResults() function of my smart contract in the following way:

storeInput: function(event) {
    var queryResultHandlerinstance;

    App.contracts.QueryResultHandler.deployed().then(function(instance) {
      queryResultHandlerinstance = instance;
      return queryResultHtandlerinstance.storeQueryResults(1, 2, "a", "b", {
        from: web3.eth.accounts[0]
      });
    }).then(function(result) {
      alert("success");
    }).catch(function(err) {
      alert(err.message);
    });
  },
};

Then, after confirming the transaction in Metamask, I can see it is approved there:Metamask_printscreen

However, in Ganache nothing happens: Ganache_printscreen

2 Answers 2

0

So, I have figured it out. Temporarily, I removed MetaMask and tried it out by only using Ganache. Then, I got a proper error message saying that the transaction exceeds the gas limit. Therefore, I added 'gas: 3000000' as a parameter, so my transaction looks like this:

App.contracts.QueryResultHandler.deployed().then(function(instance) {
    queryResultHandlerinstance = instance;

    return queryResultHandlerinstance.storeQueryResults(1, 2, "a", "b", {
        from: web3.eth.accounts[0],
        gas: 3000000
    });
}).then(function(result) {
    alert("success");
    }
}).catch(function(err) {
  alert(err.message);
});

So, as a takeaway, I don't think that MetaMask returns errors properly and explicitly defining the gas limit is important.

-2

I also have difficulty viewing transactions under the Transactions tab within Ganache. Can you see the transaction under the Logs tab?

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.