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