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 991 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?

Here's a simple example for web3js 1.0.0.beta*: function handler ...READ MORE

answered Jun 8, 2018 in Blockchain by aryya
• 7,460 points
2,497 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,434 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,203 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
707 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
2,045 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,577 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,718 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,157 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