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); } }
void ASCAccountDelegation_Clicked(System.Object sender, System.EventArgs e) { ASCAccountDelegation.Opacity = .2; StackASCAccountDelegation.IsEnabled = false; ASCAccountDelegation.IsEnabled = false; Algorand.V2.Model.TransactionParametersResponse transParams = null; try { transParams = algodApiInstance.TransactionParams(); } catch (ApiException err) { throw new Exception("Could not get params", err); } // format and send logic sig // int 1, returns true // byte[] program = { 0x01, 0x20, 0x01, 0x01, 0x22 }; // int 0, returns false, so rawTransaction will fail below // byte[] program = { 0x01, 0x20, 0x01, 0x00, 0x22 }; byte[] program = { 0x01, 0x20, 0x01, 0x01, 0x22 }; LogicsigSignature lsig = new LogicsigSignature(program, null); // sign the logic signature with an account sk account1.SignLogicsig(lsig); Console.WriteLine("Escrow address: " + lsig.ToAddress().ToString()); Transaction tx = Utils.GetPaymentTransaction(new Address(account1.Address.ToString()), new Address(account2.Address.ToString()), 1000000, "draw algo with logic signature", transParams); // Algorand.Transaction tx = Utils.GetLogicSignatureTransaction(account1.Address, account2.Address, transParams, "logic sig message"); try { SignedTransaction stx = Account.SignLogicsigTransaction(lsig, tx); byte[] encodedTxBytes = Encoder.EncodeToMsgPack(stx); // int 0 is the teal program, which returns false, // so rawTransaction will fail below var id = Utils.SubmitTransaction(algodApiInstance, stx); var wait = Utils.WaitTransactionToComplete(algodApiInstance, id.TxId); Console.WriteLine(wait); Console.WriteLine("Successfully sent tx logic sig tx id: " + id); var htmlSource = new HtmlWebViewSource(); htmlSource.Html = @"<html><body>" + "<h3>" + "Successfully sent tx logic sig tx: " + wait + "</h3>" + "</body></html>"; myWebView.Source = htmlSource; ASCAccountDelegation.IsEnabled = true; } catch (ApiException err) { // This is generally expected, but should give us an informative error message. Console.WriteLine("Exception when calling algod#rawTransaction: " + err.Message); var htmlSource = new HtmlWebViewSource(); htmlSource.Html = @"<html><body><h3> Expected error: Exception when calling algod#rawTransaction: " + err.Message + "</h3>" + "</body></html>"; myWebView.Source = htmlSource; ASCAccountDelegation.IsEnabled = true; } ASCAccountDelegation.Opacity = 1; StackASCAccountDelegation.IsEnabled = true; }