コード例 #1
0
ファイル: Coin.cs プロジェクト: skalenetwork/skale-demo
        public IEnumerator TransferTokens()
        {
            var transactionTransferRequest = new TransactionSignedUnityRequest(endpoint, privateKey);

            var transactionMessage = new ERC20.TransferFunction
            {
                Recipient = playerWallet,
                Amount    = UnitConversion.Convert.ToWei(1),
            };

            yield return(transactionTransferRequest.SignAndSendTransaction(transactionMessage, SKALE_ERC20));

            var transactionTransferHash = transactionTransferRequest.Result;

            Debug.Log(playerWallet);
            Debug.Log("Transfer txn hash:" + transactionTransferHash);
        }
コード例 #2
0
ファイル: Reset.cs プロジェクト: skalenetwork/skale-demo
        public IEnumerator TransferTokensBack()
        {
            //Query request using our acccount and the contracts address (no parameters needed and default values)
            var queryRequest = new QueryUnityRequest <ERC20.BalanceOfFunction, ERC20.BalanceOfOutputDTO>(endpoint, playerWallet);

            yield return(queryRequest.Query(new ERC20.BalanceOfFunction()
            {
                Account = playerWallet
            }, SKALE_ERC20));

            //Getting the dto response already decoded
            var dtoResult = queryRequest.Result.ReturnValue1;

            Debug.Log(dtoResult);

            var transactionApproveRequest = new TransactionSignedUnityRequest(endpoint, playerPrivateKey);

            var transactionApproveMessage = new ERC20.ApproveFunction
            {
                Spender = account,
                Amount  = UnitConversion.Convert.ToWei(1),
            };

            yield return(transactionApproveRequest.SignAndSendTransaction(transactionApproveMessage, SKALE_ERC20));

            var transactionApproveHash = transactionApproveRequest.Result;

            Debug.Log(playerWallet);
            Debug.Log("Approve txn hash:" + transactionApproveHash);

            var transactionTransferRequest = new TransactionSignedUnityRequest(endpoint, playerPrivateKey);

            var transactionMessage = new ERC20.TransferFunction
            {
                Recipient = account,
                Amount    = UnitConversion.Convert.ToWei(1),
            };

            yield return(transactionTransferRequest.SignAndSendTransaction(transactionMessage, SKALE_ERC20));

            var transactionTransferHash = transactionTransferRequest.Result;

            Debug.Log(playerWallet);
            Debug.Log("Transfer txn hash:" + transactionTransferHash);
        }