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

retagged Nov 22, 2018 by Priyaj 14 views

2 answers to this question.

0 votes
Are you passing the right arguments with right datatypes?
answered Oct 24, 2018 by Omkar
• 67,120 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,050 points

Related Questions In Blockchain

0 votes
1 answer

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 ariaholic
• 7,320 points
290 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,330 points
118 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,050 points
151 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,050 points
31 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
105 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,620 points
119 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
• 67,120 points
57 views