CreateApprovalWebWallet.cs 1.2 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. using Web3Unity.Scripts.Library.Web3Wallet;
  7. public class CreateApprovalWebWallet : 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. string chainID = "5";
  15. private void Awake()
  16. {
  17. account = PlayerPrefs.GetString("Account");
  18. }
  19. public async void ApproveTransaction()
  20. {
  21. var response = await EVM.CreateApproveTransaction(chain, network, account, tokenType);
  22. Debug.Log("Response: " + response.connection.chain);
  23. try
  24. {
  25. string responseNft = await Web3Wallet.SendTransaction(chainID, response.tx.to, "0",
  26. response.tx.data, response.tx.gasLimit, response.tx.gasPrice);
  27. if (responseNft == null)
  28. {
  29. Debug.Log("Empty Response Object:");
  30. }
  31. print(responseNft);
  32. Debug.Log(responseNft);
  33. }
  34. catch (Exception e)
  35. {
  36. Debug.LogException(e, this);
  37. }
  38. }
  39. }