WebGLGetNonce.cs 674 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 WebGLGetNonce : MonoBehaviour
  8. {
  9. public async void GetNonce()
  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 nonce = tx.Nonce;
  19. Debug.Log("Nonce: " + nonce);
  20. }
  21. }
  22. #endif