Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. contract Transfereventaction {
  2.  
  3. event Deposit(
  4. address indexed _from,
  5. bytes32 indexed _id,
  6. uint _value
  7. );
  8.  
  9. function deposit(bytes32 _id) public payable {
  10. // Events are emitted using `emit`, followed by
  11. // the name of the event and the arguments
  12. // (if any) in parentheses. Any such invocation
  13. // (even deeply nested) can be detected from
  14. // the JavaScript API by filtering for `Deposit`.
  15. emit Deposit(msg.sender, _id, msg.value);
  16. }
  17.  
  18. }
  19.  
  20. const infura = "ws://ropsten.infura.io/v3/id";
  21. const web3 = new Web3(new Web3.providers.WebsocketProvider(infura));
  22. var ClientReceipt = new web3.eth.Contract(abi ,contract_address);
  23.  
  24. ClientReceipt.events.Deposit({
  25. fromBlock: "latest"
  26. }, (error, event) => { console.log("Event result is "+ event); }).on('data', (event) => {
  27. console.log("data event"+event); // same results as the optional callback above
  28. }).on('changed', (event) => {
  29. console.log("changed event" + event) // remove event from local database
  30. })
  31. .on('error', console.error);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement