public async void ShouldReturnBalanceBiggerThanZeroForCurrentBlock() { var blockNumber = await(new EthBlockNumber(Client)).SendRequestAsync(); var ethGetBalance = new EthGetBalance(Client); var result = await ethGetBalance.SendRequestAsync(Settings.GetDefaultAccount(), new BlockParameter(blockNumber)); //Default account has balance Assert.True(result.Value > 0); }
public async Task <decimal> CalculateTotalAmountToTransferWholeBalanceInEther(string address, decimal gasPriceGwei, BigInteger?gas = null) { var ethGetBalance = new EthGetBalance(_transactionManager.Client); var currentBalance = await ethGetBalance.SendRequestAsync(address); var gasPrice = UnitConversion.Convert.ToWei(gasPriceGwei, UnitConversion.EthUnit.Gwei); var gasAmount = gas ?? _transactionManager.DefaultGas; var totalAmount = currentBalance.Value - (gasAmount * gasPrice); return(UnitConversion.Convert.FromWei(totalAmount)); }
public async Task <decimal> CalculateTotalAmountToTransferWholeBalanceInEtherAsync(string address, BigInteger maxFeePerGas, BigInteger?gas = null) { var ethGetBalance = new EthGetBalance(_transactionManager.Client); var currentBalance = await ethGetBalance.SendRequestAsync(address).ConfigureAwait(false); var gasAmount = gas ?? _transactionManager.DefaultGas; var totalAmount = currentBalance.Value - (gasAmount * maxFeePerGas); if (totalAmount <= 0) { throw new Exception("Insufficient balance to make a transfer"); } return(UnitConversion.Convert.FromWei(totalAmount)); }
public override async Task <HexBigInteger> ExecuteAsync(IClient client) { var ethGetBalance = new EthGetBalance(client); return(await ethGetBalance.SendRequestAsync(Settings.GetDefaultAccount())); }
/// <summary> /// Gets the ether balance of an address. /// </summary> /// <param name="address"> The address to check for the ether balance. </param> /// <returns> Task which returns the decimal ether balance of the address. </returns> public static async Task <decimal> GetEtherBalance(string address) { EthGetBalance ethGetBalance = new EthGetBalance(NetworkProvider.GetWeb3().Client); return(SolidityUtils.ConvertFromUInt((await ethGetBalance.SendRequestAsync(address)).Value, 18)); }
public async Task <object> ExecuteTestAsync(IClient client) { var ethGetBalance = new EthGetBalance(client); return(await ethGetBalance.SendRequestAsync("0x12890d2cce102216644c59dae5baed380d84830c")); }
public async Task<dynamic> ExecuteTestAsync(RpcClient client) { var ethGetBalance = new EthGetBalance(client); return await ethGetBalance.SendRequestAsync( "0x12890d2cce102216644c59dae5baed380d84830c"); }