I have an event set up in the Contract.
Contact Packages
emit Spend(msg.sender, msg);
function sendPackage(msg) external payable returns(bool) {
require(
msg.value == price,
'Please send the correct amount of ETH to make send a message'
);
emit Spend(msg.sender, msg);
return true;
}
And a script in NodeJS that listens to new events.
The intention is to kick off some NodeJS code whenever a new event on the contract takes place.
But whenever I start the script, the Contract.on(..
fires and the last event is passed to it, even though the event fired a hour ago.
Is there a way to config the callback to NOT include previous events?
Contract.on('Spend', (sender, event) => {
console.log(sender);
console.log(event);
});
EDIT
I've tried to use Contact.once
and the same result occurs.