Example #1
0
        public static Transaction GetFreezeAssetTransaction(Address sender, Address toFreeze, long?assetId, bool freezeState,
                                                            TransactionParametersResponse trans, string message = "")
        {
            var tx = Transaction.CreateAssetFreezeTransaction(sender, toFreeze, freezeState, 1, (ulong?)trans.LastRound,
                                                              (ulong?)trans.LastRound + 1000, Encoding.UTF8.GetBytes(message), new Digest(trans.GenesisHash), (ulong?)assetId);

            Account.SetFeeByFeePerByte(tx, (ulong?)trans.Fee);
            return(tx);
        }
Example #2
0
        public static Transaction GetRevokeAssetTransaction(Address reserve, Address revokedFrom, Address receiver, long?assetId,
                                                            ulong amount, TransactionParametersResponse trans, string message = "")
        {
            var tx = Transaction.CreateAssetRevokeTransaction(reserve, revokedFrom, receiver, amount, 1, (ulong?)trans.LastRound,
                                                              (ulong?)trans.LastRound + 1000, Encoding.UTF8.GetBytes(message), trans.GenesisId,
                                                              new Digest(trans.GenesisHash), (ulong?)assetId);

            Account.SetFeeByFeePerByte(tx, (ulong?)trans.Fee);
            return(tx);
        }
Example #3
0
        public static Transaction GetTransferAssetTransaction(Address from, Address to, long?assetId, ulong amount,
                                                              TransactionParametersResponse trans, Address closeTo = null, string message = "")
        {
            var tx = Transaction.CreateAssetTransferTransaction(from, to, closeTo, amount, 1,
                                                                (ulong?)trans.LastRound, (ulong?)trans.LastRound + 1000, Encoding.UTF8.GetBytes(message), trans.GenesisId,
                                                                new Digest(trans.GenesisHash), (ulong?)assetId);

            Account.SetFeeByFeePerByte(tx, (ulong?)trans.Fee);
            return(tx);
        }
Example #4
0
 /// <summary>
 /// Get a payment transaction
 /// </summary>
 /// <param name="from">from address</param>
 /// <param name="to">to address</param>
 /// <param name="amount">amount(Unit:MicroAlgo)</param>
 /// <param name="message">message</param>
 /// <param name="trans">Transaction Params(use AlgodApi.TransactionParams() function to get the params)</param>
 /// <returns>payment transaction</returns>
 public static Transaction GetPaymentTransaction(Address from, Address to, ulong?amount, string message,
                                                 TransactionParametersResponse trans)
 {
     if (trans is null)
     {
         throw new Exception("The Transaction Params can not be null!");
     }
     return(GetPaymentTransactionWithInfo(from, to, amount, message,
                                          (ulong?)trans.Fee, (ulong?)trans.LastRound, trans.GenesisId, Convert.ToBase64String(trans.GenesisHash)));
 }
Example #5
0
        public static Transaction GetDestroyAssetTransaction(Address manager, long?assetId, TransactionParametersResponse trans, string message = "")
        {
            var tx = Transaction.CreateAssetDestroyTransaction(manager, 1, (ulong?)trans.LastRound, (ulong?)trans.LastRound + 1000,
                                                               Encoding.UTF8.GetBytes(message), new Digest(trans.GenesisHash), (ulong?)assetId);

            Account.SetFeeByFeePerByte(tx, (ulong?)trans.Fee);
            return(tx);
        }
Example #6
0
        public static Transaction GetAssetOptingInTransaction(Address sender, long?assetID, TransactionParametersResponse trans, string message = "")
        {
            var tx = Transaction.CreateAssetAcceptTransaction(sender, 1, (ulong?)trans.LastRound,
                                                              (ulong?)trans.LastRound + 1000, Encoding.UTF8.GetBytes(message), trans.GenesisId,
                                                              new Digest(trans.GenesisHash), (ulong?)assetID);

            Account.SetFeeByFeePerByte(tx, (ulong?)trans.Fee);
            return(tx);
        }
Example #7
0
        public static Transaction GetConfigAssetTransaction(Address sender, V2.Model.Asset asset, TransactionParametersResponse trans, string message = "")
        {
            ValidateAsset(asset.Params);
            //sender must be manager
            var tx = Transaction.CreateAssetConfigureTransaction(sender, 1,
                                                                 (ulong?)trans.LastRound, (ulong?)trans.LastRound + 1000, Encoding.UTF8.GetBytes(message), trans.GenesisId,
                                                                 new Digest(trans.GenesisHash), (ulong?)asset.Index, new Address(asset.Params.Manager),
                                                                 new Address(asset.Params.Reserve), new Address(asset.Params.Freeze), new Address(asset.Params.Clawback), false);

            Account.SetFeeByFeePerByte(tx, (ulong?)trans.Fee);
            return(tx);
        }
Example #8
0
        public async void Transaction_Clicked(System.Object sender, System.EventArgs e)
        {
            // restore accounts

            var accounts = await helper.RestoreAccounts();

            Account           account1 = accounts[0];
            Account           account2 = accounts[1];
            Account           account3 = accounts[2];
            HtmlWebViewSource htmlSource;
            // transfer from Account 1 to 2
            TransactionParametersResponse transParams = null;

            try
            {
                transParams = algodApiInstance.TransactionParams();
            }
            catch (ApiException err)
            {
                throw new Exception("Could not get params", err);
            }
            var amount   = Utils.AlgosToMicroalgos(1);
            var tx       = Utils.GetPaymentTransaction(account1.Address, account2.Address, amount, "pay message", transParams);
            var signedTx = account1.SignTransaction(tx);

            Console.WriteLine("Signed transaction with txid: " + signedTx.transactionID);
            PostTransactionsResponse id = null;

            //  string wait = "";
            // send the transaction to the network
            try
            {
                id = Utils.SubmitTransaction(algodApiInstance, signedTx);
                Console.WriteLine("Successfully sent tx with id: " + id.TxId);
                var wait = Utils.WaitTransactionToComplete(algodApiInstance, id.TxId);

                Console.WriteLine("Successful! " + wait.Txn);
                await DisplayAccount(helper.StorageAccountName2);
            }
            catch (ApiException err)
            {
                // This should give us an informative error message.
                //   await SecureStorage.SetAsync("Transaction", err.Message);
                Console.WriteLine("Exception when calling algod#rawTransaction: " + err.Message);

                if (err.Message.Contains("overspend"))
                {
                    var network = await SecureStorage.GetAsync(helper.StorageNetwork);

                    htmlSource      = new HtmlWebViewSource();
                    htmlSource.Html = @"<html><body><h3>" + network + " Account has insuficent funds. " + "</h3>" +
                                      "<h3>" + network + " add funds and try again. " + "</h3>" +
                                      "<p>Account = " + account1.Address.ToString() + "</p>" +
                                      "</body></html>";

                    myWebView.Source  = htmlSource;
                    myWebViewp.Source = htmlSource;
                }
                htmlSource      = new HtmlWebViewSource();
                htmlSource.Html = @"<html><body><h3> Transaction ID = " + err.Message + "</h3>" +
                                  "</body></html>";

                myWebView.Source  = htmlSource;
                myWebViewp.Source = htmlSource;
                //  Entry4.Text = "Transaction ID = " + err.Message;
            }

            if (!(String.IsNullOrEmpty(id.TxId)))
            {
                await SecureStorage.SetAsync(helper.StorageTransaction, id.TxId.ToString());

                GetTransaction.IsVisible = true;
            }


            buttonstate();


            var mytx = await SecureStorage.GetAsync(helper.StorageTransaction);

            if (!(mytx == null || mytx == ""))

            {
                Algorand.V2.Model.Account accountinfo = await algodApiInstance.AccountInformationAsync(account2.Address.ToString());

                Debug.WriteLine("Account 2 info: " + accountinfo);
                htmlSource = new HtmlWebViewSource();

                htmlSource.Html = @"<html><body><h3> Transaction ID = " + mytx.ToString() + " </h3>" +
                                  "<h3>" + "Account 2 info = " + accountinfo.ToJson() + "</h3>" +
                                  "</body></html>";

                myWebView.Source  = htmlSource;
                myWebViewp.Source = htmlSource;
            }
            await DisplayAccount(helper.StorageAccountName2);
        }