public async Task PrivateWalletServiceTest_TestTransactionEstimation() { string fromAddress = "0x46Ea3e8d85A06cBBd8c6a491a09409f5B59BEa28"; EthTransaction transaction = new EthTransaction() { FromAddress = fromAddress, GasAmount = 21000, GasPrice = 50000000000, ToAddress = "0xaA4981d084120AEf4BbaEeCB9abdBc7D180C7EdB",//"0xaA4981d084120AEf4BbaEeCB9abdBc7D180C7EdB", Value = 5000000000 }; string trRaw = await _privateWallet.GetTransactionForSigning(transaction); string signedRawTr = SignRawTransaction(trRaw, _privateKey); OperationEstimationResult result = await _privateWallet.EstimateTransactionExecutionCost(fromAddress, signedRawTr); }
public async Task <IActionResult> EstimateCashoutGas([FromBody] TransferModel model) { if (!ModelState.IsValid) { throw new ClientSideException(ExceptionType.WrongParams, JsonConvert.SerializeObject(ModelState.Errors())); } BigInteger amount = BigInteger.Parse(model.Amount); OperationEstimationResult cashoutEstimationResult = await _exchangeContractService.EstimateCashoutGas(model.Id, model.CoinAdapterAddress, _addressUtil.ConvertToChecksumAddress(model.FromAddress), _addressUtil.ConvertToChecksumAddress(model.ToAddress), amount, model.Sign); await _logger.WriteInfoAsync("ExchangeController", "EstimateCashoutGas", model.ToJson(), $"Estimated amount:{cashoutEstimationResult.GasAmount}", DateTime.UtcNow); return(Ok(new EstimatedGasModel { EstimatedGas = cashoutEstimationResult.GasAmount.ToString(), IsAllowed = cashoutEstimationResult.IsAllowed })); }