From 62a809f3f5256a91f2807b239ff8fb4fe55f1705 Mon Sep 17 00:00:00 2001 From: John A Date: Tue, 19 Mar 2024 15:07:47 -0400 Subject: [PATCH] [Challenge Fix] 1. The problem was the txn was not signed by the sender. 2. Solved by signing txn and sending the signed txn to algodclient 3. Screenshot [] --- challenge/index.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/challenge/index.ts b/challenge/index.ts index 73e28a5..fa6964f 100644 --- a/challenge/index.ts +++ b/challenge/index.ts @@ -26,14 +26,22 @@ const txn = algosdk.makePaymentTxnWithSuggestedParamsFromObject({ from: sender.addr, suggestedParams, to: receiver.addr, - amount: 1000000, + amount: 1000000 }); +console.log(txn); -await algodClient.sendRawTransaction(txn).do(); +// Sign the transaction with sender's secret key +const signedTxn = txn.signTxn(sender.sk); + +// And send the now Signed transaction! +const txId = await algodClient.sendRawTransaction(signedTxn).do(); +console.log("Transaction ID: ", txId); + +// Wait for confirmation const result = await algosdk.waitForConfirmation( algodClient, - txn.txID().toString(), + txId.txId, 3 ); -console.log(`Payment of ${result.txn.txn.amt} microAlgos was sent to ${receiver.addr} at confirmed round ${result['confirmed-round']}`); \ No newline at end of file +console.log(`Payment of ${result.txn.txn.amt} microAlgos was sent to ${receiver.addr} at confirmed round ${result['confirmed-round']}`);