joyso.py 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import requests
  2. from random import randrange
  3. import json
  4. from app.api.api_v1.endpoints import models
  5. from fastapi import APIRouter
  6. router = APIRouter()
  7. baseUrl = "https://nft-api-staging.joyso.io/api/v1/"
  8. headers = {'Authorization': 'Basic %s' %
  9. 'bmZ0OmMxOTEzOWMzYjM3YjdjZWU3ZmY3OTFiZGU3NzdjZWNl'}
  10. # # Get address
  11. # path = 'accounts/test01'
  12. # r = requests.get(baseUrl + path, headers=headers)
  13. #
  14. # print(r.json())
  15. # Mint
  16. @router.post("/mint")
  17. async def mint(userModel : models.joysoMint):
  18. path = "erc1155/mint"
  19. txid = str(randrange(99999))
  20. to = userModel.toaddress
  21. uid = '88888888'
  22. amount = userModel.amount
  23. data = {
  24. "txid": txid,
  25. "to": to,
  26. "uid": uid,
  27. "amount": amount
  28. }
  29. r = requests.post(baseUrl+path, headers=headers, data=json.dumps(data))
  30. return r.text
  31. # # Transfer
  32. # path = "accounts/test01/erc1155/safe_transfer_to"
  33. # txid = "202112229"
  34. # to = "0x72487C7A8bA487DFC3ed3Aa055ac5033138D8659"
  35. # uid = "88888888"
  36. # contract = "0xe0d9102c88b09369df99b1c126fb2eebc13804f8"
  37. # value = "1"
  38. #
  39. # data = {
  40. # "txid": txid,
  41. # "to": to,
  42. # "uid": uid,
  43. # "contract": contract,
  44. # "value": value
  45. # }
  46. #
  47. # r = requests.post(baseUrl+path, headers=headers, data=data)
  48. #
  49. # print(r.json())