0

I need to write a contract. That contract should detect and alert while receiving token/ether with some parameter. If somebody sends token/ether with some parameter to my contract. I need to know at the time of the transaction received. Is any event available to do this function Thanks in advance

1

For this, you need to

  1. Write a function that emits a so called event.
  2. Events take parameters (the data you want to log). give the event a parameter of the type uint256 and put msg.value as that parameter when emitting the event.
  3. write a listener, that listens to the triggering of such events.

Examples for all of this can be found here: https://solidity.readthedocs.io/en/v0.5.3/contracts.html#events

Hint: If you put as fromBlock: "latest" in your listener script, it will not search for events in the past, but only give you triggered events in "real time".

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.