From 4b20cff3e36150b9dc6c0f5ef8d538f825063439 Mon Sep 17 00:00:00 2001 From: SJ <127313669+Ganainmtech@users.noreply.github.com> Date: Tue, 30 Apr 2024 20:01:24 +0100 Subject: [PATCH 01/28] Update post-create.sh --- post-create.sh | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/post-create.sh b/post-create.sh index f4bebbd..9d0e31a 100644 --- a/post-create.sh +++ b/post-create.sh @@ -1,12 +1,17 @@ #!/bin/bash -echo "running" +echo "Running setup script..." + pipx install poetry pip install typing-extensions poetry init -n -poetry add git+https://github.com/algorandfoundation/algokit-utils-py#feat/algorand_client -poetry env use python3.12 -poetry shell +git clone https://github.com/algorandfoundation/algokit-utils-py.git +cd algokit-utils-py +pip install . +cd .. + +echo "Setup completed." + From 1c5e87ce7214e4f0617ac7e641d2b8b96e10fa30 Mon Sep 17 00:00:00 2001 From: SJ <127313669+Ganainmtech@users.noreply.github.com> Date: Fri, 3 May 2024 20:34:47 +0100 Subject: [PATCH 02/28] Rename post-create.sh to algorand_setup.sh --- post-create.sh => algorand_setup.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename post-create.sh => algorand_setup.sh (100%) diff --git a/post-create.sh b/algorand_setup.sh similarity index 100% rename from post-create.sh rename to algorand_setup.sh From 906e3e42d9de5340735b28aac318262fb0b4c686 Mon Sep 17 00:00:00 2001 From: SJ <127313669+Ganainmtech@users.noreply.github.com> Date: Wed, 5 Jun 2024 09:37:21 +0100 Subject: [PATCH 03/28] Update README.md --- README.md | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c4caaa1..ff551da 100644 --- a/README.md +++ b/README.md @@ -1 +1,32 @@ -# codespace_algorand \ No newline at end of file +# The all in one Algorand Codespace +The all in one Algorand Codespace allows you to set up a virtual enviroment with the latest developer tooling to interact with the Algorand blockchain. This includes SDKs like Python to code without smart contracts, and the algokit experience for when you want to practise smart contracts and galore! + +# How to start a codespace? +Above the files in the top right corner you will see a green code button +Once pressed you can start a new codespace by clicking the "Create codespace on main" + +# How do I enter an old codespace? +Once you are in the codespace menu (by clicking the green code button) you will see any old code spaces that are still available underneath the create codespace on main button. + +# How to use the all in one Algorand Codespace? +1: Once your codespace is fully loaded in run the commmand 'sh algorand_setup.sh' in your terminal +2: After this you can begin coding in your main.py file to practise interacting with the blockchain (no smart contract needed!) +3: To get started with smart contracts/dapps run the command 'algokit init' to initilise your Algorand project. + +And thats it! - the rest is your playground. + +# Enjoying the Blockchain Developer experience on Algorand? +Then its time to move away from virtual codespace enviroments to local enviroments. Please check out the Algorand Developer Docs to find out how to set up your local enviroment (Its easy and takes less then 10 minutes!) Link: https://developer.algorand.org/docs/get-started/algokit/ + +# Prerequisites needed for algokit +Python 3.12 or higher +PipX +Git +Docker +VSCode (recommended) + +Join the algodevs community and work with thousands of developers just like you! +Algorand Discord: https://discord.com/invite/algorand +Algodevs X(twitter): https://x.com/algodevs + + From fd28b8460169485d74f1d3cd26a5e95f5a46dd64 Mon Sep 17 00:00:00 2001 From: SJ <127313669+Ganainmtech@users.noreply.github.com> Date: Wed, 5 Jun 2024 09:38:44 +0100 Subject: [PATCH 04/28] Update README.md --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index ff551da..fb0b5da 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,7 @@ The all in one Algorand Codespace allows you to set up a virtual enviroment with # How to start a codespace? Above the files in the top right corner you will see a green code button + Once pressed you can start a new codespace by clicking the "Create codespace on main" # How do I enter an old codespace? @@ -10,7 +11,9 @@ Once you are in the codespace menu (by clicking the green code button) you will # How to use the all in one Algorand Codespace? 1: Once your codespace is fully loaded in run the commmand 'sh algorand_setup.sh' in your terminal + 2: After this you can begin coding in your main.py file to practise interacting with the blockchain (no smart contract needed!) + 3: To get started with smart contracts/dapps run the command 'algokit init' to initilise your Algorand project. And thats it! - the rest is your playground. From 197a105fa3d914c2116f43d4604f2ce0733c0d82 Mon Sep 17 00:00:00 2001 From: SJ <127313669+Ganainmtech@users.noreply.github.com> Date: Wed, 5 Jun 2024 09:44:38 +0100 Subject: [PATCH 05/28] Update README.md --- README.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index fb0b5da..e003167 100644 --- a/README.md +++ b/README.md @@ -19,17 +19,25 @@ Once you are in the codespace menu (by clicking the green code button) you will And thats it! - the rest is your playground. # Enjoying the Blockchain Developer experience on Algorand? -Then its time to move away from virtual codespace enviroments to local enviroments. Please check out the Algorand Developer Docs to find out how to set up your local enviroment (Its easy and takes less then 10 minutes!) Link: https://developer.algorand.org/docs/get-started/algokit/ +Then its time to move away from virtual codespace enviroments to local enviroments. Please check out the Algorand Developer Docs to find out how to set up your local enviroment (Its easy and takes less then 10 minutes!) + +Link: https://developer.algorand.org/docs/get-started/algokit/ # Prerequisites needed for algokit Python 3.12 or higher + PipX + Git + Docker + VSCode (recommended) Join the algodevs community and work with thousands of developers just like you! + Algorand Discord: https://discord.com/invite/algorand + Algodevs X(twitter): https://x.com/algodevs From 61734477c37ce197c02bbf178e58f52c944974e5 Mon Sep 17 00:00:00 2001 From: SJ <127313669+Ganainmtech@users.noreply.github.com> Date: Wed, 5 Jun 2024 09:45:08 +0100 Subject: [PATCH 06/28] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e003167..958864b 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ Docker VSCode (recommended) -Join the algodevs community and work with thousands of developers just like you! +# Join the algodevs community and work with thousands of developers just like you! Algorand Discord: https://discord.com/invite/algorand From f87eec9dc024d0283f466d64c63a2fdd45d92e28 Mon Sep 17 00:00:00 2001 From: SJ <127313669+Ganainmtech@users.noreply.github.com> Date: Wed, 5 Jun 2024 09:45:41 +0100 Subject: [PATCH 07/28] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 958864b..859108f 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # The all in one Algorand Codespace -The all in one Algorand Codespace allows you to set up a virtual enviroment with the latest developer tooling to interact with the Algorand blockchain. This includes SDKs like Python to code without smart contracts, and the algokit experience for when you want to practise smart contracts and galore! +The all in one Algorand Codespace allows you to set up a virtual enviroment with the latest developer tooling to interact with the Algorand blockchain. This includes SDKs like Python to code without smart contracts, and the algokit experience for when you want to practise smart contracts and dApps! # How to start a codespace? Above the files in the top right corner you will see a green code button From 73a5642b1da8ab1c7bd99aaba9e3ce634b52026f Mon Sep 17 00:00:00 2001 From: SJ <127313669+Ganainmtech@users.noreply.github.com> Date: Wed, 5 Jun 2024 11:37:40 +0100 Subject: [PATCH 08/28] Update README.md --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 859108f..75ad85f 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,10 @@ Once you are in the codespace menu (by clicking the green code button) you will And thats it! - the rest is your playground. +Not sure where to start? This codespace is intended for beginner workshops you can find the code we run through in these workshops here: +[https://github.com/Ganainmtech/python_algokit_demo](https://github.com/Ganainmtech/python_algokit_demo/blob/main/main.py) + + # Enjoying the Blockchain Developer experience on Algorand? Then its time to move away from virtual codespace enviroments to local enviroments. Please check out the Algorand Developer Docs to find out how to set up your local enviroment (Its easy and takes less then 10 minutes!) From f7036872baf017bd6f714178dd6570a9096442ff Mon Sep 17 00:00:00 2001 From: SJ <127313669+Ganainmtech@users.noreply.github.com> Date: Wed, 5 Jun 2024 14:24:33 +0100 Subject: [PATCH 09/28] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 75ad85f..c36200e 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ Once you are in the codespace menu (by clicking the green code button) you will 2: After this you can begin coding in your main.py file to practise interacting with the blockchain (no smart contract needed!) -3: To get started with smart contracts/dapps run the command 'algokit init' to initilise your Algorand project. +3: To get started with smart contracts/dapps run the command 'algokit init' to initialise your Algorand project. And thats it! - the rest is your playground. From f5e25438bb8d9ce56b17bd4427bf69328a33fba4 Mon Sep 17 00:00:00 2001 From: SJ <127313669+Ganainmtech@users.noreply.github.com> Date: Fri, 14 Jun 2024 19:11:52 +0100 Subject: [PATCH 10/28] Update README.md --- README.md | 30 +++++++----------------------- 1 file changed, 7 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index c36200e..8cbb98e 100644 --- a/README.md +++ b/README.md @@ -1,43 +1,27 @@ # The all in one Algorand Codespace The all in one Algorand Codespace allows you to set up a virtual enviroment with the latest developer tooling to interact with the Algorand blockchain. This includes SDKs like Python to code without smart contracts, and the algokit experience for when you want to practise smart contracts and dApps! -# How to start a codespace? -Above the files in the top right corner you will see a green code button - -Once pressed you can start a new codespace by clicking the "Create codespace on main" +# How to use the all in one Algorand Codespace? +1. Above the files in the top right corner click the green code button. -# How do I enter an old codespace? -Once you are in the codespace menu (by clicking the green code button) you will see any old code spaces that are still available underneath the create codespace on main button. +2. Next click the "Create codespace on main". -# How to use the all in one Algorand Codespace? -1: Once your codespace is fully loaded in run the commmand 'sh algorand_setup.sh' in your terminal +3. Once your codespace is fully loaded in run the commmand 'sh algorand_setup.sh' in your terminal. -2: After this you can begin coding in your main.py file to practise interacting with the blockchain (no smart contract needed!) +4. After this you can begin coding in your main.py file to practise interacting with the blockchain. (no smart contract needed!) -3: To get started with smart contracts/dapps run the command 'algokit init' to initialise your Algorand project. +5. To get started with smart contracts/dapps run the command 'algokit init' to initialise your Algorand project. And thats it! - the rest is your playground. -Not sure where to start? This codespace is intended for beginner workshops you can find the code we run through in these workshops here: +Not sure where to start? This codespace is intended for beginner workshops you can find the code we run through in those workshops here: [https://github.com/Ganainmtech/python_algokit_demo](https://github.com/Ganainmtech/python_algokit_demo/blob/main/main.py) - # Enjoying the Blockchain Developer experience on Algorand? Then its time to move away from virtual codespace enviroments to local enviroments. Please check out the Algorand Developer Docs to find out how to set up your local enviroment (Its easy and takes less then 10 minutes!) Link: https://developer.algorand.org/docs/get-started/algokit/ -# Prerequisites needed for algokit -Python 3.12 or higher - -PipX - -Git - -Docker - -VSCode (recommended) - # Join the algodevs community and work with thousands of developers just like you! Algorand Discord: https://discord.com/invite/algorand From c9795615498eb63f231fb5a7c5dba210208515a2 Mon Sep 17 00:00:00 2001 From: "Sara Jane (SJ)" <127313669+Ganainmtech@users.noreply.github.com> Date: Wed, 24 Jul 2024 10:31:51 +0100 Subject: [PATCH 11/28] Update README.md Added short video showcase --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 8cbb98e..679ca72 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # The all in one Algorand Codespace -The all in one Algorand Codespace allows you to set up a virtual enviroment with the latest developer tooling to interact with the Algorand blockchain. This includes SDKs like Python to code without smart contracts, and the algokit experience for when you want to practise smart contracts and dApps! +The all in one Algorand Codespace allows you to set up a virtual enviroment with the latest developer tooling to interact with the Algorand blockchain. This includes languages like Python to code without smart contracts, and the algokit experience for when you want to practise smart contracts and dApps! + +https://github.com/user-attachments/assets/57a20768-8292-4cff-a764-cb8173b89ae4 # How to use the all in one Algorand Codespace? 1. Above the files in the top right corner click the green code button. From fa3e5800b222bdba0615ad2452979d984734451b Mon Sep 17 00:00:00 2001 From: "Sara Jane (SJ)" <127313669+Ganainmtech@users.noreply.github.com> Date: Wed, 24 Jul 2024 12:23:41 +0100 Subject: [PATCH 12/28] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 679ca72..caa1d2d 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ Not sure where to start? This codespace is intended for beginner workshops you c # Enjoying the Blockchain Developer experience on Algorand? Then its time to move away from virtual codespace enviroments to local enviroments. Please check out the Algorand Developer Docs to find out how to set up your local enviroment (Its easy and takes less then 10 minutes!) -Link: https://developer.algorand.org/docs/get-started/algokit/ +Link: [Get started with AlgoKit!](https://developer.algorand.org/algokit/?utm_source=af_employee&utm_medium=social&utm_campaign=algokit_sarajane&utm_content=download&utm_term=EME) # Join the algodevs community and work with thousands of developers just like you! From d9d0b6bf6f38bbd390bfb65a35272f2d7117de08 Mon Sep 17 00:00:00 2001 From: "Sara Jane (SJ)" <127313669+Ganainmtech@users.noreply.github.com> Date: Tue, 13 Aug 2024 10:55:22 +0000 Subject: [PATCH 13/28] Adding frontend to algorand scripts --- .sesskey | 1 + __pycache__/main.cpython-310.pyc | Bin 0 -> 2116 bytes algokit-utils-py | 1 + algorand_setup.sh | 18 ------ data/algorand.db | Bin 0 -> 4096 bytes main.py | 104 +++++++++++++++++++++++++++++++ pyproject.toml | 14 +++++ setup.sh | 21 +++++++ 8 files changed, 141 insertions(+), 18 deletions(-) create mode 100644 .sesskey create mode 100644 __pycache__/main.cpython-310.pyc create mode 160000 algokit-utils-py delete mode 100644 algorand_setup.sh create mode 100644 data/algorand.db create mode 100644 pyproject.toml create mode 100644 setup.sh diff --git a/.sesskey b/.sesskey new file mode 100644 index 0000000..43b1921 --- /dev/null +++ b/.sesskey @@ -0,0 +1 @@ +18072c21-15b1-4d85-91ce-5abc0895e24d \ No newline at end of file diff --git a/__pycache__/main.cpython-310.pyc b/__pycache__/main.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..f18d6f5fc400eefeec337b1c5a2a70252ffc495f GIT binary patch literal 2116 zcmZ`)OK%)S5T1U_W5>H|J3$bWC@c>}8l-qRaX?XsaTJsTCQ5ujtw=+Ax;GhnUh3)1 zW3`r$oD-6-2nmp!V}1kwfgjLUF61W=k(lb1nK4vjnl1m~yKq3;IXWju~-T6EgOK#p1UD1QD`f^$H_psWO;qHoz#j;ottA_-< zlY4F?=U&2nyaXBaY2usyM)9Clyb_y5E-P(TH`-R}O(nUOcevtZYtB2 zJN)TfU2*H*Hu`oovutI=9x;C`4k3(9813gEG+-gHAO~ch2s-tC@q|A`AcH9e8U7aT zQ;nts2DR}X;sbooOX96bcXqGAcD*O7S9GYx)uhKWo!8aXow3$+HCc-X@LX%IyREev zYzU!b+kP>aT)sAJt}mAF%1q{ugFu*ucU75^1o=lu3Md zTn+AJDsQxkz`qNZb#~;aRuY0p2n!!RNt?RWtfRSl;J|UV_Aze^g?**6RhIZH*v@q! zh3dkT(Oa-${I69#ZdmY@qu!x-N?2?R0iW-I()K}6+(i@xfK>2?9xH1<0|)|x%~l7< zWl*$t;O%>mhXBl)2NF9;*1Q9#ri5;(9_&)qw^{~~VABVN$IS_Aj*0}i$ltyjwSn7X zS_&e-7m!*5<;;}=Fr0Ao2TZhggr38trrs_-BA~(LK%<~x(EOu7hf}m0P4RAI%j}Rm zN67B>k2*SbR>!N=76UjApQC*;B_dq&M6~AZLs`zf`e(fQ|M9w{yHl`2sY0QioYm8P z=Y6&UP3n-kHGAsJ*8SB&*xSl~_~~aaAtq>DTAOH5HYVU@J+5^A7XijYo5&+xGIDF< zn883Efv&x=lFmAgnu!Yu+ntk}OPh18t;Iwym=M zY?q$*XJs=u30SnKeD$H-70%lei{M0^>L=AK7#Ei9KeOz#MWZf&_!vg}J%|X!C?2bIFfBPtuTM#Wg!22J1Ok?XIcNvvv2& zZ+zeiiavxYF;FW?C#!5_#9RGPm&LkOc+;?tY@B<*`B>*gyS^heUtfftX6{eTF{3Pg z4jhNF!_I``M|oDO%9SaLtj`pj8e%kb)DrkqG>p0Q1vKHe) fUbo$(wP_l8mrxW&xE}{NMnMpxh(=$&117U}9o$P*7lCU|@t|AVoG{WYDv}$qUjhK(-m98b?E5 nGz3ONU^E0qLtr!nMnhmU1V%$(Gz3ONU^E0qLtr!nC=3Ar-H8V& literal 0 HcmV?d00001 diff --git a/main.py b/main.py index 8b13789..8a7c086 100644 --- a/main.py +++ b/main.py @@ -1 +1,105 @@ +from fasthtml.fastapp import * +from algokit_utils.beta.algorand_client import ( + AlgorandClient, + AssetCreateParams, + AssetTransferParams, + PayParams, + AssetOptInParams, +) +import uvicorn +import logging +# Setup basic logging +logging.basicConfig(level=logging.INFO) + +def render(creator_address, receiver_address, asset_id): + result = f""" + \nCreator Address: {creator_address} + \nReceiver Address: {receiver_address} + \nAsset ID: {asset_id} + """ + return Div(result, id='result') + +# Unpack only the necessary values from fast_app +app, rt = fast_app('data/algorand.db') + +@rt("/") +async def get(request): + new_frm = Form(Group(Button("Run Script", hx_post="/run-script", target_id="result", hx_swap="innerHTML")), + id='form') + # Add a result div here + result_placeholder = Div(id='result') + return Titled('Algorand Token Creation and Transfer', new_frm, result_placeholder) + + +@rt("/run-script") +async def post(request): + logging.info("Form submitted! Running Algorand setup...") + result = setup_algorand() + return render(result['creator_address'], result['receiver_address'], result['asset_id']) + +def setup_algorand(): + algorand = AlgorandClient.default_local_net() + dispenser = algorand.account.dispenser() + + # Create and fund a new account (creator) + creator = algorand.account.random() + algorand.send.payment( + PayParams( + sender=dispenser.address, + receiver=creator.address, + amount=10_000_000 # Fund with 10 Algos + ) + ) + + # Create a new Algorand Standard Asset (ASA) + sent_txn = algorand.send.asset_create( + AssetCreateParams( + sender=creator.address, + total=1000, + asset_name="algofam", + unit_name="FAM", + manager=creator.address, + clawback=creator.address, + freeze=creator.address + ) + ) + + asset_id = sent_txn["confirmation"]["asset-index"] + + # Create and fund another new account (receiver) + receiver = algorand.account.random() + algorand.send.payment( + PayParams( + sender=dispenser.address, + receiver=receiver.address, + amount=10_000_000 # Fund with 10 Algos + ) + ) + + # Opt-in the receiver account to the newly created ASA + algorand.send.asset_opt_in( + AssetOptInParams( + sender=receiver.address, + asset_id=asset_id + ) + ) + + # Transfer 10 units of the ASA from creator to receiver + algorand.send.asset_transfer( + AssetTransferParams( + sender=creator.address, + receiver=receiver.address, + asset_id=asset_id, + amount=10 # Transfer amount + ) + ) + + return { + "creator_address": creator.address, + "receiver_address": receiver.address, + "asset_id": asset_id + } + +if __name__ == "__main__": + uvicorn.run(app, host="0.0.0.0", port=8000) diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..ee18341 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,14 @@ +[tool.poetry] +name = "codespace-algorand" +version = "0.1.0" +description = "" +authors = ["Sara Jane (SJ) <127313669+Ganainmtech@users.noreply.github.com>"] +readme = "README.md" + +[tool.poetry.dependencies] +python = "^3.10" + + +[build-system] +requires = ["poetry-core"] +build-backend = "poetry.core.masonry.api" diff --git a/setup.sh b/setup.sh new file mode 100644 index 0000000..11a494f --- /dev/null +++ b/setup.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +echo "Running setup script..." + +# Install Poetry using pipx +pipx install poetry + +# Initialize a Poetry project without any interactive prompts +poetry init -n + +# Add dependencies to the project +poetry add typing-extensions +poetry add fast-html htmx uvicorn + +# Clone and install the Algokit Utils package +git clone https://github.com/algorandfoundation/algokit-utils-py.git +cd algokit-utils-py +pip install . +cd .. + +echo "Setup completed." From fe8204a8be69f848b960b2ab5e303a24988a979f Mon Sep 17 00:00:00 2001 From: "Sara Jane (SJ)" <127313669+Ganainmtech@users.noreply.github.com> Date: Tue, 13 Aug 2024 12:02:03 +0100 Subject: [PATCH 14/28] Delete .sesskey --- .sesskey | 1 - 1 file changed, 1 deletion(-) delete mode 100644 .sesskey diff --git a/.sesskey b/.sesskey deleted file mode 100644 index 43b1921..0000000 --- a/.sesskey +++ /dev/null @@ -1 +0,0 @@ -18072c21-15b1-4d85-91ce-5abc0895e24d \ No newline at end of file From 6f11c08a1b9c379ccf57920dd2131ec89fb7b99d Mon Sep 17 00:00:00 2001 From: "Sara Jane (SJ)" <127313669+Ganainmtech@users.noreply.github.com> Date: Tue, 13 Aug 2024 12:02:35 +0100 Subject: [PATCH 15/28] Delete data directory --- data/algorand.db | Bin 4096 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 data/algorand.db diff --git a/data/algorand.db b/data/algorand.db deleted file mode 100644 index 41ade9e5d196d38ea43f480680e2ead84f89a719..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4096 zcmWFz^vNtqRY=P(%1ta$FlG>7U}9o$P*7lCU|@t|AVoG{WYDv}$qUjhK(-m98b?E5 nGz3ONU^E0qLtr!nMnhmU1V%$(Gz3ONU^E0qLtr!nC=3Ar-H8V& From e0687379ce8d181a3cb5276040fa2c62416c4779 Mon Sep 17 00:00:00 2001 From: "Sara Jane (SJ)" <127313669+Ganainmtech@users.noreply.github.com> Date: Tue, 13 Aug 2024 12:02:51 +0100 Subject: [PATCH 16/28] Delete pyproject.toml --- pyproject.toml | 14 -------------- 1 file changed, 14 deletions(-) delete mode 100644 pyproject.toml diff --git a/pyproject.toml b/pyproject.toml deleted file mode 100644 index ee18341..0000000 --- a/pyproject.toml +++ /dev/null @@ -1,14 +0,0 @@ -[tool.poetry] -name = "codespace-algorand" -version = "0.1.0" -description = "" -authors = ["Sara Jane (SJ) <127313669+Ganainmtech@users.noreply.github.com>"] -readme = "README.md" - -[tool.poetry.dependencies] -python = "^3.10" - - -[build-system] -requires = ["poetry-core"] -build-backend = "poetry.core.masonry.api" From 56f444a650d7c6a5308b6fe4f7699745618c30a6 Mon Sep 17 00:00:00 2001 From: "Sara Jane (SJ)" <127313669+Ganainmtech@users.noreply.github.com> Date: Tue, 13 Aug 2024 12:03:08 +0100 Subject: [PATCH 17/28] Delete __pycache__ directory --- __pycache__/main.cpython-310.pyc | Bin 2116 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 __pycache__/main.cpython-310.pyc diff --git a/__pycache__/main.cpython-310.pyc b/__pycache__/main.cpython-310.pyc deleted file mode 100644 index f18d6f5fc400eefeec337b1c5a2a70252ffc495f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2116 zcmZ`)OK%)S5T1U_W5>H|J3$bWC@c>}8l-qRaX?XsaTJsTCQ5ujtw=+Ax;GhnUh3)1 zW3`r$oD-6-2nmp!V}1kwfgjLUF61W=k(lb1nK4vjnl1m~yKq3;IXWju~-T6EgOK#p1UD1QD`f^$H_psWO;qHoz#j;ottA_-< zlY4F?=U&2nyaXBaY2usyM)9Clyb_y5E-P(TH`-R}O(nUOcevtZYtB2 zJN)TfU2*H*Hu`oovutI=9x;C`4k3(9813gEG+-gHAO~ch2s-tC@q|A`AcH9e8U7aT zQ;nts2DR}X;sbooOX96bcXqGAcD*O7S9GYx)uhKWo!8aXow3$+HCc-X@LX%IyREev zYzU!b+kP>aT)sAJt}mAF%1q{ugFu*ucU75^1o=lu3Md zTn+AJDsQxkz`qNZb#~;aRuY0p2n!!RNt?RWtfRSl;J|UV_Aze^g?**6RhIZH*v@q! zh3dkT(Oa-${I69#ZdmY@qu!x-N?2?R0iW-I()K}6+(i@xfK>2?9xH1<0|)|x%~l7< zWl*$t;O%>mhXBl)2NF9;*1Q9#ri5;(9_&)qw^{~~VABVN$IS_Aj*0}i$ltyjwSn7X zS_&e-7m!*5<;;}=Fr0Ao2TZhggr38trrs_-BA~(LK%<~x(EOu7hf}m0P4RAI%j}Rm zN67B>k2*SbR>!N=76UjApQC*;B_dq&M6~AZLs`zf`e(fQ|M9w{yHl`2sY0QioYm8P z=Y6&UP3n-kHGAsJ*8SB&*xSl~_~~aaAtq>DTAOH5HYVU@J+5^A7XijYo5&+xGIDF< zn883Efv&x=lFmAgnu!Yu+ntk}OPh18t;Iwym=M zY?q$*XJs=u30SnKeD$H-70%lei{M0^>L=AK7#Ei9KeOz#MWZf&_!vg}J%|X!C?2bIFfBPtuTM#Wg!22J1Ok?XIcNvvv2& zZ+zeiiavxYF;FW?C#!5_#9RGPm&LkOc+;?tY@B<*`B>*gyS^heUtfftX6{eTF{3Pg z4jhNF!_I``M|oDO%9SaLtj`pj8e%kb)DrkqG>p0Q1vKHe) fUbo$(wP_l8mrxW&xE}{NMnMpxh(=$&11 Date: Tue, 13 Aug 2024 12:03:55 +0100 Subject: [PATCH 18/28] Update setup.sh --- setup.sh | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/setup.sh b/setup.sh index 11a494f..36f133e 100644 --- a/setup.sh +++ b/setup.sh @@ -2,20 +2,16 @@ echo "Running setup script..." -# Install Poetry using pipx pipx install poetry - -# Initialize a Poetry project without any interactive prompts +pip install typing-extensions poetry init -n - -# Add dependencies to the project -poetry add typing-extensions -poetry add fast-html htmx uvicorn - -# Clone and install the Algokit Utils package git clone https://github.com/algorandfoundation/algokit-utils-py.git cd algokit-utils-py pip install . cd .. echo "Setup completed." + + + + From aefeee9aeccc4419874c74153e6e58166ffc359f Mon Sep 17 00:00:00 2001 From: "Sara Jane (SJ)" <127313669+Ganainmtech@users.noreply.github.com> Date: Tue, 13 Aug 2024 12:08:40 +0100 Subject: [PATCH 19/28] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index caa1d2d..38130f0 100644 --- a/README.md +++ b/README.md @@ -30,4 +30,4 @@ Algorand Discord: https://discord.com/invite/algorand Algodevs X(twitter): https://x.com/algodevs - +[REMINDER: Get started with AlgoKit!](https://developer.algorand.org/algokit/?utm_source=af_employee&utm_medium=social&utm_campaign=algokit_sarajane&utm_content=download&utm_term=EME) From 81a3dae2639bb159dd0b862fb11f4485f0090608 Mon Sep 17 00:00:00 2001 From: "Sara Jane (SJ)" <127313669+Ganainmtech@users.noreply.github.com> Date: Tue, 13 Aug 2024 12:09:19 +0100 Subject: [PATCH 20/28] Empty main.py --- main.py | 104 -------------------------------------------------------- 1 file changed, 104 deletions(-) diff --git a/main.py b/main.py index 8a7c086..8b13789 100644 --- a/main.py +++ b/main.py @@ -1,105 +1 @@ -from fasthtml.fastapp import * -from algokit_utils.beta.algorand_client import ( - AlgorandClient, - AssetCreateParams, - AssetTransferParams, - PayParams, - AssetOptInParams, -) -import uvicorn -import logging -# Setup basic logging -logging.basicConfig(level=logging.INFO) - -def render(creator_address, receiver_address, asset_id): - result = f""" - \nCreator Address: {creator_address} - \nReceiver Address: {receiver_address} - \nAsset ID: {asset_id} - """ - return Div(result, id='result') - -# Unpack only the necessary values from fast_app -app, rt = fast_app('data/algorand.db') - -@rt("/") -async def get(request): - new_frm = Form(Group(Button("Run Script", hx_post="/run-script", target_id="result", hx_swap="innerHTML")), - id='form') - # Add a result div here - result_placeholder = Div(id='result') - return Titled('Algorand Token Creation and Transfer', new_frm, result_placeholder) - - -@rt("/run-script") -async def post(request): - logging.info("Form submitted! Running Algorand setup...") - result = setup_algorand() - return render(result['creator_address'], result['receiver_address'], result['asset_id']) - -def setup_algorand(): - algorand = AlgorandClient.default_local_net() - dispenser = algorand.account.dispenser() - - # Create and fund a new account (creator) - creator = algorand.account.random() - algorand.send.payment( - PayParams( - sender=dispenser.address, - receiver=creator.address, - amount=10_000_000 # Fund with 10 Algos - ) - ) - - # Create a new Algorand Standard Asset (ASA) - sent_txn = algorand.send.asset_create( - AssetCreateParams( - sender=creator.address, - total=1000, - asset_name="algofam", - unit_name="FAM", - manager=creator.address, - clawback=creator.address, - freeze=creator.address - ) - ) - - asset_id = sent_txn["confirmation"]["asset-index"] - - # Create and fund another new account (receiver) - receiver = algorand.account.random() - algorand.send.payment( - PayParams( - sender=dispenser.address, - receiver=receiver.address, - amount=10_000_000 # Fund with 10 Algos - ) - ) - - # Opt-in the receiver account to the newly created ASA - algorand.send.asset_opt_in( - AssetOptInParams( - sender=receiver.address, - asset_id=asset_id - ) - ) - - # Transfer 10 units of the ASA from creator to receiver - algorand.send.asset_transfer( - AssetTransferParams( - sender=creator.address, - receiver=receiver.address, - asset_id=asset_id, - amount=10 # Transfer amount - ) - ) - - return { - "creator_address": creator.address, - "receiver_address": receiver.address, - "asset_id": asset_id - } - -if __name__ == "__main__": - uvicorn.run(app, host="0.0.0.0", port=8000) From b2af02508936bdd19af568b41ff8e4d94f1ba1ba Mon Sep 17 00:00:00 2001 From: "Sara Jane (SJ)" <127313669+Ganainmtech@users.noreply.github.com> Date: Tue, 13 Aug 2024 12:15:02 +0100 Subject: [PATCH 21/28] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 38130f0..156c412 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ https://github.com/user-attachments/assets/57a20768-8292-4cff-a764-cb8173b89ae4 2. Next click the "Create codespace on main". -3. Once your codespace is fully loaded in run the commmand 'sh algorand_setup.sh' in your terminal. +3. Once your codespace is fully loaded in run the commmand 'sh setup.sh' in your terminal. 4. After this you can begin coding in your main.py file to practise interacting with the blockchain. (no smart contract needed!) From 0bb5ec0df65760beb380d73fe347123b25a95b94 Mon Sep 17 00:00:00 2001 From: "Sara Jane (SJ)" <127313669+Ganainmtech@users.noreply.github.com> Date: Fri, 16 Aug 2024 10:58:31 +0100 Subject: [PATCH 22/28] videos to be added --- README.md | 100 +++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 81 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 156c412..2ca0e15 100644 --- a/README.md +++ b/README.md @@ -1,33 +1,95 @@ -# The all in one Algorand Codespace -The all in one Algorand Codespace allows you to set up a virtual enviroment with the latest developer tooling to interact with the Algorand blockchain. This includes languages like Python to code without smart contracts, and the algokit experience for when you want to practise smart contracts and dApps! +# The All-in-One Algorand Codespace -https://github.com/user-attachments/assets/57a20768-8292-4cff-a764-cb8173b89ae4 +Welcome to the all-in-one Algorand Codespace! This repository is designed to provide you with everything you need to start developing on the Algorand blockchain, whether you're attending a workshop, completing a challenge, or just exploring on your own. -# How to use the all in one Algorand Codespace? -1. Above the files in the top right corner click the green code button. +## ๐ŸŒŸ Quick Start Guide -2. Next click the "Create codespace on main". +### ๐Ÿš€ Start with Codespaces +This is the fastest way to get up and running! -3. Once your codespace is fully loaded in run the commmand 'sh setup.sh' in your terminal. +1. **Create a Codespace:** + - [![Setup Codespace Video](https://img.youtube.com/vi/SETUP_VIDEO_THUMBNAIL_ID/maxresdefault.jpg)](SETUP_CODESPACE_VIDEO_LINK) + *Click the image above to watch a quick 15-second video on how to create your Codespace.* + - Click the green "Code" button at the top right of this page. + - Select "Create codespace on main". + - Once your Codespace is fully loaded, run the following command in the terminal: + ```bash + sh setup.sh + ``` -4. After this you can begin coding in your main.py file to practise interacting with the blockchain. (no smart contract needed!) +2. **Start Coding:** + - Open the `main.py` file to start coding and interact with the Algorand blockchain (no smart contracts needed). + - To start a smart contract/dApp project, run: + ```bash + algokit init + ``` -5. To get started with smart contracts/dapps run the command 'algokit init' to initialise your Algorand project. +3. **Workshop Follow-Along:** + - If you're participating in a workshop, the code weโ€™ll be using is available [here](https://github.com/Ganainmtech/python_algokit_demo). -And thats it! - the rest is your playground. +4. **Explore on Your Own:** + - Use this environment to write your own scripts or modify existing ones. -Not sure where to start? This codespace is intended for beginner workshops you can find the code we run through in those workshops here: -[https://github.com/Ganainmtech/python_algokit_demo](https://github.com/Ganainmtech/python_algokit_demo/blob/main/main.py) +### ๐Ÿ’ป Advanced Setup for Local Development -# Enjoying the Blockchain Developer experience on Algorand? -Then its time to move away from virtual codespace enviroments to local enviroments. Please check out the Algorand Developer Docs to find out how to set up your local enviroment (Its easy and takes less then 10 minutes!) +Prefer a local environment? Follow these steps: -Link: [Get started with AlgoKit!](https://developer.algorand.org/algokit/?utm_source=af_employee&utm_medium=social&utm_campaign=algokit_sarajane&utm_content=download&utm_term=EME) +#### ๐Ÿงฐ Prerequisites -# Join the algodevs community and work with thousands of developers just like you! +- Install Python 3.12 or higher. +- Install AlgoKit. +- Install Docker (for running a local Algorand network). -Algorand Discord: https://discord.com/invite/algorand +#### ๐Ÿ”ง Setup Instructions -Algodevs X(twitter): https://x.com/algodevs +1. **Fork & Clone the Repository:** + *Watch this video to see how to fork and clone the repository.* + - Fork this repository to your GitHub account. + - Clone the repository to your local machine: + ```bash + cd [DIRECTORY_OF_YOUR_CHOICE] + git clone [FORKED_REPO_URL] + ``` + +2. **Open in VSCode:** + - Open the repository with your code editor. + +3. **Bootstrap Your Project:** + - Navigate to the challenge folder. + - Run the following command to set up your environment: + ```bash + algokit project bootstrap + ``` + - This installs dependencies and generates a `.env` file. + +4. **Activate Python Virtual Environment:** + - Run: + ```bash + poetry shell + ``` + - The virtual environment will automatically activate the next time you open the project. + +## ๐ŸŽ“ Workshop Challenges + +If youโ€™re taking part in a workshop challenge, follow these steps: + +1. **Live coding follow along:** + - Complete the task provided during the workshop. + +2. **Submit Your Answer:** + - Push your changes to your forked GitHub repository. + - Create a Pull Request (PR) to the original repository. + - In your PR, include: + - What your script achieves. + +## ๐Ÿ“š Additional Resources + +- **Level Up:** Move to a local development environment when you're ready! Check out the [AlgoKit Landing Page](https://developer.algorand.org/algokit/?utm_source=af_employee&utm_medium=social&utm_campaign=algokit_sarajane&utm_content=download&utm_term=EME) for a quick setup guide. +- **Join the Community:** + - [![Join Algorand Discord](https://img.shields.io/discord/discord_channel_id?logo=discord)](https://discord.com/invite/algorand) + - [![Follow Algodevs on Twitter](https://img.shields.io/twitter/follow/algodevs?style=social)](https://x.com/algodevs) + +## ๐Ÿ Conclusion + +This repository serves as both a playground for exploration and a platform for structured learning through workshops and challenges. Whether you're a beginner or an experienced developer, we hope you find this environment useful and engaging. Happy coding! -[REMINDER: Get started with AlgoKit!](https://developer.algorand.org/algokit/?utm_source=af_employee&utm_medium=social&utm_campaign=algokit_sarajane&utm_content=download&utm_term=EME) From 3bb67a4b350aad248b6d698705f6a6ca42ffebd1 Mon Sep 17 00:00:00 2001 From: "Sara Jane (SJ)" <127313669+Ganainmtech@users.noreply.github.com> Date: Fri, 16 Aug 2024 11:18:39 +0100 Subject: [PATCH 23/28] added draft videos --- README.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 2ca0e15..4ad033b 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,11 @@ Welcome to the all-in-one Algorand Codespace! This repository is designed to pro This is the fastest way to get up and running! 1. **Create a Codespace:** - - [![Setup Codespace Video](https://img.youtube.com/vi/SETUP_VIDEO_THUMBNAIL_ID/maxresdefault.jpg)](SETUP_CODESPACE_VIDEO_LINK) + + +https://github.com/user-attachments/assets/1513fd15-b55a-48e5-8b97-ba128a74fe43 + + *Click the image above to watch a quick 15-second video on how to create your Codespace.* - Click the green "Code" button at the top right of this page. - Select "Create codespace on main". @@ -43,6 +47,11 @@ Prefer a local environment? Follow these steps: #### ๐Ÿ”ง Setup Instructions 1. **Fork & Clone the Repository:** + + +https://github.com/user-attachments/assets/6942cc23-72c1-4d89-a4aa-f2f4fe8fcfe0 + + *Watch this video to see how to fork and clone the repository.* - Fork this repository to your GitHub account. - Clone the repository to your local machine: From ccf919c3990919786bc41008ca00632897c15c3b Mon Sep 17 00:00:00 2001 From: "Sara Jane (SJ)" <127313669+Ganainmtech@users.noreply.github.com> Date: Fri, 16 Aug 2024 12:00:32 +0100 Subject: [PATCH 24/28] update --- setup.sh => algorand_setup.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename setup.sh => algorand_setup.sh (100%) diff --git a/setup.sh b/algorand_setup.sh similarity index 100% rename from setup.sh rename to algorand_setup.sh From 99fd680613314059838d5ab9cae16c5a530e7cc0 Mon Sep 17 00:00:00 2001 From: "Sara Jane (SJ)" <127313669+Ganainmtech@users.noreply.github.com> Date: Fri, 16 Aug 2024 12:08:18 +0100 Subject: [PATCH 25/28] Update README.md --- README.md | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 4ad033b..ec0fba8 100644 --- a/README.md +++ b/README.md @@ -7,31 +7,48 @@ Welcome to the all-in-one Algorand Codespace! This repository is designed to pro ### ๐Ÿš€ Start with Codespaces This is the fastest way to get up and running! -1. **Create a Codespace:** +### 1. **Fork the Repo:** + +To create your own copy of this repository: + +1. **Go to the GitHub Repository:** + - Navigate to the main page which is the current one your on. + +2. **Click the "Fork" Button:** + - In the top-right corner of the page, click the **Fork** button. This will create a copy of the repository under your GitHub account. + +3. **Select Your Account:** + - If prompted, select your GitHub account as the destination for the fork. + +4. **Wait for the Forking Process to Complete:** + - GitHub will take a few moments to create the fork. Once complete, youโ€™ll be redirected to your newly created fork. + + +2. **Create a Codespace:** https://github.com/user-attachments/assets/1513fd15-b55a-48e5-8b97-ba128a74fe43 *Click the image above to watch a quick 15-second video on how to create your Codespace.* - - Click the green "Code" button at the top right of this page. + - Click the green "Code" button at the top right of your forked repo. - Select "Create codespace on main". - Once your Codespace is fully loaded, run the following command in the terminal: ```bash - sh setup.sh + sh algorand_setup.sh ``` -2. **Start Coding:** +3. **Start Coding:** - Open the `main.py` file to start coding and interact with the Algorand blockchain (no smart contracts needed). - To start a smart contract/dApp project, run: ```bash algokit init ``` -3. **Workshop Follow-Along:** +4. **Workshop Follow-Along:** - If you're participating in a workshop, the code weโ€™ll be using is available [here](https://github.com/Ganainmtech/python_algokit_demo). -4. **Explore on Your Own:** +5. **Explore on Your Own:** - Use this environment to write your own scripts or modify existing ones. ### ๐Ÿ’ป Advanced Setup for Local Development @@ -41,7 +58,7 @@ Prefer a local environment? Follow these steps: #### ๐Ÿงฐ Prerequisites - Install Python 3.12 or higher. -- Install AlgoKit. +- Install [AlgoKit](https://developer.algorand.org/algokit/?utm_source=af_employee&utm_medium=social&utm_campaign=algokit_sarajane&utm_content=download&utm_term=EME). - Install Docker (for running a local Algorand network). #### ๐Ÿ”ง Setup Instructions @@ -80,7 +97,7 @@ https://github.com/user-attachments/assets/6942cc23-72c1-4d89-a4aa-f2f4fe8fcfe0 ## ๐ŸŽ“ Workshop Challenges -If youโ€™re taking part in a workshop challenge, follow these steps: +If youโ€™re taking part in a workshop challenge you can choose to fork and enter codespace or fork and work locally: 1. **Live coding follow along:** - Complete the task provided during the workshop. @@ -89,7 +106,7 @@ If youโ€™re taking part in a workshop challenge, follow these steps: - Push your changes to your forked GitHub repository. - Create a Pull Request (PR) to the original repository. - In your PR, include: - - What your script achieves. + - What your script achieves. (Optional) ## ๐Ÿ“š Additional Resources From c30f48ad98c91822e2300a2451574ca90d7a9a54 Mon Sep 17 00:00:00 2001 From: "Sara Jane (SJ)" <127313669+Ganainmtech@users.noreply.github.com> Date: Fri, 16 Aug 2024 12:20:19 +0100 Subject: [PATCH 26/28] Update README.md --- README.md | 44 +++++++++++++++++++------------------------- 1 file changed, 19 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index ec0fba8..bed08fd 100644 --- a/README.md +++ b/README.md @@ -4,27 +4,23 @@ Welcome to the all-in-one Algorand Codespace! This repository is designed to pro ## ๐ŸŒŸ Quick Start Guide -### ๐Ÿš€ Start with Codespaces -This is the fastest way to get up and running! - -### 1. **Fork the Repo:** +### **Fork the Repo:** To create your own copy of this repository: -1. **Go to the GitHub Repository:** +a. **Go to the GitHub Repository:** - Navigate to the main page which is the current one your on. -2. **Click the "Fork" Button:** +b. **Click the "Fork" Button:** - In the top-right corner of the page, click the **Fork** button. This will create a copy of the repository under your GitHub account. -3. **Select Your Account:** - - If prompted, select your GitHub account as the destination for the fork. - -4. **Wait for the Forking Process to Complete:** +c. **Wait for the Forking Process to Complete:** - GitHub will take a few moments to create the fork. Once complete, youโ€™ll be redirected to your newly created fork. +## ๐Ÿš€ Start with Codespaces +This is the fastest way to get up and running! -2. **Create a Codespace:** +1. **Create a Codespace:** https://github.com/user-attachments/assets/1513fd15-b55a-48e5-8b97-ba128a74fe43 @@ -38,20 +34,20 @@ https://github.com/user-attachments/assets/1513fd15-b55a-48e5-8b97-ba128a74fe43 sh algorand_setup.sh ``` -3. **Start Coding:** +2. **Start Coding:** - Open the `main.py` file to start coding and interact with the Algorand blockchain (no smart contracts needed). - To start a smart contract/dApp project, run: ```bash algokit init ``` -4. **Workshop Follow-Along:** +3. **Workshop Follow-Along:** - If you're participating in a workshop, the code weโ€™ll be using is available [here](https://github.com/Ganainmtech/python_algokit_demo). -5. **Explore on Your Own:** +4. **Explore on Your Own:** - Use this environment to write your own scripts or modify existing ones. -### ๐Ÿ’ป Advanced Setup for Local Development +## ๐Ÿ’ป Advanced Setup for Local Development Prefer a local environment? Follow these steps: @@ -69,7 +65,7 @@ Prefer a local environment? Follow these steps: https://github.com/user-attachments/assets/6942cc23-72c1-4d89-a4aa-f2f4fe8fcfe0 - *Watch this video to see how to fork and clone the repository.* + *Watch this video to see how to fork and clone a repository.* - Fork this repository to your GitHub account. - Clone the repository to your local machine: ```bash @@ -81,19 +77,17 @@ https://github.com/user-attachments/assets/6942cc23-72c1-4d89-a4aa-f2f4fe8fcfe0 - Open the repository with your code editor. 3. **Bootstrap Your Project:** - - Navigate to the challenge folder. - - Run the following command to set up your environment: + - Navigate to the [`main.py`](./main.py) file. + - Run the following command to set up your environment for simple scripts: ```bash - algokit project bootstrap + sh algorand_setup.sh ``` - - This installs dependencies and generates a `.env` file. - -4. **Activate Python Virtual Environment:** - - Run: + - If you are looking into smart contracts and algokit run the following commands: ```bash - poetry shell + algokit init + algokit project bootstrap ``` - - The virtual environment will automatically activate the next time you open the project. + - This installs dependencies and generates a `.env` file if you are using algokit. ## ๐ŸŽ“ Workshop Challenges From 5596947616d02fed9cd39a3dbc4d530d3dbd9107 Mon Sep 17 00:00:00 2001 From: "Sara Jane (SJ)" <127313669+Ganainmtech@users.noreply.github.com> Date: Wed, 21 Aug 2024 19:17:34 +0000 Subject: [PATCH 27/28] tidy up --- algokit-utils-py | 1 - 1 file changed, 1 deletion(-) delete mode 160000 algokit-utils-py diff --git a/algokit-utils-py b/algokit-utils-py deleted file mode 160000 index 816b548..0000000 --- a/algokit-utils-py +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 816b548da68b76dcdd53788db3a47736d8646668 From e235fb4fb08ff831237fd9ae2b6ca413eb7ce016 Mon Sep 17 00:00:00 2001 From: Ansar Afsar <83577572+Ansarafsar@users.noreply.github.com> Date: Mon, 26 Aug 2024 10:10:16 +0000 Subject: [PATCH 28/28] Challenge Completed --- algokit-utils-py | 1 + main.py | 86 ++++++++++++++++++++++++++++++++++++++++++++++++ pyproject.toml | 14 ++++++++ 3 files changed, 101 insertions(+) create mode 160000 algokit-utils-py create mode 100644 pyproject.toml diff --git a/algokit-utils-py b/algokit-utils-py new file mode 160000 index 0000000..816b548 --- /dev/null +++ b/algokit-utils-py @@ -0,0 +1 @@ +Subproject commit 816b548da68b76dcdd53788db3a47736d8646668 diff --git a/main.py b/main.py index 8b13789..f465b17 100644 --- a/main.py +++ b/main.py @@ -1 +1,87 @@ +from algokit_utils.beta.algorand_client import( + AlgorandClient, + AssetCreateParams, + AssetOptInParams, + AssetTransferParams, + PayParams, +) +# client to connect to the local net +algorand = AlgorandClient.default_local_net() + +dispenser = algorand.account.dispenser() +#print("Dispenser Address: ",dispenser.address) + +# Generate creator wallet +creator = algorand.account.random() +#print("Creator Address: ",creator.address) +#print(algorand.account.get_information(creator.address)) + +# Fund creator address with algo +algorand.send.payment( + PayParams( + sender=dispenser.address, + receiver=creator.address, + amount=10_000_000 # 10 algos + ) +) + +#print(algorand.account.get_information(creator.address)) + +send_txn = algorand.send.asset_create( + AssetCreateParams( + sender=creator.address, + total=100, + asset_name="Edu4teen", + unit_name="E4T" + ) +) + +asset_id = send_txn["confirmation"]["asset-index"] +#print("Asset ID: ", asset_id) + +receiver_acct = algorand.account.random() + +algorand.send.payment( + PayParams( + sender=dispenser.address, + receiver=receiver_acct.address, + amount=10_000_000 # 10 algos + ) +) + +#print(algorand.account.get_information(receiver_acct.address)) + +# create a new group txn +group_txn = algorand.new_group() + +group_txn.add_asset_opt_in( + AssetOptInParams( + sender=receiver_acct.address, + asset_id=asset_id + ) +) + +group_txn.add_payment( + PayParams( + sender=receiver_acct.address, + receiver=creator.address, + amount=1_000_000 # 1 algo + ) +) + +group_txn.add_asset_transfer( + AssetTransferParams( + sender=creator.address, + receiver=receiver_acct.address, + asset_id=asset_id, + amount=10 + ) +) + +group_txn.execute() + +print(algorand.account.get_information(receiver_acct.address)) + +print("Receiver Account Asset Balance: ", algorand.account.get_information(receiver_acct.address)['assets'][0]['amount']) +print("Creator Account Asset Balance: ", algorand.account.get_information(creator.address)['assets'][0]['amount']) \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..96fabbc --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,14 @@ +[tool.poetry] +name = "codespace-algo-first" +version = "0.1.0" +description = "" +authors = ["Ansar Afsar <83577572+Ansarafsar@users.noreply.github.com>"] +readme = "README.md" + +[tool.poetry.dependencies] +python = "^3.12" + + +[build-system] +requires = ["poetry-core"] +build-backend = "poetry.core.masonry.api"