diff --git a/challenge/index.ts b/challenge/index.ts index 73e28a5..f0d94c9 100644 --- a/challenge/index.ts +++ b/challenge/index.ts @@ -1,14 +1,14 @@ -import algosdk from "algosdk"; -import * as algokit from '@algorandfoundation/algokit-utils'; +import algosdk from "algosdk"; +import * as algokit from "@algorandfoundation/algokit-utils"; -const algodClient = algokit.getAlgoClient() +const algodClient = algokit.getAlgoClient(); // Retrieve 2 accounts from localnet kmd -const sender = await algokit.getLocalNetDispenserAccount(algodClient) +const sender = await algokit.getLocalNetDispenserAccount(algodClient); const receiver = await algokit.mnemonicAccountFromEnvironment( - {name: 'RECEIVER', fundWith: algokit.algos(100)}, - algodClient, - ) + { name: "RECEIVER", fundWith: algokit.algos(100) }, + algodClient +); /* TODO: edit code below @@ -23,17 +23,22 @@ When solved correctly, the console should print out the following: */ const suggestedParams = await algodClient.getTransactionParams().do(); const txn = algosdk.makePaymentTxnWithSuggestedParamsFromObject({ - from: sender.addr, - suggestedParams, - to: receiver.addr, - amount: 1000000, + from: sender.addr, + suggestedParams, + to: receiver.addr, + amount: 1000000, }); -await algodClient.sendRawTransaction(txn).do(); +const signedTxn = txn.signTxn(sender.sk); +// const signedTxn = algosdk.signTransaction(txn, sender.sk); + +await algodClient.sendRawTransaction(signedTxn).do(); const result = await algosdk.waitForConfirmation( - algodClient, - txn.txID().toString(), - 3 + algodClient, + txn.txID().toString(), + 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"]}` +);