Guest User

Untitled

a guest
May 20th, 2018
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. */5 * * * * /home/youruser/getBalance.sh
  2.  
  3. #!/bin/bash
  4. curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getBalance","params":["YOURADDRESS", "latest"],"id":1}' 'http://localhost:PORT'
  5.  
  6. import requests
  7. import json
  8. def balance(address, url):
  9.  
  10. postData = {"jsonrpc":"2.0","method":"eth_getBalance","params":[address, "latest"],"id":1}
  11. #print('p: {}'.format(postData))
  12. response = requests.post(url, data=json.dumps(postData))
  13. print(response.json())
  14. result = response.json()
  15. return result['result']
  16.  
  17. def writebalance(balance):
  18. with open('getBalance.txt', 'w') as f:
  19. f.write(balance)
  20.  
  21. def readbalance():
  22. with open('getBalance.txt', 'r') as f:
  23. bal = f.read()
  24. return bal
  25.  
  26.  
  27. if __name__ == '__main__':
  28. oldbalance = readbalance()
  29. newbalance = balance("YOURADDRESS", 'http://localhost:8545')
  30. if int(newbalance, 16) - int(oldbalance, 16) >0:
  31. print('toto')
  32. writebalance(newbalance)
  33.  
  34. // web3 contract
  35. var web3Contract = new web3.eth.Contract(abi, address);
  36.  
  37. // dagger contract
  38. var contract = dagger.contract(web3Contract);
  39. var filter = contract.events.Transfer({room: 'latest'});
  40.  
  41. // watch
  42. filter.watch(function(data, removed){
  43. // data.returnValues.to : address to which it has been transferred to
  44. // data.returnValues.value : value which has been transferred
  45. });
  46.  
  47. // watch only once
  48. filter.watchOnce(function(data, removed){
  49. // data.returnValues.to : address to which it has been transferred to
  50. // data.returnValues.value : value which has been transferred
  51. });
  52.  
  53. // stop watching
  54. filter.stopWatching();
Add Comment
Please, Sign In to add comment