public static async Task <MaticTransactionOptions> GetTransactionEstimate(ProcessExitsModel processExitsModel, MaticTransactionOptions options, Function function)
        {
            try
            {
                //Get the Account and set up the sender's Address
                Account account = GetAccount(options.SenderPrivateKey, options.ChainId);

                //Get the Gas Limit
                HexBigInteger gasLimit = await function.EstimateGasAsync(account.Address, null, null, processExitsModel.RootTokenAddress);

                //Get the Gas Price Estimate
                GasPriceEstimator gasPriceEstimator = new GasPriceEstimator();
                GasPriceEstimate  gasPriceEstimate  = await gasPriceEstimator.GetRecommendedGasPriceFromNetwork();

                //Fill the options
                options.GasPrice = (decimal)gasPriceEstimate.AverageGwei;
                options.GasLimit = gasLimit;
                options.From     = account.Address;

                return(options);
            }catch (Exception ex)
            {
                throw new Exception("Could not fetch the transaction estimate because " + ex.Message);
            }
        }
Example #2
0
        /// <summary>
        /// Process Exits
        /// </summary>
        /// <param name="rootTokenAddress"></param>
        /// <param name="options"></param>
        /// <returns></returns>
        public async Task <string> ProcessExits(string rootTokenAddress, MaticTransactionOptions options)
        {
            ProcessExitsModel processExitsModel = new ProcessExitsModel()
            {
                RootTokenAddress = rootTokenAddress
            };
            string response = await maticWithrawalManagerContract.ProcessExits(processExitsModel, options);

            return(response);
        }
Example #3
0
        /// <summary>

        /// </summary>
        /// <param name="rootTokenAddress"></param>11
        /// <param name="options"></param>
        /// <returns></returns>
        public async Task <string> ProcessExits(ProcessExitsModel processExitsModel, MaticTransactionOptions options)
        {
            //Get the Contract instance by Creating a Web3 client from the Sender's Private Key
            Web3     web3Client       = Web3ClientHelper.GetWeb3Client(ProviderUrl, options.SenderPrivateKey);
            Contract contractInstance = web3Client.Eth.GetContract(ABI, ContractAddress);
            Function function         = contractInstance.GetFunction("processExits");

            options = await TransactionEstimateHelper.GetTransactionEstimate(processExitsModel, options, function);

            string response = await function.SendTransactionAsync(options.From, options.GasLimit, options.GasPrice, null, processExitsModel.RootTokenAddress);

            return(response);
        }