Ethereum function completed not event not showing up

0 votes

I have the following contract:

Contract Store{

    event Purchase(address buyer, int item_id);

    struct Product {
        string name;
        uint price;
        string desc;
        uint quantity;
        bool enabled;
    }

    mapping (address => int) balances;

    function buyProduct(uint id) returns(bool){
        if(products[id].quantity <= 0){ return false; }

        balances[msg.sender] = balances[msg.sender] - int(products[id].price);
        products[id].quantity--;
        Purchase(msg.sender, id);
        return true;
      }

}

When I use web3 to purchase a product with Store.buyProduct, the product purchase is made, but the event doesn't fire on the front-end. Here is my event watcher code:

var eventFilter = Store.deployed().Purchase({from: "0xe02b4fc50f429624937e9425e1243292857291e2"}, {fromBlock: 0, toBlock: 'latest'});

eventFilter.watch(function(error, event){
    console.log('hai');
    console.log(event);
});
Oct 24, 2018 in Blockchain by slayer
• 29,310 points

retagged Nov 22, 2018 by Priyaj 161 views

2 answers to this question.

0 votes
Are you passing the right arguments with right datatypes?
answered Oct 24, 2018 by Omkar
• 69,170 points
0 votes

Oh ya. I was passing unit but I had to pass int. It works now, thanks

answered Oct 24, 2018 by slayer
• 29,310 points

Related Questions In Blockchain

0 votes
2 answers

How to get notified when an event triggers on ethereum smart contract?

Muchas gracias. ?Como puedo iniciar sesion? READ MORE

answered May 2, 2020 in Blockchain by aqowcmbevs
1,258 views
0 votes
1 answer

Error in Chaincodes not getting picked up by ./startFabric.sh

After changing chaincode in fabric-samples/chaincode/fabcar/go/fabcar.go (this is ...READ MORE

answered Jul 31, 2018 in Blockchain by Shashank
• 10,400 points
631 views
0 votes
1 answer

Ethereum smart contract event trigger notification

I have an example here for web3js ...READ MORE

answered Aug 1, 2018 in Blockchain by slayer
• 29,310 points
1,073 views
0 votes
1 answer

Ethereum wallet not able to make transaction

I can see that the nonce you ...READ MORE

answered Aug 9, 2018 in Blockchain by slayer
• 29,310 points
161 views
0 votes
1 answer

Truffle tests not running after truffle init

This was a bug. They've fixed it. ...READ MORE

answered Sep 11, 2018 in Blockchain by Christine
• 15,830 points
696 views
0 votes
1 answer
+3 votes
2 answers

How to run ethereumjs using Node.JS

You need to install testrpc globally on ...READ MORE

answered Mar 27, 2018 in Blockchain by ned_crew
• 1,610 points
460 views
0 votes
1 answer
0 votes
1 answer

TypeError: XMLHttpRequest is not a function when using web3 on meteor server side

I had the same problem. Instead ethereum:web3 Meteor package ...READ MORE

answered Oct 10, 2018 in Blockchain by Omkar
• 69,170 points
363 views