public async Task <HexBigInteger> GetNextNonceAsync()
        {
            if (Client == null)
            {
                throw new NullReferenceException("Client not configured");
            }
            var ethGetTransactionCount = new EthGetTransactionCount(Client);
            await _semaphoreSlim.WaitAsync().ConfigureAwait(false);

            try
            {
                var nonce = await ethGetTransactionCount.SendRequestAsync(_account, BlockParameter.CreatePending())
                            .ConfigureAwait(false);

                if (nonce.Value <= CurrentNonce)
                {
                    CurrentNonce = CurrentNonce + 1;
                    nonce        = new HexBigInteger(CurrentNonce);
                }
                else
                {
                    CurrentNonce = nonce.Value;
                }
                return(nonce);
            }
            finally
            {
                _semaphoreSlim.Release();
            }
        }
        public async Task <HexBigInteger> GetNonceAsync(TransactionInput transaction)
        {
            if (Client == null)
            {
                throw new NullReferenceException("Client not configured");
            }
            if (transaction == null)
            {
                throw new ArgumentNullException(nameof(transaction));
            }
            var ethGetTransactionCount = new EthGetTransactionCount(Client);
            var nonce = transaction.Nonce;

            if (nonce == null)
            {
                //we are doing a check all the time on current nonce, we could just cache an increment but we might get out of sync.
                nonce = await ethGetTransactionCount.SendRequestAsync(_account).ConfigureAwait(false);

                if (nonce.Value <= _nonceCount)
                {
                    _nonceCount = _nonceCount + 1;
                    nonce       = new HexBigInteger(_nonceCount);
                }
                else
                {
                    _nonceCount = nonce.Value;
                }
            }
            return(nonce);
        }
 public EthApiTransactionsService(IClient client) : base(client)
 {
     Call        = new EthCall(client);
     EstimateGas = new EthEstimateGas(client);
     GetTransactionByBlockHashAndIndex   = new EthGetTransactionByBlockHashAndIndex(client);
     GetTransactionByBlockNumberAndIndex = new EthGetTransactionByBlockNumberAndIndex(client);
     GetTransactionByHash  = new EthGetTransactionByHash(client);
     GetTransactionCount   = new EthGetTransactionCount(client);
     GetTransactionReceipt = new EthGetTransactionReceipt(client);
     SendRawTransaction    = new EthSendRawTransaction(client);
     SendTransaction       = new EthSendTransaction(client);
 }
 public EthTransactionsService(IClient client) : base(client)
 {
     Call = new EthCall(client);
     EstimateGas = new EthEstimateGas(client);
     GetTransactionByBlockHashAndIndex = new EthGetTransactionByBlockHashAndIndex(client);
     GetTransactionByBlockNumberAndIndex = new EthGetTransactionByBlockNumberAndIndex(client);
     GetTransactionByHash = new EthGetTransactionByHash(client);
     GetTransactionCount = new EthGetTransactionCount(client);
     GetTransactionReceipt = new EthGetTransactionReceipt(client);
     SendRawTransaction = new EthSendRawTransaction(client);
     SendTransaction = new EthSendTransaction(client);
 }
Beispiel #5
0
        public override async Task <HexBigInteger> ExecuteAsync(IClient client)
        {
            var ethGetTransactionCount = new EthGetTransactionCount(client);

            return(await ethGetTransactionCount.SendRequestAsync(Settings.GetDefaultAccount()));
        }
Beispiel #6
0
        public async Task <object> ExecuteTestAsync(IClient client)
        {
            var ethGetTransactionCount = new EthGetTransactionCount(client);

            return(await ethGetTransactionCount.SendRequestAsync("0x12890d2cce102216644c59dae5baed380d84830c"));
        }
 public async Task<dynamic> ExecuteTestAsync(RpcClient client)
 {
     var ethGetTransactionCount = new EthGetTransactionCount(client);
     return await ethGetTransactionCount.SendRequestAsync( "0x12890d2cce102216644c59dae5baed380d84830c");
 }
Beispiel #8
0
 public NonceCalculator(Web3 web3)
 {
     _getTransactionCount = new EthGetTransactionCount(web3.Client);
     _client = web3.Client;
 }