public IEnumerator getPongEventRequest() { var getPongRequest = new EthGetLogsUnityRequest(_url); var getPongInput = pingTokenContractService.CreatePongInput(); Debug.Log("Checking pong event..."); yield return(getPongRequest.SendRequest(getPongInput)); if (getPongRequest.Exception == null) { Debug.Log("Pong Event: " + getPongRequest.Result); } else { Debug.Log("Error getting pong event: " + getPongRequest.Exception.Message); } }
public IEnumerator getTransferEventRequest() { var getTransferRequest = new EthGetLogsUnityRequest(_url); var getTransferInput = m_nexiumContract.CreateTransferInput(); Debug.Log("Checking transfer event..."); yield return(getTransferRequest.SendRequest(getTransferInput)); if (getTransferRequest.Exception == null) { Debug.Log("transfert Event: " + getTransferRequest.Result); } else { Debug.Log("Error getting transfer event: " + getTransferRequest.Exception.Message); } }
public IEnumerator getLogWithdrawEventRequest() { var getLogWithdrawRequest = new EthGetLogsUnityRequest(_url); var getLogWithdrawInput = transferContract.CreateLogWithdrawInput(); Debug.Log("Checking withdraw event..."); yield return(getLogWithdrawRequest.SendRequest(getLogWithdrawInput)); if (getLogWithdrawRequest.Exception == null) { Debug.Log("Withdraw Event: " + getLogWithdrawRequest.Result); } else { Debug.Log("Error getting withdraw event: " + getLogWithdrawRequest.Exception.Message); } }
public IEnumerator getEventRequest() { var getRequest = new EthGetLogsUnityRequest(_url); var getInput = m_nameContract.Create_Input_Event(); Debug.Log("Checking event..."); yield return(getRequest.SendRequest(getInput)); if (getRequest.Exception == null) { Debug.Log("Event: " + getRequest.Result); } else { Debug.Log("Error getting event: " + getRequest.Exception.Message); } }
public static IEnumerator Transaction(string url, string privateKey, string account, int value, string contractAddress, string targetAdress, bool toScene) { Debug.Log($"target : {targetAdress}"); var transactionTransferRequest = new TransactionSignedUnityRequest(url, privateKey); var newAddress = targetAdress; Debug.Log(value); var transactionMessage = new TransferFunction { FromAddress = account, To = newAddress, Value = value, }; yield return(transactionTransferRequest.SignAndSendTransaction(transactionMessage, contractAddress)); var transactionTransferHash = transactionTransferRequest.Result; Debug.Log(transactionTransferHash); var transactionReceiptPolling = new TransactionReceiptPollingRequest(url); yield return(transactionReceiptPolling.PollForReceipt(transactionTransferHash, 2)); var transferReceipt = transactionReceiptPolling.Result; var transferEvent = transferReceipt.DecodeAllEvents <TransferEventDto>(); Debug.Log("Transferd amount from event: " + transferEvent[0].Event.Value); var getLogsRequest = new EthGetLogsUnityRequest(url); var eventTransfer = TransferEventDto.GetEventABI(); yield return(getLogsRequest.SendRequest(eventTransfer.CreateFilterInput(contractAddress, account))); var eventDecoded = getLogsRequest.Result.DecodeAllEvents <TransferEventDto>(); Debug.Log("Transferd amount from get logs event: " + eventDecoded[0].Event.Value); if (toScene) { SceneManager.LoadScene("Start", LoadSceneMode.Single); } }
//Sample of new features / requests public IEnumerator DeployAndTransferToken() { var url = "http://localhost:8545"; var privateKey = "0xb5b1870957d373ef0eeffecc6e4812c0fd08f554b37b233526acc331bf1544f7"; var account = "0x12890d2cce102216644c59daE5baed380d84830c"; //initialising the transaction request sender var transactionRequest = new TransactionSignedUnityRequest(url, privateKey); var deployContract = new EIP20Deployment() { InitialAmount = 10000, FromAddress = account, TokenName = "TST", TokenSymbol = "TST" }; //deploy the contract and True indicates we want to estimate the gas yield return(transactionRequest.SignAndSendDeploymentContractTransaction <EIP20DeploymentBase>(deployContract)); if (transactionRequest.Exception != null) { Debug.Log(transactionRequest.Exception.Message); yield break; } var transactionHash = transactionRequest.Result; Debug.Log("Deployment 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)); var deploymentReceipt = transactionReceiptPolling.Result; Debug.Log("Deployment contract address:" + deploymentReceipt.ContractAddress); //Query request using our acccount and the contracts address (no parameters needed and default values) var queryRequest = new QueryUnityRequest <BalanceOfFunction, BalanceOfFunctionOutput>(url, account); yield return(queryRequest.Query(new BalanceOfFunction() { Owner = account }, deploymentReceipt.ContractAddress)); //Getting the dto response already decoded var dtoResult = queryRequest.Result; Debug.Log(dtoResult.Balance); var transactionTransferRequest = new TransactionSignedUnityRequest(url, privateKey); var newAddress = "0xde0B295669a9FD93d5F28D9Ec85E40f4cb697BAe"; var transactionMessage = new TransferFunction { FromAddress = account, To = newAddress, Value = 1000, }; yield return(transactionTransferRequest.SignAndSendTransaction(transactionMessage, deploymentReceipt.ContractAddress)); var transactionTransferHash = transactionTransferRequest.Result; Debug.Log("Transfer txn hash:" + transactionHash); transactionReceiptPolling = new TransactionReceiptPollingRequest(url); yield return(transactionReceiptPolling.PollForReceipt(transactionTransferHash, 2)); var transferReceipt = transactionReceiptPolling.Result; var transferEvent = transferReceipt.DecodeAllEvents <TransferEventDTO>(); Debug.Log("Transferd amount from event: " + transferEvent[0].Event.Value); var getLogsRequest = new EthGetLogsUnityRequest(url); var eventTransfer = TransferEventDTO.GetEventABI(); yield return(getLogsRequest.SendRequest(eventTransfer.CreateFilterInput(deploymentReceipt.ContractAddress, account))); var eventDecoded = getLogsRequest.Result.DecodeAllEvents <TransferEventDTO>(); Debug.Log("Transferd amount from get logs event: " + eventDecoded[0].Event.Value); }
//Sample of new features / requests public IEnumerator DeployAndTransferToken() { var url = "http://localhost:8545"; var privateKey = "0xa5ca770c997e53e182c5015bcf1b58ba5cefe358bf217800d8ec7d64ca919edd"; var account = "0x47E95DCdb798Bc315198138bC930758E6f399f81"; //initialising the transaction request sender var transactionRequest = new TransactionSignedUnityRequest(url, privateKey, account); var deployContract = new EIP20Deployment() { InitialAmount = 10000, FromAddress = account, TokenName = "TST", TokenSymbol = "TST" }; //deploy the contract and True indicates we want to estimate the gas yield return(transactionRequest.SignAndSendDeploymentContractTransaction <EIP20DeploymentBase>(deployContract)); if (transactionRequest.Exception != null) { Debug.Log(transactionRequest.Exception.Message); yield break; } var transactionHash = transactionRequest.Result; Debug.Log("Deployment 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)); var deploymentReceipt = transactionReceiptPolling.Result; Debug.Log("Deployment contract address:" + deploymentReceipt.ContractAddress); //Query request using our acccount and the contracts address (no parameters needed and default values) var queryRequest = new QueryUnityRequest <BalanceOfFunction, BalanceOfFunctionOutput>(url, account); yield return(queryRequest.Query(new BalanceOfFunction() { Owner = account }, deploymentReceipt.ContractAddress)); //Getting the dto response already decoded var dtoResult = queryRequest.Result; Debug.Log(dtoResult.Balance); var transactionTransferRequest = new TransactionSignedUnityRequest(url, privateKey, account); var newAddress = "0x4e70A9177Aff5077217f069E582992f7F9bec945"; var transactionMessage = new TransferFunction { FromAddress = account, To = newAddress, Value = 1000, }; yield return(transactionTransferRequest.SignAndSendTransaction(transactionMessage, deploymentReceipt.ContractAddress)); var transactionTransferHash = transactionTransferRequest.Result; Debug.Log("Transfer txn hash:" + transactionHash); transactionReceiptPolling = new TransactionReceiptPollingRequest(url); yield return(transactionReceiptPolling.PollForReceipt(transactionTransferHash, 2)); var transferReceipt = transactionReceiptPolling.Result; var transferEvent = transferReceipt.DecodeAllEvents <TransferEventDTO>(); Debug.Log("Transferd amount from event: " + transferEvent[0].Event.Value); var getLogsRequest = new EthGetLogsUnityRequest(url); var eventTransfer = TransferEventDTO.GetEventABI(); yield return(getLogsRequest.SendRequest(eventTransfer.CreateFilterInput(deploymentReceipt.ContractAddress, account))); var eventDecoded = getLogsRequest.Result.DecodeAllEvents <TransferEventDTO>(); Debug.Log("Transferd amount from get logs event: " + eventDecoded[0].Event.Value); }