Advertisement
Guest User

Untitled

a guest
Jul 19th, 2019
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. @main.route('/refresh', methods=['GET', 'POST'])
  2. @login_required
  3. def refresh():
  4. token_addr = '0x8e30ea2329d95802fd804f4291220b0e2f579812'
  5. receive_addr = '580c6b022a3d1c31d348fc5a8d03d516da8ba312'
  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