예제 #1
0
 private static void QueryAllNFT()
 {
     Algorand.V2.Model.Account actInfo = null;
     try
     {
         // We can now list the account information for acct3
         // and see that it can accept the new asseet
         actInfo = algodApiInstance.AccountInformation(act.Address.ToString());
         Console.WriteLine(actInfo);
         foreach (var ast in actInfo.Assets)
         {
             if (ast.Creator == reliableAddress)
             {
                 var astInfo = algodApiInstance.GetAssetByID(ast.AssetId);
                 if (astInfo.Params.Total == 1 && astInfo.Params.Decimals == 0 &&
                     astInfo.Params.UnitName == "NFT")
                 {
                     Console.WriteLine(
                         string.Format("Token Name: {0}, Token Id: {1}", astInfo.Params.Name, astInfo.Index)
                         );
                 }
             }
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
         return;
     }
 }
예제 #2
0
        public async Task <IActionResult> About()
        {
            var userIt = await _userManager.FindByNameAsync(User.Identity.Name);

            AlgodApi algodApiInstance = new AlgodApi("https://testnet-algorand.api.purestake.io/ps1", "B3SU4KcVKi94Jap2VXkK83xx38bsv95K5UZm2lab");
            //BuyerMnemonnic
            Account src          = new Account(userIt.MnnemonicKey);
            var     buyerAddress = userIt.AccountAddress;
            //var c = "OQIM6O74DXB454SCLT7KH7GJ5HJJE6DQDPPW6JNPVSRZ6RU4GVQMGKTH2Q";
            //Console.WriteLine(account1.Address.ToString());
            //Console.WriteLine(account2.Address.ToString());
            var accountInfo = algodApiInstance.AccountInformation(buyerAddress.ToString());

            //Console.WriteLine(string.Format($"Account Balance: {0} microAlgos", accountInfo.Amount));
            ViewData["acc"] = $"Account Balance: {accountInfo.Amount} microAlgos";
            var acts    = algodApiInstance.AccountInformation(buyerAddress.ToString());
            var befores = "Account 1 balance before: " + acts.Amount.ToString();

            //Console.WriteLine(acts);
            //Console.WriteLine(befores);
            ViewData["address"] = $"{userIt.AccountAddress}";
            ViewData["acts"]    = $"{acts}";
            ViewData["befores"] = $"{befores}";
            ViewData["Message"] = "Your application description page.";

            return(View());
        }
        public async Task <IActionResult> BuyIT(int id)
        {
            var gameITModel = await _context.GameITModel.SingleOrDefaultAsync(m => m.Id == id);

            var userIt = await _userManager.FindByNameAsync(User.Identity.Name);

            AlgodApi algodApiInstance = new AlgodApi("https://testnet-algorand.api.purestake.io/ps1", "B3SU4KcVKi94Jap2VXkK83xx38bsv95K5UZm2lab");
            //BuyerMnemonnic
            Account src           = new Account(userIt.MnnemonicKey);
            var     buyerAddress  = userIt.AccountAddress;
            var     sellerAddress = gameITModel.GameAddressOwner;
            //var c = "OQIM6O74DXB454SCLT7KH7GJ5HJJE6DQDPPW6JNPVSRZ6RU4GVQMGKTH2Q";
            //Console.WriteLine(account1.Address.ToString());
            //Console.WriteLine(account2.Address.ToString());
            var accountInfo = algodApiInstance.AccountInformation(buyerAddress.ToString());

            Console.WriteLine(string.Format($"Account Balance: {0} microAlgos", accountInfo.Amount));
            var acts    = algodApiInstance.AccountInformation(buyerAddress.ToString());
            var befores = "Account 1 balance before: " + acts.Amount.ToString();

            Console.WriteLine(acts);
            Console.WriteLine(befores);
            TransactionParams transParams = null;

            try
            {
                transParams = algodApiInstance.TransactionParams();
            }
            catch (ApiException err)
            {
                throw new Exception("Could not get params", err);
            }
            var amount   = Utils.AlgosToMicroalgos(Convert.ToDouble(gameITModel.Price));
            var tx       = Utils.GetPaymentTransaction(new Address(buyerAddress), new Address(gameITModel.GameAddressOwner), amount, "pay message", transParams);
            var signedTx = src.SignTransaction(tx);

            ViewBag.Tran = $"Signed transaction with txid: {signedTx.transactionID}";
            //Console.WriteLine("Signed transaction with txid: " + signedTx.transactionID);

            // send the transaction to the network
            try
            {
                var ids = Utils.SubmitTransaction(algodApiInstance, signedTx);
                ViewBag.Sent = $"Successfully sent tx with id: {ids.TxId}";
                //Console.WriteLine("Successfully sent tx with id: " + ids.TxId);
                ViewBag.WaitTran = Utils.WaitTransactionToComplete(algodApiInstance, ids.TxId);
                //Console.WriteLine(Utils.WaitTransactionToComplete(algodApiInstance, ids.TxId));
            }
            catch (ApiException e)
            {
                // This is generally expected, but should give us an informative error message.
                ViewBag.Exc = $"Exception when calling algod#rawTransaction: {e.Message}";
                //Console.WriteLine("Exception when calling algod#rawTransaction: " + e.Message);
            }
            ViewBag.Success = $"You have successefully arrived the end of this test, please press and key to exist.";
            //Console.WriteLine("You have successefully arrived the end of this test, please press and key to exist.");
            //Console.ReadKey();
            return(RedirectToAction(nameof(Index)));
        }
        static void CallApp(AlgodApi client, Account creator, Account user, long?applicationId, List <byte[]> args,
                            TEALProgram program, string tealFileName)
        {
            Console.WriteLine("Creator Account:" + creator.Address.ToString());
            Console.WriteLine("User Account:" + user.Address.ToString());
            try
            {
                var transParams = client.TransactionParams();
                var tx          = Utils.GetApplicationCallTransaction(user.Address, (ulong?)applicationId, transParams, args);
                var signedTx    = user.SignTransaction(tx);
                //Console.WriteLine("Signed transaction with txid: " + signedTx.transactionID);

                var cr      = client.AccountInformation(creator.Address.ToString());
                var usr     = client.AccountInformation(user.Address.ToString());
                var mydrr   = DryrunDrr(signedTx, program, cr, usr);
                var drrFile = "mydrr.dr";
                WriteDrr(drrFile, mydrr);
                Console.WriteLine("drr file created ... debugger starting - goto chrome://inspect");

                // START debugging session
                // either use from terminal in this folder
                // `tealdbg debug program.teal --dryrun-req mydrr.dr`
                //
                // or use this line to invoke debugger
                // and switch to chrome://inspect to inspect and debug
                // (program execution will continue aafter debuigging session completes)

                Excute(string.Format("tealdbg debug {0} --dryrun-req {1}", tealFileName, drrFile));

                // break here on the next line with debugger
                // run this command in this folder
                // tealdbg debug hello_world.teal --dryrun-req mydrr.dr
                // or
                // tealdbg debug hello_world_updated.teal --dryrun-req mydrr.dr

                var id = Utils.SubmitTransaction(client, signedTx);
                Console.WriteLine("Successfully sent tx with id: " + id.TxId);
                var resp = Utils.WaitTransactionToComplete(client, id.TxId);
                Console.WriteLine("Confirmed at round: " + resp.ConfirmedRound);
                //System.out.println("Called app-id: " + pTrx.txn.tx.applicationId);
                if (resp.GlobalStateDelta != null)
                {
                    Console.WriteLine("    Global state: " + resp.GlobalStateDelta.ToString());
                }
                if (resp.LocalStateDelta != null)
                {
                    Console.WriteLine("    Local state: " + resp.LocalStateDelta.ToString());
                }
            }
            catch (ApiException e)
            {
                Console.WriteLine("Exception when calling create application: " + e.Message);
            }
        }
예제 #5
0
        private static string BuildPost(string BuyerAddress, string SellerAddress, string GameToBuy, string Amount)
        {
            AlgodApi algodApiInstance = new AlgodApi("https://testnet-algorand.api.purestake.io/ps1", "B3SU4KcVKi94Jap2VXkK83xx38bsv95K5UZm2lab");
            Account  src = new Account("ordinary certain payment annual plate slot squeeze recycle neck whip transfer cat photo error bus frost magnet arrange filter used soon medal liquid abstract father");
            //Console.WriteLine(account3.Address.ToString());
            //var c = "AJ7GLWNUT6TEJYUGNYAZQ7342TK7DBZLWBMIMK3NBN6NZCWJHLNYCRYQ7I";
            var a = "36DTG5ITNWLAVZBSZ6BXPWP7UTSPEOL3K4HWIEUYML7RKUCBZQP5XBR7XY";
            var b = "EUFD3MONZCV6P65OHVHDTDY2B7OYALLNDORL2GJPB4RATJB4K2O3CUUVOU";
            var c = "OQIM6O74DXB454SCLT7KH7GJ5HJJE6DQDPPW6JNPVSRZ6RU4GVQMGKTH2Q";
            //Console.WriteLine(account1.Address.ToString());
            //Console.WriteLine(account2.Address.ToString());
            var accountInfo = algodApiInstance.AccountInformation(c.ToString());

            Console.WriteLine(string.Format($"Account Balance: {0} microAlgos", accountInfo.Amount));
            var acts    = algodApiInstance.AccountInformation(a.ToString());
            var befores = "Account 1 balance before: " + acts.Amount.ToString();

            Console.WriteLine(acts);
            Console.WriteLine(befores);
            TransactionParams 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(new Address(a), new Address(b), amount, "pay message", transParams);
            var signedTx = src.SignTransaction(tx);

            Console.WriteLine("Signed transaction with txid: " + signedTx.transactionID);

            // send the transaction to the network
            try
            {
                var id = Utils.SubmitTransaction(algodApiInstance, signedTx);
                Console.WriteLine("Successfully sent tx with id: " + id.TxId);
                Console.WriteLine(Utils.WaitTransactionToComplete(algodApiInstance, id.TxId));
            }
            catch (ApiException e)
            {
                // This is generally expected, but should give us an informative error message.
                Console.WriteLine("Exception when calling algod#rawTransaction: " + e.Message);
            }

            Console.WriteLine("You have successefully arrived the end of this test, please press and key to exist.");
            Console.ReadKey();
            return("a");
        }
        public static void Main(string[] args)
        {
            string ALGOD_API_ADDR = args[0];

            if (ALGOD_API_ADDR.IndexOf("//") == -1)
            {
                ALGOD_API_ADDR = "http://" + ALGOD_API_ADDR;
            }

            string  ALGOD_API_TOKEN = args.Length > 1 ? args[1] : null;
            string  SRC_ACCOUNT     = "typical permit hurdle hat song detail cattle merge oxygen crowd arctic cargo smooth fly rice vacuum lounge yard frown predict west wife latin absent cup";
            Account src             = new Account(SRC_ACCOUNT);

            Console.WriteLine("My account address is:" + src.Address.ToString());

            AlgodApi algodApiInstance = new AlgodApi(ALGOD_API_ADDR, ALGOD_API_TOKEN);

            var accountInfo = algodApiInstance.AccountInformation(src.Address.ToString());

            Console.WriteLine(string.Format("Account Balance: {0} microAlgos", accountInfo.Amount));

            var task = algodApiInstance.AccountInformationAsync(src.Address.ToString());

            task.Wait();
            var asyncAccountInfo = task.Result;

            Console.WriteLine(string.Format("Account Balance(Async): {0} microAlgos", asyncAccountInfo.Amount));

            Console.WriteLine("You have successefully arrived the end of this test, please press and key to exist.");
        }
        void AccountSign_Clicked(System.Object sender, System.EventArgs e)
        {
            var trans = client.TransactionParams();

            Console.WriteLine("Lastround: " + trans.LastRound.ToString());

            var act = client.AccountInformation(account3.Address.ToString());

            Console.WriteLine(act);

            ulong?amount2 = 1000000;
            var   tx2     = Utils.GetPaymentTransaction(account3.Address, account2.Address, amount2, "pay message", trans);

            tx2.RekeyTo = account1.Address;
            var signedTx2 = account1.SignTransaction(tx2);

            try
            {
                var id = Utils.SubmitTransaction(client, signedTx2);
                Console.WriteLine("Transaction ID: " + id);
                Console.WriteLine("Confirmed Round is: " +
                                  Utils.WaitTransactionToComplete(client, id.TxId).ConfirmedRound);
                DisplayInfo("Account 3 send to Account 2, rekeyed to sign by  Account 1 - Confirmed Round is: " +
                            Utils.WaitTransactionToComplete(client, id.TxId).ConfirmedRound);
                OptinBtn.IsEnabled  = false;
                ResetBack.IsEnabled = true;
            }
            catch (Exception err)
            {
                Console.WriteLine(err.Message);
                DisplayInfo("Error: " + err.Message);
                return;
            }
        }
 private async void Button_Click_1(object sender, RoutedEventArgs e)
 {
     string   ALGOD_API_ADDR   = "https://testnet-algorand.api.purestake.io/ps2";
     string   ALGOD_API_TOKEN  = "B3SU4KcVKi94Jap2VXkK83xx38bsv95K5UZm2lab";
     AlgodApi algodApiInstance = new AlgodApi(ALGOD_API_ADDR, ALGOD_API_TOKEN);
     var      accountInfo      = algodApiInstance.AccountInformation("VYFF3MXAXWGHNIAEUVINZZHEW2MH5HKTXEACXUTZ3HHADIBPT5ATJGR6K4");
     var      dialog           = new MessageDialog(string.Format("Account Balance: " + accountInfo.Amount + " MicroAlgos"));
     await dialog.ShowAsync();
 }
예제 #9
0
        static void Main(string[] args)
        {
            //AJ7GLWNUT6TEJYUGNYAZQ7342TK7DBZLWBMIMK3NBN6NZCWJHLNYCRYQ7I
            Account account1 = new Account();
            Account account2 = new Account();
            Account account3 = new Account();
            var     a        = "AJ7GLWNUT6TEJYUGNYAZQ7342TK7DBZLWBMIMK3NBN6NZCWJHLNYCRYQ7I";

            Console.WriteLine(a.ToString());
            var act    = algodApiInstance.AccountInformation(a.ToString());
            var before = "Account 1 balance before: " + act.Amount.ToString();

            Console.WriteLine(act);
            Console.WriteLine(before);
            //TransactionParams 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 tx2 = Utils.GetPaymentTransaction(account1.Address, account3.Address, amount, "pay message", transParams);
            ////SignedTransaction signedTx2 = src.SignTransactionWithFeePerByte(tx2, feePerByte);
            //Digest gid = TxGroup.ComputeGroupID(new Algorand.Transaction[] { tx, tx2 });
            //tx.AssignGroupID(gid);
            //tx2.AssignGroupID(gid);
            //// already updated the groupid, sign
            //var signedTx = account1.SignTransaction(tx);
            //var signedTx2 = account1.SignTransaction(tx2);
            //try
            //{
            //    //contact the signed msgpack
            //    List<byte> byteList = new List<byte>(Algorand.Encoder.EncodeToMsgPack(signedTx));
            //    byteList.AddRange(Algorand.Encoder.EncodeToMsgPack(signedTx2));
            //    var act = algodApiInstance.AccountInformation(account1.Address.ToString());
            //    var before = "Account 1 balance before: " + act.Amount.ToString();
            //    var id = algodApiInstance.RawTransaction(byteList.ToArray());
            //    var wait = Utils.WaitTransactionToComplete(algodApiInstance, id.TxId);
            //    Console.WriteLine(wait);

            //    // Console.WriteLine("Successfully sent tx group with first tx id: " + id);

            //    act = algodApiInstance.AccountInformation(account1.Address.ToString());
            //}
            //catch (ApiException err)
            //{
            //    // This is generally expected, but should give us an informative error message.
            //    Console.WriteLine("Exception when calling algod#rawTransaction: " + err.Message);
            //}
        }
예제 #10
0
        static void Main(string[] args)
        {
            Account account = new Account();
            var     a       = "YTZVLL4XHBHMMZ2YOFNYFICMRVKTQAYHGOKEPNIA35HACBNVHNOOCYTN6I";

            if (Address.IsValid(a))
            {
                Console.WriteLine("Address is Valid");
            }
            else
            {
                Console.WriteLine("Address is not Valid");
            }
            AlgodApi algodApiInstance = new AlgodApi("https://testnet-algorand.api.purestake.io/ps1", "B3SU4KcVKi94Jap2VXkK83xx38bsv95K5UZm2lab");
            var      accountInfo      = algodApiInstance.AccountInformation(a.ToString());

            Console.WriteLine($"Acccount Balance of {a} is {accountInfo.Amount}");
        }
        static public void ReadGlobalState(AlgodApi client, Account account, long?appId)
        {
            var acctResponse        = client.AccountInformation(account.Address.ToString());
            var createdApplications = acctResponse.CreatedApps;

            for (int i = 0; i < createdApplications.Count; i++)
            {
                if (createdApplications[i].Id == appId)
                {
                    var outStr = "Application global state: ";
                    foreach (var v in createdApplications[i].Params.GlobalState)
                    {
                        outStr += v.ToString();
                    }
                    Console.WriteLine(outStr);
                }
            }
        }
        static public void ReadLocalState(AlgodApi client, Account account, long?appId)
        {
            var acctResponse          = client.AccountInformation(account.Address.ToString());
            var applicationLocalState = acctResponse.AppsLocalState;

            for (int i = 0; i < applicationLocalState.Count; i++)
            {
                if (applicationLocalState[i].Id == appId)
                {
                    var outStr = "User's application local state: ";
                    foreach (var v in applicationLocalState[i].KeyValue)
                    {
                        outStr += v.ToString();
                    }
                    Console.WriteLine(outStr);
                }
            }
        }
        static void Main(string[] args)
        {
            string ALGOD_API_ADDR  = "https://testnet-algorand.api.purestake.io/ps1";
            string ALGOD_API_TOKEN = "B3SU4KcVKi94Jap2VXkK83xx38bsv95K5UZm2lab";

            // If the protocol is not specified in the address, http is added.
            //string ALGOD_API_ADDR = args[0];
            if (ALGOD_API_ADDR.IndexOf("//") == -1)
            {
                ALGOD_API_ADDR = "http://" + ALGOD_API_ADDR;
            }

            //string ALGOD_API_TOKEN = args[1];
            string SRC_ACCOUNT = "typical permit hurdle hat song detail cattle merge oxygen crowd arctic cargo smooth fly rice vacuum lounge yard frown predict west wife latin absent cup";
            string DEST_ADDR   = "KV2XGKMXGYJ6PWYQA5374BYIQBL3ONRMSIARPCFCJEAMAHQEVYPB7PL3KU";

            if (!Address.IsValid(DEST_ADDR))
            {
                Console.WriteLine("The address " + DEST_ADDR + " is not valid!");
            }
            Account src = new Account(SRC_ACCOUNT);

            Console.WriteLine("My account address is:" + src.Address.ToString());
            if (src.ToMnemonic() != SRC_ACCOUNT)
            {
                Console.WriteLine("ToMnemonic function is wriong!");
            }

            //sign and verify bytes function test
            var bytes    = Encoding.UTF8.GetBytes("examples");
            var siguture = src.SignBytes(bytes);

            Address srcAddr  = new Address(src.Address.ToString());
            var     verifyed = srcAddr.VerifyBytes(bytes, siguture);

            AlgodApi algodApiInstance = new AlgodApi(ALGOD_API_ADDR, ALGOD_API_TOKEN);
            var      amountBalance    = algodApiInstance.AccountInformation(srcAddr.ToString());

            Console.WriteLine(amountBalance.Amount);


            Console.WriteLine("You have successefully arrived the end of this test, please press and key to exist.");
            Console.ReadKey();
        }
예제 #14
0
        public static void Main(string[] args)
        {
            string ALGOD_API_ADDR = args[0];

            if (ALGOD_API_ADDR.IndexOf("//") == -1)
            {
                ALGOD_API_ADDR = "http://" + ALGOD_API_ADDR;
            }

            string ALGOD_API_TOKEN     = args.Length > 1 ? args[1] : null;
            var    account1_passphrase = "fringe model trophy claw stove perfect address market license abstract master slender choice around field embark sudden carbon exclude abuse square bulb front ability violin";
            var    account2_passphrase = "impulse nation creek toy carpet amused dream can small long disorder source mail game category damp spread length cupboard theory either baby squeeze about orbit";
            var    account3_passphrase = "fade exit sword someone lock minimum scout keen label dance jaguar select conduct luxury rose idea solid major solid lens globe agent assume abstract alien";


            var account1 = new Account(account1_passphrase);
            var account2 = new Account(account2_passphrase);
            //    private_key = mnemonic.to_private_key(account3_passphrase)
            var account3 = new Account(account3_passphrase);

            Console.WriteLine(string.Format("Account 1 : {0}", account1.Address));
            Console.WriteLine(string.Format("Account 2 : {0}", account2.Address));
            Console.WriteLine(string.Format("Account 3 : {0}", account3.Address));

            //Part 1
            //build transaction

            AlgodApi algodApiInstance = new AlgodApi(ALGOD_API_ADDR, ALGOD_API_TOKEN);
            var      trans            = algodApiInstance.TransactionParams();

            Console.WriteLine("Lastround: " + trans.LastRound.ToString());


            bool firstRun = false;

            if (firstRun)
            {
                ulong?amount = 0;
                //opt-in send tx to same address as sender and use 0 for amount w rekey account to account 1
                var tx = Utils.GetPaymentTransaction(account3.Address, account3.Address, amount, "pay message", trans);
                tx.RekeyTo = account1.Address;

                var signedTx = account3.SignTransaction(tx);
                // send the transaction to the network and
                // wait for the transaction to be confirmed
                try
                {
                    var id = Utils.SubmitTransaction(algodApiInstance, signedTx);
                    Console.WriteLine("Transaction ID: " + id);
                    //waitForTransactionToComplete(algodApiInstance, signedTx.transactionID);
                    //Console.ReadKey();
                    Console.WriteLine("Confirmed Round is: " +
                                      Utils.WaitTransactionToComplete(algodApiInstance, id.TxId).ConfirmedRound);
                }
                catch (Exception e)
                {
                    //e.printStackTrace();
                    Console.WriteLine(e.Message);
                    return;
                }
            }

            var act = algodApiInstance.AccountInformation(account3.Address.ToString());

            Console.WriteLine(act);

            ulong?amount2 = 1000000;
            var   tx2     = Utils.GetPaymentTransaction(account3.Address, account2.Address, amount2, "pay message", trans);

            tx2.RekeyTo = account1.Address;
            var signedTx2 = account1.SignTransaction(tx2);

            try
            {
                var id = Utils.SubmitTransaction(algodApiInstance, signedTx2);
                Console.WriteLine("Transaction ID: " + id);
                Console.WriteLine("Confirmed Round is: " +
                                  Utils.WaitTransactionToComplete(algodApiInstance, id.TxId).ConfirmedRound);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                return;
            }
        }
예제 #15
0
        // Utility function for sending a raw signed transaction to the network
        public static void Run(params string[] args) //throws Exception
        {
            string   ALGOD_API_ADDR   = "https://testnet-algorand.api.purestake.io/ps1";
            string   ALGOD_API_TOKEN  = "GeHdp7CCGt7ApLuPNppXN4LtrW07Mm1kaFNJ5Ovr";
            AlgodApi algodApiInstance = new AlgodApi(ALGOD_API_ADDR, ALGOD_API_TOKEN);

            // 这三个账号只用于演示,在实际使用时永远不要直接将助记词放在代码中
            string account1_mnemonic = "portion never forward pill lunch organ biology"
                                       + " weird catch curve isolate plug innocent skin grunt"
                                       + " bounce clown mercy hole eagle soul chunk type absorb trim";
            string account2_mnemonic = "place blouse sad pigeon wing warrior wild script"
                                       + " problem team blouse camp soldier breeze twist mother"
                                       + " vanish public glass code arrow execute convince ability"
                                       + " there";
            string account3_mnemonic = "image travel claw climb bottom spot path roast "
                                       + "century also task cherry address curious save item "
                                       + "clean theme amateur loyal apart hybrid steak about blanket";

            Account acct1 = new Account(account1_mnemonic);
            Account acct2 = new Account(account2_mnemonic);
            Account acct3 = new Account(account3_mnemonic);
            // get last round and suggested tx fee
            // We use these to get the latest round and tx fees
            // These parameters will be required before every
            // Transaction
            // We will account for changing transaction parameters
            // before every transaction in this example
            var transParams = algodApiInstance.TransactionParams();

            // The following parameters are asset specific
            // and will be re-used throughout the example.

            // Create the Asset(创建ASA)
            // Total number of this asset available for circulation
            var ap = new AssetParams(creator: acct1.Address.ToString(), assetname: "latikum22",
                                     unitname: "LAT", defaultfrozen: false, total: 10000,
                                     url: "http://this.test.com", metadatahash: Convert.ToBase64String(
                                         Encoding.ASCII.GetBytes("16efaa3924a6fd9d3a4880099a4ac65d")))
            {
                // 每种地址的意义请参照https://developer.algorand.org/docs/features/asa/
                // 默认情况下manager/reserve/freeze/clawback账号都是sender
                // 如果设置了manager,其他没有设置的地址reserve/freeze/clawback都会是manager
                Managerkey   = acct1.Address.ToString(),
                Clawbackaddr = acct2.Address.ToString(),
                Freezeaddr   = acct1.Address.ToString(),
                Reserveaddr  = acct1.Address.ToString()
            };

            var tx = Utils.GetCreateAssetTransaction(ap, transParams, "asset tx message");

            // Sign the Transaction by sender
            SignedTransaction signedTx = acct1.SignTransaction(tx);
            // send the transaction to the network and
            // wait for the transaction to be confirmed
            ulong?assetID = 0;

            try
            {
                TransactionID id = Utils.SubmitTransaction(algodApiInstance, signedTx);
                Console.WriteLine("Transaction ID: " + id);
                Console.WriteLine(Utils.WaitTransactionToComplete(algodApiInstance, id.TxId));
                // Now that the transaction is confirmed we can get the assetID
                Algorand.Algod.Client.Model.Transaction ptx = algodApiInstance.PendingTransactionInformation(id.TxId);
                assetID = ptx.Txresults.Createdasset;
            }
            catch (Exception e)
            {
                Console.WriteLine(e.StackTrace);
                return;
            }
            Console.WriteLine("AssetID = " + assetID);
            // 现在ASA已经创建


            // 修改ASA的设置
            // Next we will change the asset configuration
            // First we update standard Transaction parameters
            // To account for changes in the state of the blockchain
            transParams = algodApiInstance.TransactionParams();
            ap          = algodApiInstance.AssetInformation((long?)assetID);

            // 修改ASA设置必须由manager账号执行,在本例是中acct2
            // Note in this transaction we are re-using the asset
            // creation parameters and only changing the manager
            // and transaction parameters like first and last round
            // now update the manager to acct1
            ap.Managerkey = acct2.Address.ToString();
            tx            = Utils.GetConfigAssetTransaction(acct1.Address, assetID, ap, transParams, "config trans");

            // The transaction must be signed by the current manager account
            // We are reusing the signedTx variable from the first transaction in the example
            signedTx = acct1.SignTransaction(tx);
            // send the transaction to the network and
            // wait for the transaction to be confirmed
            try
            {
                TransactionID id = Utils.SubmitTransaction(algodApiInstance, signedTx);
                Console.WriteLine("Transaction ID: " + id.TxId);
                Console.WriteLine(Utils.WaitTransactionToComplete(algodApiInstance, id.TxId));
            }
            catch (Exception e)
            {
                //e.printStackTrace();
                Console.WriteLine(e.Message);
                return;
            }

            // Next we will list the newly created asset
            // Get the asset information for the newly changed asset
            ap = algodApiInstance.AssetInformation((long?)assetID);
            //The manager should now be the same as the creator
            Console.WriteLine(ap);


            // 激活(Opting in)某种ASA
            // 如果你需要给其他用户转ASA,那么对方必须先激活
            // 然后才能接收ASA
            // First we update standard Transaction parameters
            // To account for changes in the state of the blockchain
            transParams = algodApiInstance.TransactionParams();
            tx          = Utils.GetActivateAssetTransaction(acct3.Address, assetID, transParams, "opt in transaction");

            // The transaction must be signed by the current manager account
            // We are reusing the signedTx variable from the first transaction in the example
            signedTx = acct3.SignTransaction(tx);
            // send the transaction to the network and
            // wait for the transaction to be confirmed
            Algorand.Algod.Client.Model.Account act = null;
            try
            {
                TransactionID id = Utils.SubmitTransaction(algodApiInstance, signedTx);
                Console.WriteLine("Transaction ID: " + id.TxId);
                Console.WriteLine(Utils.WaitTransactionToComplete(algodApiInstance, id.TxId));
                // We can now list the account information for acct3
                // and see that it can accept the new asseet
                act = algodApiInstance.AccountInformation(acct3.Address.ToString());
                Console.WriteLine(act);
            }
            catch (Exception e)
            {
                //e.printStackTrace();
                Console.WriteLine(e.Message);
                return;
            }

            // ASA转账
            // 激活后account3就可以接收ASA了
            // 现在我们从acctout1向account3转账
            // First we update standard Transaction parameters
            // To account for changes in the state of the blockchain
            transParams = algodApiInstance.TransactionParams();
            // Next we set asset xfer specific parameters
            // We set the assetCloseTo to null so we do not close the asset out
            ulong assetAmount = 10;

            tx = Utils.GetTransferAssetTransaction(acct1.Address, acct3.Address, assetID, assetAmount, transParams, null, "transfer message");
            // The transaction must be signed by the sender account
            // We are reusing the signedTx variable from the first transaction in the example
            signedTx = acct1.SignTransaction(tx);
            // send the transaction to the network and
            // wait for the transaction to be confirmed
            try
            {
                TransactionID id = Utils.SubmitTransaction(algodApiInstance, signedTx);
                Console.WriteLine("Transaction ID: " + id.TxId);
                Console.WriteLine(Utils.WaitTransactionToComplete(algodApiInstance, id.TxId));
                // We can now list the account information for acct3
                // and see that it now has 5 of the new asset
                act = algodApiInstance.AccountInformation(acct3.Address.ToString());
                Console.WriteLine(act.GetHolding(assetID).Amount);
            }
            catch (Exception e)
            {
                //e.printStackTrace();
                Console.WriteLine(e.Message);
                return;
            }

            // 冻结资产
            // 如果freeze address当时没有设置,则无法冻结资产
            // 此例中冻结account3中的资产
            // 冻结事件须由freeze acount来发出,本例中为account1
            // First we update standard Transaction parameters
            // To account for changes in the state of the blockchain
            transParams = algodApiInstance.TransactionParams();
            // Next we set asset xfer specific parameters
            // The sender should be freeze account acct2
            // Theaccount to freeze should be set to acct3
            tx = Utils.GetFreezeAssetTransaction(acct1.Address, acct3.Address, assetID, true, transParams, "freeze transaction");
            // The transaction must be signed by the freeze account acct2
            // We are reusing the signedTx variable from the first transaction in the example
            signedTx = acct1.SignTransaction(tx);
            // send the transaction to the network and
            // wait for the transaction to be confirmed
            try
            {
                TransactionID id = Utils.SubmitTransaction(algodApiInstance, signedTx);
                Console.WriteLine("Transaction ID: " + id.TxId);
                Console.WriteLine(Utils.WaitTransactionToComplete(algodApiInstance, id.TxId));
                // We can now list the account information for acct3
                // and see that it now frozen
                // Note--currently no getter method for frozen state
                act = algodApiInstance.AccountInformation(acct3.Address.ToString());
                Console.WriteLine(act.GetHolding(assetID).ToString());
            }
            catch (Exception e)
            {
                //e.printStackTrace();
                Console.WriteLine(e.Message);
                return;
            }

            // 撤回转账
            // 撤加转账必须由clawbackaddress发起。
            // 如果资产的manager将clawbackaddress设为空,则此操作不可执行
            // 本例中会将10个资产从account3撤回到account1
            // 此操作需要由clawbackaccount(account2)进行签名
            // 此操作发送者为原操作的发起者(acct1)
            // First we update standard Transaction parameters
            // To account for changes in the state of the blockchain
            transParams = algodApiInstance.TransactionParams();
            // Next we set asset xfer specific parameters
            assetAmount = 10;
            tx          = Utils.GetRevokeAssetTransaction(acct2.Address, acct3.Address, acct1.Address, assetID, assetAmount, transParams, "revoke transaction");
            // The transaction must be signed by the clawback account
            // We are reusing the signedTx variable from the first transaction in the example
            signedTx = acct2.SignTransaction(tx);
            // send the transaction to the network and
            // wait for the transaction to be confirmed
            try
            {
                TransactionID id = Utils.SubmitTransaction(algodApiInstance, signedTx);
                Console.WriteLine("Transaction ID: " + id);
                Console.WriteLine(Utils.WaitTransactionToComplete(algodApiInstance, id.TxId));
                // We can now list the account information for acct3
                // and see that it now has 0 of the new asset
                act = algodApiInstance.AccountInformation(acct3.Address.ToString());
                Console.WriteLine(act.GetHolding(assetID).Amount);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                return;
            }

            // 销毁资产
            // 销毁资产前所有资产需要回到创建者账号中
            // 销毁资产需要由Manage Addr进行操作
            // First we update standard Transaction parameters
            // To account for changes in the state of the blockchain
            transParams = algodApiInstance.TransactionParams();
            // Next we set asset xfer specific parameters
            // The manager must sign and submit the transaction
            // This is currently set to acct2
            tx = Utils.GetDestroyAssetTransaction(acct2.Address, assetID, transParams, "destroy transaction");
            // The transaction must be signed by the manager account
            // We are reusing the signedTx variable from the first transaction in the example
            signedTx = acct2.SignTransaction(tx);
            // send the transaction to the network and
            // wait for the transaction to be confirmed
            try
            {
                TransactionID id = Utils.SubmitTransaction(algodApiInstance, signedTx);
                Console.WriteLine("Transaction ID: " + id);
                Console.WriteLine(Utils.WaitTransactionToComplete(algodApiInstance, id.TxId));
                // We can now list the account information for acct1
                // and see that the asset is no longer there
                act = algodApiInstance.AccountInformation(acct1.Address.ToString());
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                return;
            }
            Console.WriteLine("You have successefully arrived the end of this test, please press and key to exist.");
            Console.ReadKey();
        }
예제 #16
0
        private static void GetAndPrintAccountInformation(AlgodApi algodApi, Account account, int number)
        {
            var accountInformation = algodApi.AccountInformation(account.Address.ToString());

            Console.WriteLine("Account #" + number + " information: " + Environment.NewLine + accountInformation.ToJson());
        }
예제 #17
0
        public static void Main(string[] args)
        {
            string ALGOD_API_ADDR = args[0];

            if (ALGOD_API_ADDR.IndexOf("//") == -1)
            {
                ALGOD_API_ADDR = "http://" + ALGOD_API_ADDR;
            }

            string ALGOD_API_TOKEN = args[1];
            string SRC_ACCOUNT     = "typical permit hurdle hat song detail cattle merge oxygen crowd arctic cargo smooth fly rice vacuum lounge yard frown predict west wife latin absent cup";
            string DEST_ADDR       = "KV2XGKMXGYJ6PWYQA5374BYIQBL3ONRMSIARPCFCJEAMAHQEVYPB7PL3KU";

            if (!Address.IsValid(DEST_ADDR))
            {
                Console.WriteLine("The address " + DEST_ADDR + " is not valid!");
            }
            Account src = new Account(SRC_ACCOUNT);

            Console.WriteLine("My account address is:" + src.Address.ToString());

            AlgodApi algodApiInstance = new AlgodApi(ALGOD_API_ADDR, ALGOD_API_TOKEN);

            try
            {
                var supply = algodApiInstance.GetSupply();
                Console.WriteLine("Total Algorand Supply: " + supply.TotalMoney);
                Console.WriteLine("Online Algorand Supply: " + supply.OnlineMoney);
            }
            catch (ApiException e)
            {
                Console.WriteLine("Exception when calling algod#getSupply:" + e.Message);
            }

            var accountInfo = algodApiInstance.AccountInformation(src.Address.ToString());

            Console.WriteLine(string.Format("Account Balance: {0} microAlgos", accountInfo.Amount));

            try
            {
                var trans = algodApiInstance.TransactionParams();
                var lr    = trans.LastRound;
                var block = algodApiInstance.GetBlock(lr);

                Console.WriteLine("Lastround: " + trans.LastRound.ToString());
                Console.WriteLine("Block txns: " + block.Block.ToString());
            }
            catch (ApiException e)
            {
                Console.WriteLine("Exception when calling algod#getSupply:" + e.Message);
            }

            TransactionParametersResponse transParams;

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

            Console.WriteLine("Signed transaction with txid: " + signedTx.transactionID);

            // send the transaction to the network
            try
            {
                var id = Utils.SubmitTransaction(algodApiInstance, signedTx);
                Console.WriteLine("Successfully sent tx with id: " + id.TxId);
                Console.WriteLine(Utils.WaitTransactionToComplete(algodApiInstance, id.TxId));
            }
            catch (ApiException e)
            {
                // This is generally expected, but should give us an informative error message.
                Console.WriteLine("Exception when calling algod#rawTransaction: " + e.Message);
            }

            Console.WriteLine("You have successefully arrived the end of this test, please press and key to exist.");
            Console.ReadKey();
        }
        public IActionResult GroupedTransactions()
        {
            AlgodApi          algodApiInstance = new AlgodApi("https://testnet-algorand.api.purestake.io/ps1", "B3SU4KcVKi94Jap2VXkK83xx38bsv95K5UZm2lab");
            TransactionParams transparams      = null;

            try
            {
                transparams = algodApiInstance.TransactionParams();
            }
            catch (ApiException err)
            {
                throw new Exception("Could not get params", err);
            }
            //4CLRLFJQK3WKEIHKOYTFJ5TT7W2KKQJQUXVJM4GZYLOHG5FC3C3PNF5XMQ
            var acc1 = "5LDA2DCL4BPUBWMJXLQC47XKGPLYDY2OVBNEKBXUV6GY3NIXBSDSMTIAKA";
            var acc2 = "RSVGYZ5653Z3X6GLFNBNM7NSR2OVQC6WRPPSOQLURI2H5R5DU35OYOQQ5A";
            //AE47UNNWHF2XCVFF4DAB7WPHKKNL5MFEW2YQ6DTK3HYNGO4GCG32WQAA5I
            var     Key     = "brain under subject brown letter select auto artwork inject display reflect clerk index prosper trick host true stable fork tone drum please loud abstract reject";
            Account account = new Account(Key);
            //Console.WriteLine(account.Address.ToString());
            //Console.WriteLine($"{account.Address.ToString()} and {account.ToMnemonic()}");
            //brain under subject brown letter select auto artwork inject display reflect clerk index prosper trick host true stable fork tone drum please loud abstract reject
            //LLMTMNBRXUF5ARJZLYYJEJPVOGDJ2SBYOHQDWXHOPIODS6ANXBL4S6BECE
            var accountAddress = "LLMTMNBRXUF5ARJZLYYJEJPVOGDJ2SBYOHQDWXHOPIODS6ANXBL4S6BECE";

            var accountInfo = algodApiInstance.AccountInformation("LLMTMNBRXUF5ARJZLYYJEJPVOGDJ2SBYOHQDWXHOPIODS6ANXBL4S6BECE");

            Console.WriteLine($"The address {accountAddress} has a Balance of: {accountInfo.Amount} microAlgos");
            //Let's create a grouped transaction
            var amount = Utils.AlgosToMicroalgos(1);

            var tx1 = Utils.GetPaymentTransaction(new Address(accountAddress), new Address(acc1), amount, "Perfoming First Grouped Transactions", transparams);

            var tx2 = Utils.GetPaymentTransaction(new Address(accountAddress), new Address(acc2), amount, "Perfoming Second Grouped Transactions", transparams);

            Digest gid = TxGroup.ComputeGroupID(new Algorand.Transaction[] { tx1, tx2 });

            tx1.AssignGroupID(gid);
            tx2.AssignGroupID(gid);
            var signedTx1 = account.SignTransaction(tx1);

            var signedTx2 = account.SignTransaction(tx2);

            try
            {
                List <byte> byteList = new List <byte>(Algorand.Encoder.EncodeToMsgPack(signedTx1));

                byteList.AddRange(Algorand.Encoder.EncodeToMsgPack(signedTx2));
                var acc = algodApiInstance.AccountInformation(accountAddress);

                var before = $"Account 1 Balance before: {acc.Amount.ToString()}";

                var id = algodApiInstance.RawTransaction(byteList.ToArray());

                var wait = Utils.WaitTransactionToComplete(algodApiInstance, id.TxId);

                //Console.WriteLine(wait);
                //Console.WriteLine($"Transfer sent to Tx group with id: {id}");
                acc = algodApiInstance.AccountInformation(accountAddress.ToString());
            }
            catch (ApiException err)
            {
                //Console.WriteLine($"Exception when calling algodrawtransactions: {err.Message}");
            }
            return(RedirectToAction(nameof(Index)));
        }
예제 #19
0
        // Utility function for sending a raw signed transaction to the network
        public static void Main(params string[] args) //throws Exception
        {
            string algodApiAddrTmp = args[0];

            if (algodApiAddrTmp.IndexOf("//") == -1)
            {
                algodApiAddrTmp = "http://" + algodApiAddrTmp;
            }

            string ALGOD_API_ADDR  = algodApiAddrTmp;
            string ALGOD_API_TOKEN = args[1];

            AlgodApi algodApiInstance = new AlgodApi(ALGOD_API_ADDR, ALGOD_API_TOKEN);

            // Shown for demonstration purposes. NEVER reveal secret mnemonics in practice.
            // These three accounts are for testing purposes
            string account1_mnemonic = "portion never forward pill lunch organ biology"
                                       + " weird catch curve isolate plug innocent skin grunt"
                                       + " bounce clown mercy hole eagle soul chunk type absorb trim";
            string account2_mnemonic = "place blouse sad pigeon wing warrior wild script"
                                       + " problem team blouse camp soldier breeze twist mother"
                                       + " vanish public glass code arrow execute convince ability"
                                       + " there";
            string account3_mnemonic = "image travel claw climb bottom spot path roast "
                                       + "century also task cherry address curious save item "
                                       + "clean theme amateur loyal apart hybrid steak about blanket";

            Account acct1 = new Account(account1_mnemonic);
            Account acct2 = new Account(account2_mnemonic);
            Account acct3 = new Account(account3_mnemonic);
            // get last round and suggested tx fee
            // We use these to get the latest round and tx fees
            // These parameters will be required before every
            // Transaction
            // We will account for changing transaction parameters
            // before every transaction in this example
            var transParams = algodApiInstance.TransactionParams();

            // The following parameters are asset specific
            // and will be re-used throughout the example.

            // Create the Asset
            // Total number of this asset available for circulation
            var ap = new AssetParams(creator: acct1.Address.ToString(), name: "latikum22", unitName: "LAT", total: 10000,
                                     decimals: 0, url: "http://this.test.com", metadataHash: Encoding.ASCII.GetBytes("16efaa3924a6fd9d3a4880099a4ac65d"))
            {
                Manager = acct2.Address.ToString()
            };

            // Specified address can change reserve, freeze, clawback, and manager
            // you can leave as default, by default the sender will be manager/reserve/freeze/clawback
            // the following code only set the freeze to acct1
            var tx = Utils.GetCreateAssetTransaction(ap, transParams, "asset tx message");

            // Sign the Transaction by sender
            SignedTransaction signedTx = acct1.SignTransaction(tx);
            // send the transaction to the network and
            // wait for the transaction to be confirmed
            long?assetID = 0;

            try
            {
                var id = Utils.SubmitTransaction(algodApiInstance, signedTx);
                Console.WriteLine("Transaction ID: " + id);
                Console.WriteLine(Utils.WaitTransactionToComplete(algodApiInstance, id.TxId));
                // Now that the transaction is confirmed we can get the assetID
                var ptx = algodApiInstance.PendingTransactionInformation(id.TxId);
                assetID = ptx.AssetIndex;
            }
            catch (Exception e)
            {
                Console.WriteLine(e.StackTrace);
                return;
            }
            Console.WriteLine("AssetID = " + assetID);
            // now the asset already created


            // Change Asset Configuration:
            // Next we will change the asset configuration
            // First we update standard Transaction parameters
            // To account for changes in the state of the blockchain
            transParams = algodApiInstance.TransactionParams();
            Asset ast = algodApiInstance.GetAssetByID(assetID);

            // Note that configuration changes must be done by
            // The manager account, which is currently acct2
            // Note in this transaction we are re-using the asset
            // creation parameters and only changing the manager
            // and transaction parameters like first and last round
            // now update the manager to acct1
            ast.Params.Manager = acct1.Address.ToString();
            tx = Utils.GetConfigAssetTransaction(acct2.Address, ast, transParams, "config trans");

            // The transaction must be signed by the current manager account
            // We are reusing the signedTx variable from the first transaction in the example
            signedTx = acct2.SignTransaction(tx);
            // send the transaction to the network and
            // wait for the transaction to be confirmed
            try
            {
                var id = Utils.SubmitTransaction(algodApiInstance, signedTx);
                Console.WriteLine("Transaction ID: " + id.TxId);
                Console.WriteLine(Utils.WaitTransactionToComplete(algodApiInstance, id.TxId));
            }
            catch (Exception e)
            {
                //e.printStackTrace();
                Console.WriteLine(e.Message);
                return;
            }

            // Next we will list the newly created asset
            // Get the asset information for the newly changed asset
            ast = algodApiInstance.GetAssetByID(assetID);
            //The manager should now be the same as the creator
            Console.WriteLine(ap);



            // Opt in to Receiving the Asset
            // Opting in to transact with the new asset
            // All accounts that want recieve the new asset
            // Have to opt in. To do this they send an asset transfer
            // of the new asset to themseleves with an ammount of 0
            // In this example we are setting up the 3rd recovered account to
            // receive the new asset
            // First we update standard Transaction parameters
            // To account for changes in the state of the blockchain
            transParams = algodApiInstance.TransactionParams();
            tx          = Utils.GetAssetOptingInTransaction(acct3.Address, assetID, transParams, "opt in transaction");

            // The transaction must be signed by the current manager account
            // We are reusing the signedTx variable from the first transaction in the example
            signedTx = acct3.SignTransaction(tx);
            // send the transaction to the network and
            // wait for the transaction to be confirmed
            Algorand.V2.Model.Account act = null;
            try
            {
                var id = Utils.SubmitTransaction(algodApiInstance, signedTx);
                Console.WriteLine("Transaction ID: " + id.TxId);
                Console.WriteLine(Utils.WaitTransactionToComplete(algodApiInstance, id.TxId));
                // We can now list the account information for acct3
                // and see that it can accept the new asseet
                act = algodApiInstance.AccountInformation(acct3.Address.ToString());
                Console.WriteLine(act);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                return;
            }

            // Transfer the Asset:
            // Now that account3 can recieve the new asset
            // we can tranfer assets in from the creator
            // to account3
            // First we update standard Transaction parameters
            // To account for changes in the state of the blockchain
            transParams = algodApiInstance.TransactionParams();
            // Next we set asset xfer specific parameters
            // We set the assetCloseTo to null so we do not close the asset out
            Address assetCloseTo = new Address();
            ulong   assetAmount  = 10;

            tx = Utils.GetTransferAssetTransaction(acct1.Address, acct3.Address, assetID, assetAmount, transParams, null, "transfer message");
            // The transaction must be signed by the sender account
            // We are reusing the signedTx variable from the first transaction in the example
            signedTx = acct1.SignTransaction(tx);
            // send the transaction to the network and
            // wait for the transaction to be confirmed
            try
            {
                var id = Utils.SubmitTransaction(algodApiInstance, signedTx);
                Console.WriteLine("Transaction ID: " + id.TxId);
                Console.WriteLine(Utils.WaitTransactionToComplete(algodApiInstance, id.TxId));
                // We can now list the account information for acct3
                // and see that it now has 5 of the new asset
                act = algodApiInstance.AccountInformation(acct3.Address.ToString());
                Console.WriteLine(act.Assets.Find(h => h.AssetId == assetID).Amount);
            }
            catch (Exception e)
            {
                //e.printStackTrace();
                Console.WriteLine(e.Message);
                return;
            }

            // Freeze the Asset:
            // The asset was created and configured to allow freezing an account
            // If the freeze address is blank, it will no longer be possible to do this.
            // In this example we will now freeze account3 from transacting with the
            // The newly created asset.
            // Thre freeze transaction is sent from the freeze acount
            // Which in this example is account2
            // First we update standard Transaction parameters
            // To account for changes in the state of the blockchain
            transParams = algodApiInstance.TransactionParams();
            // Next we set asset xfer specific parameters
            // The sender should be freeze account acct2
            // Theaccount to freeze should be set to acct3
            tx = Utils.GetFreezeAssetTransaction(acct2.Address, acct3.Address, assetID, true, transParams, "freeze transaction");
            // The transaction must be signed by the freeze account acct2
            // We are reusing the signedTx variable from the first transaction in the example
            signedTx = acct2.SignTransaction(tx);
            // send the transaction to the network and
            // wait for the transaction to be confirmed
            try
            {
                var id = Utils.SubmitTransaction(algodApiInstance, signedTx);
                Console.WriteLine("Transaction ID: " + id.TxId);
                Console.WriteLine(Utils.WaitTransactionToComplete(algodApiInstance, id.TxId));
                // We can now list the account information for acct3
                // and see that it now frozen
                // Note--currently no getter method for frozen state
                act = algodApiInstance.AccountInformation(acct3.Address.ToString());
                Console.WriteLine(act.Assets.Find(h => h.AssetId == assetID));
            }
            catch (Exception e)
            {
                //e.printStackTrace();
                Console.WriteLine(e.Message);
                return;
            }


            // Revoke the asset:
            // The asset was also created with the ability for it to be revoked by
            // clawbackaddress. If the asset was created or configured by the manager
            // not allow this by setting the clawbackaddress to a blank address
            // then this would not be possible.
            // We will now clawback the 10 assets in account3. Account2
            // is the clawbackaccount and must sign the transaction
            // The sender will be be the clawback adress.
            // the recipient will also be be the creator acct1 in this case
            // First we update standard Transaction parameters
            // To account for changes in the state of the blockchain
            transParams = algodApiInstance.TransactionParams();
            // Next we set asset xfer specific parameters
            assetAmount = 10;
            tx          = Utils.GetRevokeAssetTransaction(acct2.Address, acct3.Address, acct1.Address, assetID, assetAmount, transParams, "revoke transaction");
            // The transaction must be signed by the clawback account
            // We are reusing the signedTx variable from the first transaction in the example
            signedTx = acct2.SignTransaction(tx);
            // send the transaction to the network and
            // wait for the transaction to be confirmed
            try
            {
                var id = Utils.SubmitTransaction(algodApiInstance, signedTx);
                Console.WriteLine("Transaction ID: " + id);
                Console.WriteLine(Utils.WaitTransactionToComplete(algodApiInstance, id.TxId));
                // We can now list the account information for acct3
                // and see that it now has 0 of the new asset
                act = algodApiInstance.AccountInformation(acct3.Address.ToString());
                Console.WriteLine(act.Assets.Find(h => h.AssetId == assetID).Amount);
            }
            catch (Exception e)
            {
                //e.printStackTrace();
                Console.WriteLine(e.Message);
                return;
            }

            // Destroy the Asset:
            // All of the created assets should now be back in the creators
            // Account so we can delete the asset.
            // If this is not the case the asset deletion will fail
            // The address for the from field must be the creator
            // First we update standard Transaction parameters
            // To account for changes in the state of the blockchain
            transParams = algodApiInstance.TransactionParams();
            // Next we set asset xfer specific parameters
            // The manager must sign and submit the transaction
            // This is currently set to acct1
            tx = Utils.GetDestroyAssetTransaction(acct1.Address, assetID, transParams, "destroy transaction");
            // The transaction must be signed by the manager account
            // We are reusing the signedTx variable from the first transaction in the example
            signedTx = acct1.SignTransaction(tx);
            // send the transaction to the network and
            // wait for the transaction to be confirmed
            try
            {
                var id = Utils.SubmitTransaction(algodApiInstance, signedTx);
                Console.WriteLine("Transaction ID: " + id);
                //waitForTransactionToComplete(algodApiInstance, signedTx.transactionID);
                //Console.ReadKey();
                Console.WriteLine(Utils.WaitTransactionToComplete(algodApiInstance, id.TxId));
                // We can now list the account information for acct1
                // and see that the asset is no longer there
                act = algodApiInstance.AccountInformation(acct1.Address.ToString());
                //Console.WriteLine("Does AssetID: " + assetID + " exist? " +
                //    act.Thisassettotal.ContainsKey(assetID));
            }
            catch (Exception e)
            {
                //e.printStackTrace();
                Console.WriteLine(e.Message);
                return;
            }
            Console.WriteLine("You have successefully arrived the end of this test, please press and key to exist.");
            Console.ReadKey();
        }