/// <summary> /// Estimates the gas limit of sending ether from one address to another. /// </summary> /// <param name="addressTo"> The address the ether is being sent to. </param> /// <param name="value"> The amount of ether being sent (in wei). </param> /// <returns> Task which returns the gas limit of sending ether. </returns> public static async Task <BigInteger> EstimateEthGasLimit(string addressTo, BigInteger value) { CallInput callInput = new CallInput("", addressTo, new HexBigInteger(value)); EthEstimateGas estimateGasLimit = new EthEstimateGas(NetworkProvider.GetWeb3().Client); return(await estimateGasLimit.SendRequestAsync(callInput)); }
protected async Task <HexBigInteger> EstimateGasFromEncAsync(string encodedFunctionCall) { return (await EthEstimateGas.SendRequestAsync(new CallInput(encodedFunctionCall, ContractAddress)) .ConfigureAwait(false)); }
/// <summary> /// Estimates the gas limit of calling a function of an ethereum contract. /// </summary> /// <typeparam name="TFunc"> The type of the function to call. </typeparam> /// <param name="function"> The concrete FunctionMessage to call. </param> /// <param name="contractAddress"> The contract address which will be used to call the function. </param> /// <param name="callerAddress"> The address calling the contract function. </param> /// <returns> Task which returns the gas limit of calling a function of an ethereum contract. </returns> public static async Task <BigInteger> EstimateContractGasLimit <TFunc>( TFunc function, string contractAddress, string callerAddress) where TFunc : FunctionMessage, new() { function.SetDefaultFromAddressIfNotSet(callerAddress); EthEstimateGas estimateGasLimit = new EthEstimateGas(NetworkProvider.GetWeb3().Client); return(((await estimateGasLimit.SendRequestAsync(function.CreateCallInput(contractAddress))).Value * 100) / 90); }
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); }
protected FunctionBase(IClient rpcClient, Contract contract, FunctionABI functionABI) { FunctionABI = functionABI; this.rpcClient = rpcClient; this.contract = contract; ethCall = new EthCall(rpcClient); ethSendTransaction = new EthSendTransaction(rpcClient); ethEstimateGas = new EthEstimateGas(rpcClient); FunctionCallDecoder = new FunctionCallDecoder(); FunctionCallEncoder = new FunctionCallEncoder(); }
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); }
public async Task<dynamic> ExecuteTestAsync(RpcClient client) { var ethEstimateGas = new EthEstimateGas(client); var contractByteCode = "0xc6888fa10000000000000000000000000000000000000000000000000000000000000045"; var to = "0x32eb97b8ad202b072fd9066c03878892426320ed"; var transactionInput = new CallInput(); transactionInput.Data = contractByteCode; transactionInput.To = to; transactionInput.From = "0x12890d2cce102216644c59dae5baed380d84830c"; return await ethEstimateGas.SendRequestAsync(transactionInput); }
public async Task <dynamic> ExecuteTestAsync(RpcClient client) { var ethEstimateGas = new EthEstimateGas(client); var contractByteCode = "0xc6888fa10000000000000000000000000000000000000000000000000000000000000045"; var to = "0x32eb97b8ad202b072fd9066c03878892426320ed"; var transactionInput = new CallInput(); transactionInput.Data = contractByteCode; transactionInput.To = to; transactionInput.From = "0x12890d2cce102216644c59dae5baed380d84830c"; return(await ethEstimateGas.SendRequestAsync(transactionInput)); }
public virtual Task <HexBigInteger> EstimateGasAsync(CallInput callInput) { if (Client == null) { throw new NullReferenceException("Client not configured"); } if (callInput == null) { throw new ArgumentNullException(nameof(callInput)); } var ethEstimateGas = new EthEstimateGas(Client); return(ethEstimateGas.SendRequestAsync(callInput)); }
public override async Task <HexBigInteger> ExecuteAsync(IClient client) { var ethEstimateGas = new EthEstimateGas(client); var contractByteCode = "0xc6888fa10000000000000000000000000000000000000000000000000000000000000045"; var to = "0x32eb97b8ad202b072fd9066c03878892426320ed"; var transactionInput = new CallInput(); transactionInput.Data = contractByteCode; transactionInput.To = to; transactionInput.From = Settings.GetDefaultAccount(); return(await ethEstimateGas.SendRequestAsync(transactionInput)); }
public LykkeSignedTransactionManager( IBaseSettings baseSettings, INonceCalculator nonceCalculator, ILykkeSigningAPI signingApi, ITransactionRouter transactionRouter, Web3 web3, IGasPriceRepository gasPriceRepository) { _baseSettings = baseSettings; _estimateGas = new EthEstimateGas(web3.Client); _nonceCalculator = nonceCalculator; _semaphores = new ConcurrentDictionary <string, SemaphoreSlim>(); _sendRawTransaction = new EthSendRawTransaction(web3.Client); _signingApi = signingApi; _transactionRouter = transactionRouter; _web3 = web3; _gasPriceRepository = gasPriceRepository; Client = web3.Client; }
protected async Task <HexBigInteger> EstimateGasFromEncAsync(string encodedFunctionCall, CallInput callInput ) { callInput.Data = encodedFunctionCall; return(await EthEstimateGas.SendRequestAsync(callInput).ConfigureAwait(false)); }