WebGLGetTxStatus.cs 732 B

1234567891011121314151617181920212223
  1. using Nethereum.Hex.HexTypes;
  2. using Web3Unity.Scripts.Library.Ethers.Providers;
  3. using Web3Unity.Scripts.Library.Ethers.Signers;
  4. using Web3Unity.Scripts.Library.Ethers.Transactions;
  5. using UnityEngine;
  6. #if UNITY_WEBGL
  7. public class WebGLGetTxStatus : MonoBehaviour
  8. {
  9. public async void GetTransactionStatus()
  10. {
  11. var provider = new JsonRpcProvider("YOUR_NODE");
  12. var signer = new JsonRpcSigner(provider, 0);
  13. var tx = await signer.SendTransaction(new TransactionRequest
  14. {
  15. To = await signer.GetAddress(),
  16. Value = new HexBigInteger(100000)
  17. });
  18. var txReceipt = await tx.Wait();
  19. Debug.Log("Transaction receipt: " + txReceipt.Confirmations);
  20. }
  21. }
  22. #endif