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 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); } }
static DryrunRequest DryrunDrr(SignedTransaction signTx, TEALProgram program, Algorand.V2.Model.Account cr, Algorand.V2.Model.Account usr) { var sources = new List <DryrunSource>(); if (program != null) { sources.Add(new DryrunSource("approv", Convert.ToBase64String(program.Bytes), 0)); } var drr = new DryrunRequest(new List <SignedTransaction>() { signTx }, new List <Algorand.V2.Model.Account>() { cr, usr }, sources: sources); return(drr); }
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); } }