internal async Task <TransactionInfo> PostNewTransaction(byte[] data, double?price = null, bool overrideMaxGas = false) { var gasToRun = EstimateGasCost(data); if (!overrideMaxGas && gasToRun > MaxGasLimit) { throw new InvalidOperationException( $"Transaction requires too much gas ({gasToRun}, max {MaxGasLimit}). Run with {nameof(overrideMaxGas)} parameter set to true to force transaction to run."); } var gas = new HexBigInteger(GasLimit); var value = new HexBigInteger(0); var strData = data.ToHex(true); var input = new TransactionInput(strData, _account.Address, _account.Address, gas, value); if (price != null && price > 0) { input.GasPrice = new HexBigInteger(new BigInteger(price.Value)); } //var hash = await _web3.TransactionManager.SendTransactionAsync(input); var receipt = await _web3 .TransactionManager .TransactionReceiptService .SendRequestAndWaitForReceiptAsync(input); //if (!await AwaitTransactionMined(receipt.TransactionHash, timeout, data)) // throw new TimeoutException("Transaction not mined in timeout"); var cost = new EthCostInfo((double)receipt.GasUsed.Value, (double)input.GasPrice.Value); var info = new TransactionInfo(receipt.TransactionHash, cost, receipt.Status.Value == 1); LastGasPrice = (double)input.GasPrice.Value; return(info); }
public override CostInfo GetEstimatedCommitCostAsync() { DataSet.AcceptChanges(); var bytes = DataSetConverter.ToBytes(DataSet); var gas = EthereumConnection.EstimateGasCost(bytes); var cost = new EthCostInfo(gas, GasPrice); return(cost); }