public async Task <HexBigInteger> EstimateGasAsync(string contractAddress, TFunctionMessage functionMessage = null) { if (functionMessage == null) { functionMessage = new TFunctionMessage(); } SetEncoderContractAddress(contractAddress); var callInput = FunctionMessageEncodingService.CreateCallInput(functionMessage); try { if (TransactionManager.EstimateOrSetDefaultGasIfNotSet) { return(await TransactionManager.EstimateGasAsync(callInput).ConfigureAwait(false)); } return(null); } catch (RpcResponseException rpcException) { ContractRevertExceptionHandler.HandleContractRevertException(rpcException); throw; } catch (Exception) { var ethCall = new EthCall(TransactionManager.Client); var result = await ethCall.SendRequestAsync(callInput).ConfigureAwait(false); new FunctionCallDecoder().ThrowIfErrorOnOutput(result); throw; } }
public async Task <string> SendRequestAsync(string transactionHash) { var transaction = await _apiTransactionsService.GetTransactionByHash.SendRequestAsync(transactionHash); var transactionInput = transaction.ConvertToTransactionInput(); var functionCallDecoder = new FunctionCallDecoder(); if (transactionInput.MaxFeePerGas != null) { transactionInput.GasPrice = null; } try { var errorHex = await _apiTransactionsService.Call.SendRequestAsync(transactionInput, new BlockParameter(transaction.BlockNumber)); if (ErrorFunction.IsErrorData(errorHex)) { return(functionCallDecoder.DecodeFunctionErrorMessage(errorHex)); } return(string.Empty); } catch (RpcResponseException rpcException) { ContractRevertExceptionHandler.HandleContractRevertException(rpcException); throw; } }