I have the following simple contract
pragma solidity ^0.4.0;
contract ClientReceipt {
event Deposit(
address indexed _from,
bytes32 indexed _id,
uint _value
);
function deposit(bytes32 _id) public payable {
Deposit(msg.sender, _id, msg.value);
}
}
and then a node js file listening to the Deposit event:
let ClientReceiptContract = initContract(ClientReceiptJSON);
ClientReceiptContract.deployed().then(clientReceipt => {
var event = clientReceipt.Deposit();
event.watch(function(error, result){
if (!error) {
console.log(result);
}
});
});
I am using truffle and truffle-contact to get the abi of the contract.
I am using the test rpc running the
truffle develop
command.
So first I compile the contract, the migrate and then run the node application.
When I call the Deposit function:
ClientReceipt.deployed().then(inst => inst.deposit(1,{value: 6000000000000000000}));
my node application catches the event and displays the args.
When I stop the node application and run it again, it returns the latest event without triggering any event in the contact.
Any ideas what might be the problem? I guess it has to do with the block number but I don't know how to fix it.