Web3WalletGetNonce.cs 656 B

123456789101112131415161718192021
  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. public class Web3WalletGetNonce : MonoBehaviour
  7. {
  8. public async void GetNonce()
  9. {
  10. var provider = new JsonRpcProvider("YOUR_NODE");
  11. var signer = new JsonRpcSigner(provider, 0);
  12. var tx = await signer.SendTransaction(new TransactionRequest
  13. {
  14. To = await signer.GetAddress(),
  15. Value = new HexBigInteger(100000)
  16. });
  17. var nonce = tx.Nonce;
  18. Debug.Log("Nonce: " + nonce);
  19. }
  20. }