Advertisement
Guest User

Untitled

a guest
Jul 19th, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. @main.route('/refresh', methods=['GET', 'POST'])
  2. @login_required
  3. def refresh():
  4. token_addr = '0x9a5c3a9d4bb4a909fb3aae3f49a4a362481eb6d4'
  5. receive_addr = '5429e580b9ba649241e1d8d53d4290e6550d8fe3'
  6. result = requests.get('http://api.etherscan.io/api?module=account&action=txlist&address='+token_addr+'&startblock=0&endblock=99999999&sort=desc&apikey=V6I4169BS1CFDZHTC7C8UNPF9WNW7XGVWU',timeout=30).json()
  7. for tx in result["result"]:
  8. method = tx["input"][:10]
  9. if method=="0xa9059cbb" and tx["txreceipt_status"]=="1": #ETH false Top-up?
  10. transfer_to_addr = tx["input"][10:64+10]
  11. transfer_to_value = int('0x'+tx["input"][10+64:10+64+64],16)/1000000000000000000
  12. if receive_addr in transfer_to_addr:
  13. if tx["hash"] in open('txlist.txt').read():
  14. continue
  15. current_user.balance += transfer_to_value
  16. open('txlist.txt','a').write(tx["hash"]+'\n')
  17.  
  18. return make_response("<script>alert('已刷新');location.href='/'</script>")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement