CreateApprovalWebGL.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. using Web3Unity.Scripts.Library.ETHEREUEM.Connect;
  6. #if UNITY_WEBGL
  7. public class CreateApprovalWebGL : MonoBehaviour
  8. {
  9. // Start is called before the first frame update
  10. public string chain = "ethereum";
  11. public string network = "goerli";
  12. public string account;
  13. public string tokenType = "1155";
  14. private void Awake()
  15. {
  16. account = PlayerPrefs.GetString("Account");
  17. }
  18. public async void ApproveTransaction()
  19. {
  20. var response = await EVM.CreateApproveTransaction(chain, network, account, tokenType);
  21. Debug.Log("Response: " + response.connection.chain);
  22. try
  23. {
  24. string responseNft = await Web3GL.SendTransactionData(response.tx.to, "0", response.tx.gasPrice, response.tx.gasLimit, response.tx.data);
  25. if (responseNft == null)
  26. {
  27. Debug.Log("Empty Response Object:");
  28. }
  29. print(responseNft);
  30. Debug.Log(responseNft);
  31. }
  32. catch (Exception e)
  33. {
  34. Debug.LogException(e, this);
  35. }
  36. }
  37. }
  38. #endif