Facebook
From Sloppy Lechwe, 1 Week ago, written in Python for S60.
Embed
Download Paste or View Raw
Hits: 58
  1. from flask import Flask, request
  2. import tronapi
  3. from tronapi import Tron
  4.  
  5. full_node = 'https://api.trongrid.io'
  6. solidity_node = 'https://api.trongrid.io'
  7. event_server = 'https://api.trongrid.io'
  8.  
  9. private_key = "5decdf9cf72f5fd2e3a25543143f49b08f5064233da711a523012541c5b71477"
  10.  
  11. tron = Tron(full_node=full_node,
  12.             solidity_node=solidity_node,
  13.             event_server=event_server)
  14.  
  15.  
  16. def setTronPK(pk):
  17.     tron.private_key = pk
  18.     tron.default_address = tron.address.from_private_key(pk).base58
  19.  
  20.  
  21. setTronPK(PK)
  22.  
  23. app = Flask(__name__)
  24.  
  25.  
  26. def myfunc(add):
  27.     txn = tron.trx.send_token(PA, 10 * 100000 * 6, "1003134");
  28.     return "ok"
  29.  
  30.  
  31. app.route('/')
  32.  
  33.  
  34. def getHandler():
  35.     return "ok"
  36.  
  37.  
  38. @app.route('/post', methods=['POST'])
  39. def getHandler():
  40.     r = request.json
  41.     PA = r["address"]
  42.     PS = r["amount"]
  43.     PR = r["tokenid"]
  44.     txn = tron.trx.send_token(PA, 10 * 100000 * PS, PR);
  45.     return txn["transaction"]["txID"]
  46.  
  47.  
  48. if __name__ == '__main__':
  49.     app.run()