public IEnumerator MakePayment( string server, string fromPrivateKey, string fromPublicAddress, string toPublicAddress, decimal sendAmount, int gas ) { var ethTransfer = new EthTransferUnityRequest(server, fromPrivateKey, fromPublicAddress); yield return(ethTransfer.TransferEther(toPublicAddress, sendAmount, gas)); if (ethTransfer.Exception != null) { Debug.Log(ethTransfer.Exception.Message); yield break; } var transactionHash = ethTransfer.Result; Debug.Log("Transfer transaction hash:" + transactionHash); // create a poll to get the receipt when mined var transactionReceiptPolling = new TransactionReceiptPollingRequest(server); // checking every 2 seconds for the receipt yield return(transactionReceiptPolling.PollForReceipt(transactionHash, 2)); Debug.Log("Transaction mined"); var balanceRequest = new EthGetBalanceUnityRequest(server); yield return(balanceRequest.SendRequest(toPublicAddress, BlockParameter.CreateLatest())); Debug.Log("Balance of account:" + UnitConversion.Convert.FromWei(balanceRequest.Result.Value)); }
public IEnumerator TransferEther(string url, string privateKey, string addressTo, string amountText) { var amount = System.Decimal.Parse(amountText); var ethTransfer = new EthTransferUnityRequest(url, privateKey); var receivingAddress = addressTo; var gasPriceGwei = 2; yield return(ethTransfer.TransferEther(receivingAddress, amount, gasPriceGwei)); if (ethTransfer.Exception != null) { Debug.Log(ethTransfer.Exception.Message); yield break; } var transactionHash = ethTransfer.Result; Debug.Log("Transfer transaction hash:" + transactionHash); //create a poll to get the receipt when mined var transactionReceiptPolling = new TransactionReceiptPollingRequest(url); //checking every 2 seconds for the receipt yield return(transactionReceiptPolling.PollForReceipt(transactionHash, 2)); Debug.Log("Transaction mined"); var balanceRequest = new EthGetBalanceUnityRequest(url); yield return(balanceRequest.SendRequest(receivingAddress, BlockParameter.CreateLatest())); var balanceAddressTo = UnitConversion.Convert.FromWei(balanceRequest.Result.Value); Debug.Log("Balance of account:" + balanceAddressTo); }
//Sample of new features / requests public IEnumerator TransferEther(decimal Amount, string AddressTo) { //Url = InputUrl.text; //PrivateKey = InputPrivateKey.text; //AddressTo = InputAddressTo.text; //Amount = System.Decimal.Parse(InputAmount.text); //initialising the transaction request sender var ethTransfer = new EthTransferUnityRequest(Url, PrivateKey); var receivingAddress = AddressTo; yield return(ethTransfer.TransferEther(receivingAddress, Amount, GasPriceGwei)); if (ethTransfer.Exception != null) { Debug.Log(ethTransfer.Exception.Message); yield break; } TransactionHash = ethTransfer.Result; //ResultTxnHash.text = TransactionHash; Debug.Log("Transfer transaction hash:" + TransactionHash); //create a poll to get the receipt when mined var transactionReceiptPolling = new TransactionReceiptPollingRequest(Url); //checking every 2 seconds for the receipt yield return(transactionReceiptPolling.PollForReceipt(TransactionHash, 2)); Debug.Log("Transaction mined"); var balanceRequest = new EthGetBalanceUnityRequest(Url); yield return(balanceRequest.SendRequest(receivingAddress, BlockParameter.CreateLatest())); BalanceAddressTo = UnitConversion.Convert.FromWei(balanceRequest.Result.Value); //ResultBalanceAddressTo.text = BalanceAddressTo.ToString(); Debug.Log("Balance of account:" + BalanceAddressTo); }
//Sample of new features / requests public IEnumerator TransferEther() { var url = "http://localhost:8545"; var privateKey = "0xb5b1870957d373ef0eeffecc6e4812c0fd08f554b37b233526acc331bf1544f7"; var account = "0x12890d2cce102216644c59daE5baed380d84830c"; //initialising the transaction request sender var ethTransfer = new EthTransferUnityRequest(url, privateKey, account); var receivingAddress = "0xde0B295669a9FD93d5F28D9Ec85E40f4cb697BAe"; yield return(ethTransfer.TransferEther("0xde0B295669a9FD93d5F28D9Ec85E40f4cb697BAe", 1.1m, 2)); if (ethTransfer.Exception != null) { Debug.Log(ethTransfer.Exception.Message); yield break; } var transactionHash = ethTransfer.Result; Debug.Log("Transfer transaction hash:" + transactionHash); //create a poll to get the receipt when mined var transactionReceiptPolling = new TransactionReceiptPollingRequest(url); //checking every 2 seconds for the receipt yield return(transactionReceiptPolling.PollForReceipt(transactionHash, 2)); Debug.Log("Transaction mined"); var balanceRequest = new EthGetBalanceUnityRequest(url); yield return(balanceRequest.SendRequest(receivingAddress, BlockParameter.CreateLatest())); Debug.Log("Balance of account:" + UnitConversion.Convert.FromWei(balanceRequest.Result.Value)); }
//Sample of new features / requests public IEnumerator TransferEther() { var url = "http://localhost:8545"; var privateKey = "0xa5ca770c997e53e182c5015bcf1b58ba5cefe358bf217800d8ec7d64ca919edd"; var account = "0x47E95DCdb798Bc315198138bC930758E6f399f81"; //initialising the transaction request sender var ethTransfer = new EthTransferUnityRequest(url, privateKey, account); var receivingAddress = "0x09f8F8c219D94A5db8Ee466dC072748603A7A0D9"; yield return(ethTransfer.TransferEther("0x09f8F8c219D94A5db8Ee466dC072748603A7A0D9", 1.1m, 2)); if (ethTransfer.Exception != null) { Debug.Log(ethTransfer.Exception.Message); yield break; } var transactionHash = ethTransfer.Result; Debug.Log("Transfer transaction hash:" + transactionHash); //create a poll to get the receipt when mined var transactionReceiptPolling = new TransactionReceiptPollingRequest(url); //checking every 2 seconds for the receipt yield return(transactionReceiptPolling.PollForReceipt(transactionHash, 2)); Debug.Log("Transaction mined"); var balanceRequest = new EthGetBalanceUnityRequest(url); yield return(balanceRequest.SendRequest(receivingAddress, BlockParameter.CreateLatest())); Debug.Log("Balance of account:" + UnitConversion.Convert.FromWei(balanceRequest.Result.Value)); }