I'm trying to build a frontend for my Dapp and first, I wanted to test if I can initiate a transaction at all. I have a Button which calls the storeInput() function. Then, it should invoke the storeQueryResults(uint256 id1, uint256 id2, string text1, string text2) function of my smart contract. This is my index.js file:

App = {
  web3Provider: null,
  contracts: {},
  account: '0x0'

  init: function() {
    return App.initWeb3();

  initWeb3: function() {
    if (typeof web3 !== 'undefined') {
      App.web3Provider = web3.currentProvider;
      web3 = new Web3(web3.currentProvider);
    } else {
      App.web3Provider = new 
      web3 = new Web3(App.web3Provider);
    return App.initContract();

  initContract: function() {
    $.getJSON("QueryResultHandler.json", function(queryResultHandler) {
      App.contracts.QueryResultHandler = TruffleContract(queryResultHandler);
      return App.render();

  render: function() {
    web3.eth.getCoinbase(function(err, account) {
      if (err === null) {
        App.account = account;

  storeInput: function() {
    App.contracts.QueryResultHandler.deployed().then(function(instance) {
      return instance.storeQueryResults(1, 2, "a", "b", {
        from: App.account
    }).then(function(result) {
      return result;
    }).catch(function(err) {


$(function() {
  $(window).load(function() {

I'm using MetaMask, and I'm actually trying to follow Truffle's pet-shop tutorial regarding the config. http://truffleframework.com/tutorials/pet-shop

However, the button seems to do nothing, it doesn't even fire an error message and in Ganache, no new transactions are displayed. I really don't know, what I'm missing.

Your Answer

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

Browse other questions tagged or ask your own question.