PoggyBird/Assets/Web3Unity/Scripts/Prefabs/WebGL/WebGLGetNonce.cs
2023-02-28 19:02:09 +05:30

23 lines
674 B
C#

using Nethereum.Hex.HexTypes;
using Web3Unity.Scripts.Library.Ethers.Providers;
using Web3Unity.Scripts.Library.Ethers.Signers;
using Web3Unity.Scripts.Library.Ethers.Transactions;
using UnityEngine;
#if UNITY_WEBGL
public class WebGLGetNonce : MonoBehaviour
{
public async void GetNonce()
{
var provider = new JsonRpcProvider("YOUR_NODE");
var signer = new JsonRpcSigner(provider, 0);
var tx = await signer.SendTransaction(new TransactionRequest
{
To = await signer.GetAddress(),
Value = new HexBigInteger(100000)
});
var nonce = tx.Nonce;
Debug.Log("Nonce: " + nonce);
}
}
#endif