/// <summary> /// Gets the ether balance of a certain wallet. /// </summary> /// <param name="promise"> Promise of an eventual eth balance returned. </param> /// <param name="address"> The address to check the ether balance for. </param> /// <returns> The time waited for the request to complete. </returns> private static IEnumerator _AddressEthBalanceCoroutine(EthCallPromise <dynamic> promise, string address) { var request = new EthGetBalanceUnityRequest(EthereumNetworkManager.CurrentNetwork.NetworkUrl); yield return(request.SendRequest(address, BlockParameter.CreateLatest())); promise.Build(request, () => SolidityUtils.ConvertFromUInt(request.Result.Value, 18)); }
/// <summary> /// Sends ether from one address to another. /// </summary> /// <param name="signedUnityRequest"> The signed request to send the ether with. </param> /// <param name="walletAddress"> The address of the wallet sending the ether. </param> /// <param name="gasLimit"> The gas limit of the ether send transaction. </param> /// <param name="gasPrice"> The gas price of the ether send transaction. </param> /// <param name="addressTo"> The address to send the ether to. </param> /// <param name="amount"> The amount to send in ether. </param> /// <returns> The time waited for the request to be broadcast to the network. </returns> private static IEnumerator _SendEtherCoroutine( TransactionSignedUnityRequest signedUnityRequest, HexBigInteger gasLimit, HexBigInteger gasPrice, string walletAddress, string addressTo, dynamic amount) { var promise = new EthTransactionPromise(EthereumPendingTransactionManager, walletAddress, "Sending ETH"); var transactionInput = new TransactionInput("", addressTo, walletAddress, gasLimit, gasPrice, new HexBigInteger(SolidityUtils.ConvertToUInt(amount, 18))); yield return(signedUnityRequest.SignAndSendTransaction(transactionInput)); promise.Build(signedUnityRequest, () => signedUnityRequest.Result, () => EthereumNetworkManager.CurrentNetwork.NetworkUrl); }