Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion challenge/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"name": "algorand-puzzle-1",
"version": "1.0.0",
"scripts": {
"start": "tsx -r dotenv/config index.ts"
"start": "tsx -r dotenv/config challenge/index.ts"
},
"module": "index.ts",
"type": "module",
Expand All @@ -15,3 +16,6 @@
"tsx": "^4.7.0"
}
}



33 changes: 33 additions & 0 deletions index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import algosdk from "algosdk";
import * as algokit from "@algorandfoundation/algokit-utils";

async function main() {
const algodClient = algokit.getAlgoClient();

// Retrieve 2 accounts from localnet kmd
const sender = await algokit.getLocalNetDispenserAccount(algodClient);
const receiver = await algokit.mnemonicAccountFromEnvironment(
{ name: "RECEIVER", fundWith: algokit.algos(100) },
algodClient
);

const suggestedParams = await algodClient.getTransactionParams().do();
const txn = algosdk.makePaymentTxnWithSuggestedParamsFromObject({
from: sender.addr,
suggestedParams,
to: receiver.addr,
amount: 1000000,
});

const signedTxn = txn.signTxn(sender.sk);
const { txId } = await algodClient.sendRawTransaction(signedTxn).do();
const result = await algosdk.waitForConfirmation(algodClient, txId, 3);

console.log(
`Payment of ${result.txn.txn.amt} microAlgos was sent to ${receiver.addr} at confirmed round ${result["confirmed-round"]}`
);
}

main().catch((error) => {
console.error("Error in main function:", error);
});