protected async Task <HexBigInteger> EstimateGasFromEncAsync(string encodedFunctionCall)
 {
     return
         (await
          ethEstimateGas.SendRequestAsync(new CallInput(encodedFunctionCall, ContractAddress))
          .ConfigureAwait(false));
 }
Beispiel #2
0
        /// <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));
        }
Beispiel #3
0
        /// <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 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);
 }
Beispiel #5
0
        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));
        }
Beispiel #6
0
        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));
        }
Beispiel #7
0
        public async Task <HexBigInteger> EstimateGasAsync <T>(T callInput) where T : CallInput
        {
            if (Client == null)
            {
                throw new NullReferenceException("Client not configured");
            }

            if (callInput == null)
            {
                throw new ArgumentNullException(nameof(callInput));
            }

            return(await _estimateGas.SendRequestAsync(callInput));
        }
Beispiel #8
0
        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));
        }
Beispiel #9
0
        public async Task <HexBigInteger> EstimateGasAsync <T>(T callInput) where T : CallInput
        {
            if (Client == null)
            {
                throw new NullReferenceException("Client not configured");
            }

            if (callInput == null)
            {
                throw new ArgumentNullException(nameof(callInput));
            }

            var(gasPrice, gasValue) = await GetGasPriceAndValueAsync(callInput.GasPrice ?? BigInteger.Zero, callInput.Gas ?? BigInteger.Zero);

            callInput.Gas      = new HexBigInteger(gasValue.Value);
            callInput.GasPrice = new HexBigInteger(gasPrice.Value);

            return(await _estimateGas.SendRequestAsync(callInput));
        }
Beispiel #10
0
 protected async Task <HexBigInteger> EstimateGasFromEncAsync(string encodedFunctionCall, CallInput callInput
                                                              )
 {
     callInput.Data = encodedFunctionCall;
     return(await EthEstimateGas.SendRequestAsync(callInput).ConfigureAwait(false));
 }