WebGLSendTransactionExample.cs 847 B

12345678910111213141516171819202122232425262728293031
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. #if UNITY_WEBGL
  6. public class WebGLSendTransactionExample : MonoBehaviour
  7. {
  8. async public void OnSendTransaction()
  9. {
  10. // account to send to
  11. string to = "0x428066dd8A212104Bc9240dCe3cdeA3D3A0f7979";
  12. // amount in wei to send
  13. string value = "12300000000000000";
  14. // gas limit OPTIONAL
  15. string gasLimit = "";
  16. // gas price OPTIONAL
  17. string gasPrice = "";
  18. // connects to user's browser wallet (metamask) to send a transaction
  19. try
  20. {
  21. string response = await Web3GL.SendTransaction(to, value, gasLimit, gasPrice);
  22. Debug.Log(response);
  23. }
  24. catch (Exception e)
  25. {
  26. Debug.LogException(e, this);
  27. }
  28. }
  29. }
  30. #endif