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,370 points

retagged Nov 22, 2018 by Priyaj 870 views

2 answers to this question.

0 votes
Are you passing the right arguments with right datatypes?
answered Oct 24, 2018 by Omkar
• 69,220 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,370 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
2,392 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
1,253 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,370 points
2,080 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,370 points
637 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,790 points
1,922 views
0 votes
1 answer

Hyperledger Sawtooth vs Quorum in concurrency and speed Ask

Summary: Both should provide similar reliability of ...READ MORE

answered Sep 26, 2018 in IoT (Internet of Things) by Upasana
• 8,620 points
1,451 views
+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
1,409 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,220 points
1,078 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP