Пример #1
0
        /// <summary>
        /// Estimates the gas price based on current network congestion.
        /// </summary>
        /// <param name="promise"> Promise of the eventual gas price estimate. </param>
        /// <param name="gasPriceTarget"> The GasPriceTarget to aim for. </param>
        /// <returns> The time taken to retrieve the estimated gas limit. </returns>
        private static IEnumerator _EstimateGasPriceCoroutine(EthCallPromise <BigInteger> promise, GasPriceTarget gasPriceTarget)
        {
            var request = new EthGasPriceUnityRequest(EthereumNetworkManager.CurrentNetwork.NetworkUrl);

            yield return(request.SendRequest());

            promise.Build(request, () => ModifyGasPrice(gasPriceTarget, request.Result.Value));
        }
    public IEnumerator GasPrice()
    {
        EthGasPriceUnityRequest req = new EthGasPriceUnityRequest(m_endpoint);

        yield return(req.SendRequest());

        Debug.Log("gasprice " + GetEthValue(req.Result));
    }
Пример #3
0
        /// <summary>
        /// Estimates the gas price based on current network congestion.
        /// </summary>
        /// <param name="promise"> Promise of the eventual gas price estimate. </param>
        /// <param name="gasPriceTarget"> The GasPriceTarget to aim for. </param>
        /// <returns> The time taken to retrieve the estimated gas limit. </returns>
        private static IEnumerator _EstimateGasPriceCoroutine(EthCallPromise <BigInteger> promise, GasPriceTarget gasPriceTarget)
        {
            var request = new EthGasPriceUnityRequest(NetworkProvider.GetNetworkChainUrl());

            yield return(request.SendRequest());

            promise.Build(request, () => ModifyGasPrice(gasPriceTarget, request.Result.Value));
        }
Пример #4
0
        private static IEnumerator GetGasPriceCoroutine(UnityAction <decimal> callback)
        {
            var gasPriceRequest = new EthGasPriceUnityRequest(WalletSettings.current.networkUrl);

            yield return(gasPriceRequest.SendRequest());

            if (gasPriceRequest.Exception == null)
            {
                callback(UnitConversion.Convert.FromWei(gasPriceRequest.Result.Value, 9));
            }
            else
            {
                throw new System.InvalidOperationException("Gas price request failed, exception=" + gasPriceRequest.Exception);
            }
        }
Пример #5
0
    public static IEnumerator GetGasPrice(System.Action <decimal> callback)
    {
        var getGasPriceRequest = new EthGasPriceUnityRequest(_url);

        yield return(getGasPriceRequest.SendRequest());

        if (getGasPriceRequest.Exception == null)
        {
            var gasPrice = getGasPriceRequest.Result.Value;
            UnityEngine.Debug.Log("xxx gasprice" + gasPrice.ToString());
            callback(Nethereum.Util.UnitConversion.Convert.FromWei(gasPrice, 9));
        }
        else
        {
            UnityEngine.Debug.LogError("GetGasPrice exception " + getGasPriceRequest.Exception.Message);
            throw new System.InvalidOperationException("Get gasprice request failed");
        }
    }