private async Task DisplayAccount(string accountname) { Account account; string mnemonic = ""; try { mnemonic = await SecureStorage.GetAsync(accountname); } catch (Exception ex) { Debug.WriteLine("Error: " + ex.Message); // Possible that device doesn't support secure storage on device. } //restore account from mnemonic account = new Account(mnemonic); // Algorand.V2.Model.Account accountinfo = algodApiInstance.AccountInformation(account.Address.ToString()); var accountinfo = await algodApiInstance.AccountInformationAsync(account.Address.ToString()); Debug.WriteLine("accountinfo: " + accountinfo); var htmlSource = new HtmlWebViewSource(); htmlSource.Html = @"<html><body><h3>" + " Address = " + account.Address.ToString() + "</h3>" + "<h3>" + "Account amount (micro algos) = " + accountinfo.Amount.ToString() + "</h3>" + "<p>Info = " + accountinfo.ToJson() + " </p>" + "</body></html>"; myWebView.Source = htmlSource; myWebViewp.Source = htmlSource; }
private async void ASA_Appearing(object sender, EventArgs e) { algodApiInstance = await helper.CreateApiInstance(); network = await helper.GetNetwork(); // restore accounts var accounts = await helper.RestoreAccounts(); account1 = accounts[0]; account2 = accounts[1]; account3 = accounts[2]; var nodetype = await SecureStorage.GetAsync(helper.StorageNodeType); NetworkLabel.Text = "Network: " + network + " " + nodetype; var lastASAbutton = await SecureStorage.GetAsync(helper.StorageLastASAButton); if (string.IsNullOrEmpty(lastASAbutton) || lastASAbutton == " ") { buttonstate("init"); } else { buttonstate(lastASAbutton); } // StorageLastASAButton }
private async void StatefulContracts_Appearing(object sender, EventArgs e) { client = await helper.CreateApiInstance(); network = await helper.GetNetwork(); // restore accounts var accounts = await helper.RestoreAccounts(); creator = accounts[0]; user = accounts[1]; Console.WriteLine("creator account: " + creator.Address); Console.WriteLine("user account: " + user.Address); var nodetype = await SecureStorage.GetAsync(helper.StorageNodeType); // NetworkLabel.Text = "Network: " + network + " " + nodetype; compileTealPrograms(); OptInBtn.IsEnabled = false; CallAppBtn.IsEnabled = false; ReadLocalStateBtn.IsEnabled = false; ReadGlobalStateBtn.IsEnabled = false; UpdateAppBtn.IsEnabled = false; CallUpdatedAppBtn.IsEnabled = false; ReadLocalStateAgainBtn.IsEnabled = false; CloseOutAppBtn.IsEnabled = false; DeleteAppBtn.IsEnabled = false; ClearAppCtn.IsEnabled = false; }
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))); }
public AccountViewModel() { Account account = new Account(); var address = account.Address.ToString(); var key = account.ToMnemonic(); this.AccountAddress = address; this.MnemonicKey = key; }
//Function public void PayPlayerwithAlgorandFunction() { Debug.Log("Starting Algorand Transaction."); string ALGOD_API_ADDR = "https://testnet-algorand.api.purestake.io/ps2"; if (ALGOD_API_ADDR.IndexOf("//") == -1) { ALGOD_API_ADDR = "http://" + ALGOD_API_ADDR; } string ALGOD_API_TOKEN = "Your API Key Here"; 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)) { Debug.LogError("The address " + DEST_ADDR + " is not valid!"); } Account src = new Account(SRC_ACCOUNT); Debug.Log("My account address is:" + src.Address.ToString()); AlgodApi algodApiInstance = new AlgodApi(ALGOD_API_ADDR, ALGOD_API_TOKEN); TransactionParametersResponse transParams; try { transParams = algodApiInstance.TransactionParams(); } catch (ApiException e) { Debug.LogError("Could not get params: " + e.Message); throw new Exception("Could not get params", e); } var amount = Utils.AlgosToMicroalgos(0.01); var tx = Utils.GetPaymentTransaction(src.Address, new Address(DEST_ADDR), amount, "pay message", transParams); var signedTx = src.SignTransaction(tx); Debug.Log("Signed transaction with txid: " + signedTx.transactionID); // send the transaction to the network try { var id = Utils.SubmitTransaction(algodApiInstance, signedTx); Debug.Log("Successfully sent tx with id: " + id.TxId); var resp = Utils.WaitTransactionToComplete(algodApiInstance, id.TxId); Debug.Log("Confirmed Round is: " + resp.ConfirmedRound); } catch (ApiException e) { // This is generally expected, but should give us an informative error message. Debug.LogError("Exception when calling algod#rawTransaction: " + e.Message); } Debug.Log("Algorand transaction to Player completed."); }
public static void Main(string[] args) { Account myAccount = new Account(); var myMnemonic = myAccount.ToMnemonic(); Console.WriteLine("Account 1 Address = " + myAccount.Address.ToString()); Console.WriteLine("Account 1 Mnemonic = " + myMnemonic.ToString()); Console.WriteLine("You have successefully arrived the end of this test, please press and key to exist."); Console.ReadKey(); }
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); //} }
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); } }
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"); }
private async void DryrunDebugging_Appearing(object sender, EventArgs e) { client = await helper.CreateApiInstance(); // restore accounts var accounts = await helper.RestoreAccounts(); account1 = accounts[0]; account2 = accounts[1]; Console.WriteLine("Account 1: " + account1.Address); Console.WriteLine("Account 2: " + account2.Address); }
void DryrunDebugging_Clicked(System.Object sender, System.EventArgs e) { //Account acct1 = new Account(SRC_ACCOUNT); //var acct2.Address = "QUDVUXBX4Q3Y2H5K2AG3QWEOMY374WO62YNJFFGUTMOJ7FB74CMBKY6LPQ"; // byte[] source = File.ReadAllBytes("V2\\contract\\sample.teal"); byte[] source = ExtractResource("algorandapp.Contract.sample.teal"); byte[] program = Convert.FromBase64String("ASABASI="); LogicsigSignature lsig = new LogicsigSignature(program, null); // sign the logic signaure with an account sk account1.SignLogicsig(lsig); // var algodApiInstance = new AlgodApi(ALGOD_API_ADDR, ALGOD_API_TOKEN); Algorand.V2.Model.TransactionParametersResponse transParams; try { transParams = client.TransactionParams(); } catch (ApiException err) { throw new Exception("Could not get params", err); } Transaction tx = Utils.GetPaymentTransaction(account1.Address, account2.Address, 1000000, "tx using in dryrun", transParams); try { //bypass verify for non-lsig SignedTransaction signedTx = Account.SignLogicsigTransaction(lsig, tx); // dryrun source var dryrunResponse = Utils.GetDryrunResponse(client, signedTx, source); Debug.WriteLine("Dryrun compiled repsonse : " + dryrunResponse.ToJson()); // pretty print DisplayInfo("Dryrun compiled repsonse : " + dryrunResponse.ToJson()); // dryrun logic sig transaction - omit source //var dryrunResponse2 = Utils.GetDryrunResponse(algodApiInstance, signedTx); //Debug.WriteLine("Dryrun source repsonse : " + dryrunResponse2.ToJson()); // pretty print //var id = Utils.SubmitTransaction(algodApiInstance, signedTx); //Console.WriteLine("Successfully sent tx logic sig tx id: " + id); } catch (ApiException err) { // This is generally expected, but should give us an informative error message. Debug.WriteLine("Exception when calling algod#rawTransaction: " + err.Message); } }
public async void CreateMultiSig_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]; List <Ed25519PublicKeyParameters> publickeys = new List <Ed25519PublicKeyParameters>(); publickeys.Add(account1.GetEd25519PublicKey()); publickeys.Add(account2.GetEd25519PublicKey()); publickeys.Add(account3.GetEd25519PublicKey()); MultisigAddress msig = new MultisigAddress(1, 2, publickeys); ulong? balance = await helper.GetAccountBalance(helper.StorageMultisig); var htmlSource = new HtmlWebViewSource(); htmlSource.Html = @"<html><body><h3>" + "Multisig Address " + msig.ToString() + "</h3>" + "<h3>" + "Multisig balance = " + balance.ToString() + "</h3>" + "</body></html>"; myWebView.Source = htmlSource; CreateMultiSig.Text = "Multisig created"; CreateMultiSig.IsEnabled = false; GetMultiSig.IsVisible = true; myWebViewp.Source = htmlSource; CreateMultiSigp.Text = "Multisig created"; CreateMultiSigp.IsEnabled = false; GetMultiSigp.IsVisible = true; await SecureStorage.SetAsync(helper.StorageMultisig, msig.ToString()); buttonstate(); // OpenDispenser(helper, network, msig.ToString()); }
public static void FundMethod(string key, string receiver, int amount, string senderAddr) { string ALGOD_API_ADDR = "https://testnet-algorand.api.purestake.io/ps2"; //find in algod.net string ALGOD_API_TOKEN = "B3SU4KcVKi94Jap2VXkK83xx38bsv95K5UZm2lab"; //find in algod.token string SRC_ACCOUNT = key; string DEST_ADDR = receiver; Account src = new Account(SRC_ACCOUNT); AlgodApi algodApiInstance = new AlgodApi(ALGOD_API_ADDR, ALGOD_API_TOKEN); try { var trans = algodApiInstance.TransactionParams(); } 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 amountsent = Utils.AlgosToMicroalgos(amount); var tx = Utils.GetPaymentTransaction(src.Address, new Address(DEST_ADDR), amountsent, "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); } }
static void OptIn(AlgodApi client, Account sender, long?applicationId) { try { var transParams = client.TransactionParams(); var tx = Utils.GetApplicationOptinTransaction(sender.Address, (ulong?)applicationId, transParams); var signedTx = sender.SignTransaction(tx); var id = Utils.SubmitTransaction(client, signedTx); Console.WriteLine("Successfully sent tx with id: " + id.TxId); var resp = Utils.WaitTransactionToComplete(client, id.TxId); Console.WriteLine("Optin to Application ID: " + (resp.Txn as JObject)["txn"]["apid"]); } catch (ApiException e) { Console.WriteLine("Exception when calling create application: " + e.Message); } }
private static void UpdateApp(AlgodApi client, Account creator, long?appid, TEALProgram approvalProgram, TEALProgram clearProgram) { try { var transParams = client.TransactionParams(); var tx = Utils.GetApplicationUpdateTransaction(creator.Address, (ulong?)appid, approvalProgram, clearProgram, transParams); var signedTx = creator.SignTransaction(tx); var id = Utils.SubmitTransaction(client, signedTx); Console.WriteLine("Successfully sent tx with id: " + id.TxId); var resp = Utils.WaitTransactionToComplete(client, id.TxId); Console.WriteLine("Updated the application ID is: " + appid); } catch (ApiException e) { Console.WriteLine("Exception when calling create application: " + e.Message); } }
public static void CloseOutApp(AlgodApi client, Account sender, ulong?appId) { try { var transParams = client.TransactionParams(); var tx = Utils.GetApplicationCloseTransaction(sender.Address, appId, transParams); var signedTx = sender.SignTransaction(tx); var id = Utils.SubmitTransaction(client, signedTx); Console.WriteLine("Successfully sent tx with id: " + id.TxId); var resp = Utils.WaitTransactionToComplete(client, id.TxId); Console.WriteLine("Close out Application ID is: " + appId); } catch (ApiException e) { Console.WriteLine("Exception when calling create application: " + e.Message); } }
private async void Rekey_Appearing(object sender, EventArgs e) { client = await helper.CreateApiInstance(); // network = await helper.GetNetwork(); // restore accounts var accounts = await helper.RestoreAccounts(); account1 = accounts[0]; account2 = accounts[1]; account3 = accounts[2]; Console.WriteLine("Account 1 = " + account1.Address); Console.WriteLine("Account 2 = " + account2.Address); Console.WriteLine("Account 3 = " + account3.Address); }
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); } } }
private async void AtomicTransfers_Appearing(object sender, EventArgs e) { algodApiInstance = await helper.CreateApiInstance(); network = await helper.GetNetwork(); // restore accounts var accounts = await helper.RestoreAccounts(); account1 = accounts[0]; account2 = accounts[1]; account3 = accounts[2]; nodetype = await SecureStorage.GetAsync(helper.StorageNodeType); NetworkLabel.Text = "Network: " + network + " " + nodetype; buttonstate(); }
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(); }
void CallApp(AlgodApi client, Account sender, long?applicationId, List <byte[]> args) { try { var transParams = client.TransactionParams(); var tx = Utils.GetApplicationCallTransaction(sender.Address, (ulong?)applicationId, transParams, args); var signedTx = sender.SignTransaction(tx); Console.WriteLine("Signed transaction with txid: " + signedTx.transactionID); 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); Console.WriteLine(string.Format("Call Application({0}) success.", (resp.Txn as JObject)["txn"]["apid"])); DisplayInfo(string.Format("Call Application({0}) success.", (resp.Txn as JObject)["txn"]["apid"])); //System.out.println("Called app-id: " + pTrx.txn.tx.applicationId); if (resp.GlobalStateDelta != null) { var outStr = " Global state: "; foreach (var v in resp.GlobalStateDelta) { outStr += v.ToString(); } Console.WriteLine(outStr); } if (resp.LocalStateDelta != null) { var outStr = " Local state: "; foreach (var v in resp.LocalStateDelta) { outStr += v.ToString(); } Console.WriteLine(outStr); } } catch (ApiException e) { Console.WriteLine("Exception when calling create application: " + e.Message); } }
void ClearApp(AlgodApi client, Account sender, long?applicationId) { try { var transParams = client.TransactionParams(); var tx = Utils.GetApplicationClearTransaction(sender.Address, (ulong?)applicationId, transParams); var signedTx = sender.SignTransaction(tx); Console.WriteLine("Signed transaction with txid: " + signedTx.transactionID); var id = Utils.SubmitTransaction(client, signedTx); Console.WriteLine("Successfully sent tx with id: " + id.TxId); var resp = Utils.WaitTransactionToComplete(client, id.TxId); Console.WriteLine("Success cleared the application " + (resp.Txn as JObject)["txn"]["apid"]); DisplayInfo("Successfully Cleared out with tx id: " + id.TxId); } catch (ApiException e) { Console.WriteLine("Exception when calling create application: " + e.Message); } }
private async Task PromptToAddFunds(string network, string accountname) { if (String.IsNullOrEmpty(accountname) || accountname == " ") { } else { ulong?amount = await helper.GetAccountBalance(accountname); if (amount < helper.MIN_ACCOUNT_BALANCE) { // diplay Account1 on network is belown min balance. // would you like to dispense fund to it? string action = await DisplayActionSheet(accountname + " on " + network + " is below min balance would you like to dispense funds to it?", "Cancel", null, "Yes", "No"); Debug.WriteLine("Action: " + action); string myaddress = ""; if (action == "Yes") { if (accountname != helper.StorageMultisig) { var mnemonic = await SecureStorage.GetAsync(accountname); Account myaccount = new Account(mnemonic); myaddress = myaccount.Address.ToString(); await Clipboard.SetTextAsync(myaddress); } else { // get multisig addr myaddress = await SecureStorage.GetAsync(accountname); await Clipboard.SetTextAsync(myaddress); } OpenDispenser(helper, network, myaddress); } } } }
static long?CreateApp(AlgodApi client, Account creator, TEALProgram approvalProgram, TEALProgram clearProgram, ulong?globalInts, ulong?globalBytes, ulong?localInts, ulong?localBytes) { try { var transParams = client.TransactionParams(); var tx = Utils.GetApplicationCreateTransaction(creator.Address, approvalProgram, clearProgram, new StateSchema(globalInts, globalBytes), new StateSchema(localInts, localBytes), transParams); var signedTx = creator.SignTransaction(tx); var id = Utils.SubmitTransaction(client, signedTx); Console.WriteLine("Successfully sent tx with id: " + id.TxId); var resp = Utils.WaitTransactionToComplete(client, id.TxId); Console.WriteLine("Application ID is: " + resp.ApplicationIndex); return(resp.ApplicationIndex); } catch (ApiException e) { Console.WriteLine("Exception when calling create application: " + e.Message); return(null); } }
void CloseOutApp(AlgodApi client, Account sender, ulong appId) { try { var transParams = client.TransactionParams(); var tx = Utils.GetApplicationCloseTransaction(sender.Address, (ulong?)appId, transParams); var signedTx = sender.SignTransaction(tx); Console.WriteLine("Signed transaction with txid: " + signedTx.transactionID); 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 Round is: " + resp.ConfirmedRound); Console.WriteLine("Application ID is: " + appId); DisplayInfo("Successfully Closed out with tx id: " + id.TxId); } catch (ApiException e) { Console.WriteLine("Exception when calling create application: " + e.Message); } }
public static void Main(params string[] args) { if (args == null) { Console.WriteLine("args is null"); // Check for null array } else { args = new string[2]; args[0] = "http://localhost:4001"; args[1] = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; } Account myAccount = new Account(); var myMnemonic = myAccount.ToMnemonic(); Console.WriteLine("Account 1 Address = " + myAccount.Address.ToString()); Console.WriteLine("Account 1 Mnemonic = " + myMnemonic.ToString()); Account myAccount2 = new Account(); var myMnemonic2 = myAccount2.ToMnemonic(); Console.WriteLine("Account 2 Address = " + myAccount2.Address.ToString()); Console.WriteLine("Account 2 Mnemonic = " + myMnemonic2.ToString()); Account myAccount3 = new Account(); var myMnemonic3 = myAccount3.ToMnemonic(); Console.WriteLine("Account 3 Address = " + myAccount3.Address.ToString()); Console.WriteLine("Account 3 Mnemonic = " + myMnemonic3.ToString()); Console.WriteLine("You have successefully created 3 accounts."); Console.WriteLine("Dispense funds to these 3 accounts "); Console.WriteLine("see TestNet dispenser https://bank.testnet.algorand.network/"); }
public static void Main(string[] args) { // 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); try { Supply 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); } TransactionParams transParams = null; 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); //Transaction tx = new Transaction(src.Address, new Address(DEST_ADDR), amount, firstRound, lastRound, genesisID, genesisHash); 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); } 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(); }