From 22f57e5756d3d99e7fe577f7aa3775b1d55b6606 Mon Sep 17 00:00:00 2001 From: bofu2007 <91390278+bofu2007@users.noreply.github.com> Date: Sat, 24 Aug 2024 12:23:58 +0800 Subject: [PATCH 1/7] Add files via upload --- codespace_algorand-main/README.md | 115 ++++++++++++++++++++++ codespace_algorand-main/algorand_setup.sh | 17 ++++ codespace_algorand-main/main.py | 80 +++++++++++++++ codespace_algorand-main/pyproject.toml | 14 +++ 4 files changed, 226 insertions(+) create mode 100644 codespace_algorand-main/README.md create mode 100644 codespace_algorand-main/algorand_setup.sh create mode 100644 codespace_algorand-main/main.py create mode 100644 codespace_algorand-main/pyproject.toml diff --git a/codespace_algorand-main/README.md b/codespace_algorand-main/README.md new file mode 100644 index 00000000..bed08fde --- /dev/null +++ b/codespace_algorand-main/README.md @@ -0,0 +1,115 @@ +# The All-in-One Algorand Codespace + +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. + +## 🌟 Quick Start Guide + +### **Fork the Repo:** + +To create your own copy of this repository: + +a. **Go to the GitHub Repository:** + - Navigate to the main page which is the current one your on. + +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. + +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! + +1. **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 your forked repo. + - Select "Create codespace on main". + - Once your Codespace is fully loaded, run the following command in the terminal: + ```bash + sh algorand_setup.sh + ``` + +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 + ``` + +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). + +4. **Explore on Your Own:** + - Use this environment to write your own scripts or modify existing ones. + +## πŸ’» Advanced Setup for Local Development + +Prefer a local environment? Follow these steps: + +#### 🧰 Prerequisites + +- Install Python 3.12 or higher. +- 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 + +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 a 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 [`main.py`](./main.py) file. + - Run the following command to set up your environment for simple scripts: + ```bash + sh algorand_setup.sh + ``` + - If you are looking into smart contracts and algokit run the following commands: + ```bash + algokit init + algokit project bootstrap + ``` + - This installs dependencies and generates a `.env` file if you are using algokit. + +## πŸŽ“ Workshop Challenges + +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. + +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. (Optional) + +## πŸ“š 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! + diff --git a/codespace_algorand-main/algorand_setup.sh b/codespace_algorand-main/algorand_setup.sh new file mode 100644 index 00000000..36f133e2 --- /dev/null +++ b/codespace_algorand-main/algorand_setup.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +echo "Running setup script..." + +pipx install poetry +pip install typing-extensions +poetry init -n +git clone https://github.com/algorandfoundation/algokit-utils-py.git +cd algokit-utils-py +pip install . +cd .. + +echo "Setup completed." + + + + diff --git a/codespace_algorand-main/main.py b/codespace_algorand-main/main.py new file mode 100644 index 00000000..76129dbd --- /dev/null +++ b/codespace_algorand-main/main.py @@ -0,0 +1,80 @@ +from algokit_utils.beta.algorand_client import( + AlgorandClient, + AssetCreateParams, + AssetOptInParams, + PayParams, + AssetTransferParams +) +algorand=AlgorandClient.default_local_net() + +dispenser=algorand.account.dispenser() +# print("Dispenser: ", dispenser.address) + +maker=algorand.account.random() +# print("maker: ", maker.address) + +# print(algorand.account.get_information(maker.address)) + +algorand.send.payment( + PayParams( + sender=dispenser.address, + receiver=maker.address, + amount=10_000_000 + ) +) + +# print(algorand.account.get_information(maker.address)) + +sent_txn=algorand.send.asset_create( + AssetCreateParams( + sender=maker.address, + total=100, + asset_name="Edu4Teen", + unit_name="E4T" + ) +) + +asset_id=sent_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 + ) +) + +# print(algorand.account.get_information(receiver_acct.address)) + +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=maker.address, + amount=2_000_000 + ) +) + +group_txn.add_asset_transfer( + AssetTransferParams( + sender=maker.address, + receiver=receiver_acct.address, + asset_id=asset_id, + amount=18 + ) +) + +group_txn.execute() +print(algorand.account.get_information(receiver_acct.address)) +print("Receiver assets: ", algorand.account.get_information(receiver_acct.address)["assets"][0]["amount"]) +print("maker assets: ", algorand.account.get_information(maker.address)["assets"][0]["amount"]) \ No newline at end of file diff --git a/codespace_algorand-main/pyproject.toml b/codespace_algorand-main/pyproject.toml new file mode 100644 index 00000000..712eb8f9 --- /dev/null +++ b/codespace_algorand-main/pyproject.toml @@ -0,0 +1,14 @@ +[tool.poetry] +name = "codespace-algorand" +version = "0.1.0" +description = "" +authors = ["Hassan Ali <121270268+hassanaly18@users.noreply.github.com>"] +readme = "README.md" + +[tool.poetry.dependencies] +python = "^3.12" + + +[build-system] +requires = ["poetry-core"] +build-backend = "poetry.core.masonry.api" From f5738aba230c1aa4eb9ff9b3a56555c231584ca7 Mon Sep 17 00:00:00 2001 From: bofu2007 <91390278+bofu2007@users.noreply.github.com> Date: Sat, 24 Aug 2024 12:29:01 +0800 Subject: [PATCH 2/7] Delete main.py --- main.py | 1 - 1 file changed, 1 deletion(-) delete mode 100644 main.py diff --git a/main.py b/main.py deleted file mode 100644 index 8b137891..00000000 --- a/main.py +++ /dev/null @@ -1 +0,0 @@ - From 0500029bd01cb714df4a233e1061c43426c528dc Mon Sep 17 00:00:00 2001 From: bofu2007 <91390278+bofu2007@users.noreply.github.com> Date: Sat, 24 Aug 2024 12:29:12 +0800 Subject: [PATCH 3/7] Delete algorand_setup.sh --- algorand_setup.sh | 17 ----------------- 1 file changed, 17 deletions(-) delete mode 100644 algorand_setup.sh diff --git a/algorand_setup.sh b/algorand_setup.sh deleted file mode 100644 index 36f133e2..00000000 --- a/algorand_setup.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash - -echo "Running setup script..." - -pipx install poetry -pip install typing-extensions -poetry init -n -git clone https://github.com/algorandfoundation/algokit-utils-py.git -cd algokit-utils-py -pip install . -cd .. - -echo "Setup completed." - - - - From 1e85cbf7ae9776a0eb9edb0e3b0081b36ae8d71b Mon Sep 17 00:00:00 2001 From: bofu2007 <91390278+bofu2007@users.noreply.github.com> Date: Sat, 24 Aug 2024 12:29:37 +0800 Subject: [PATCH 4/7] Delete codespace_algorand-main directory --- codespace_algorand-main/README.md | 115 ---------------------- codespace_algorand-main/algorand_setup.sh | 17 ---- codespace_algorand-main/main.py | 80 --------------- codespace_algorand-main/pyproject.toml | 14 --- 4 files changed, 226 deletions(-) delete mode 100644 codespace_algorand-main/README.md delete mode 100644 codespace_algorand-main/algorand_setup.sh delete mode 100644 codespace_algorand-main/main.py delete mode 100644 codespace_algorand-main/pyproject.toml diff --git a/codespace_algorand-main/README.md b/codespace_algorand-main/README.md deleted file mode 100644 index bed08fde..00000000 --- a/codespace_algorand-main/README.md +++ /dev/null @@ -1,115 +0,0 @@ -# The All-in-One Algorand Codespace - -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. - -## 🌟 Quick Start Guide - -### **Fork the Repo:** - -To create your own copy of this repository: - -a. **Go to the GitHub Repository:** - - Navigate to the main page which is the current one your on. - -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. - -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! - -1. **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 your forked repo. - - Select "Create codespace on main". - - Once your Codespace is fully loaded, run the following command in the terminal: - ```bash - sh algorand_setup.sh - ``` - -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 - ``` - -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). - -4. **Explore on Your Own:** - - Use this environment to write your own scripts or modify existing ones. - -## πŸ’» Advanced Setup for Local Development - -Prefer a local environment? Follow these steps: - -#### 🧰 Prerequisites - -- Install Python 3.12 or higher. -- 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 - -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 a 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 [`main.py`](./main.py) file. - - Run the following command to set up your environment for simple scripts: - ```bash - sh algorand_setup.sh - ``` - - If you are looking into smart contracts and algokit run the following commands: - ```bash - algokit init - algokit project bootstrap - ``` - - This installs dependencies and generates a `.env` file if you are using algokit. - -## πŸŽ“ Workshop Challenges - -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. - -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. (Optional) - -## πŸ“š 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! - diff --git a/codespace_algorand-main/algorand_setup.sh b/codespace_algorand-main/algorand_setup.sh deleted file mode 100644 index 36f133e2..00000000 --- a/codespace_algorand-main/algorand_setup.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash - -echo "Running setup script..." - -pipx install poetry -pip install typing-extensions -poetry init -n -git clone https://github.com/algorandfoundation/algokit-utils-py.git -cd algokit-utils-py -pip install . -cd .. - -echo "Setup completed." - - - - diff --git a/codespace_algorand-main/main.py b/codespace_algorand-main/main.py deleted file mode 100644 index 76129dbd..00000000 --- a/codespace_algorand-main/main.py +++ /dev/null @@ -1,80 +0,0 @@ -from algokit_utils.beta.algorand_client import( - AlgorandClient, - AssetCreateParams, - AssetOptInParams, - PayParams, - AssetTransferParams -) -algorand=AlgorandClient.default_local_net() - -dispenser=algorand.account.dispenser() -# print("Dispenser: ", dispenser.address) - -maker=algorand.account.random() -# print("maker: ", maker.address) - -# print(algorand.account.get_information(maker.address)) - -algorand.send.payment( - PayParams( - sender=dispenser.address, - receiver=maker.address, - amount=10_000_000 - ) -) - -# print(algorand.account.get_information(maker.address)) - -sent_txn=algorand.send.asset_create( - AssetCreateParams( - sender=maker.address, - total=100, - asset_name="Edu4Teen", - unit_name="E4T" - ) -) - -asset_id=sent_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 - ) -) - -# print(algorand.account.get_information(receiver_acct.address)) - -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=maker.address, - amount=2_000_000 - ) -) - -group_txn.add_asset_transfer( - AssetTransferParams( - sender=maker.address, - receiver=receiver_acct.address, - asset_id=asset_id, - amount=18 - ) -) - -group_txn.execute() -print(algorand.account.get_information(receiver_acct.address)) -print("Receiver assets: ", algorand.account.get_information(receiver_acct.address)["assets"][0]["amount"]) -print("maker assets: ", algorand.account.get_information(maker.address)["assets"][0]["amount"]) \ No newline at end of file diff --git a/codespace_algorand-main/pyproject.toml b/codespace_algorand-main/pyproject.toml deleted file mode 100644 index 712eb8f9..00000000 --- a/codespace_algorand-main/pyproject.toml +++ /dev/null @@ -1,14 +0,0 @@ -[tool.poetry] -name = "codespace-algorand" -version = "0.1.0" -description = "" -authors = ["Hassan Ali <121270268+hassanaly18@users.noreply.github.com>"] -readme = "README.md" - -[tool.poetry.dependencies] -python = "^3.12" - - -[build-system] -requires = ["poetry-core"] -build-backend = "poetry.core.masonry.api" From fa74956fa9827f21299c8b24782fac997b88db5d Mon Sep 17 00:00:00 2001 From: bofu2007 <91390278+bofu2007@users.noreply.github.com> Date: Sat, 24 Aug 2024 12:29:48 +0800 Subject: [PATCH 5/7] Delete .devcontainer.json --- .devcontainer.json | 22 ---------------------- 1 file changed, 22 deletions(-) delete mode 100644 .devcontainer.json diff --git a/.devcontainer.json b/.devcontainer.json deleted file mode 100644 index 3d0dfc0f..00000000 --- a/.devcontainer.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "forwardPorts": [4001, 4002, 8980, 5173], - "portsAttributes": { - "4001": { - "label": "algod" - }, - "4002": { - "label": "kmd" - }, - "8980": { - "label": "indexer" - }, - "5173": { - "label": "vite" - } - }, - - "postCreateCommand": "pipx install algokit", - "postStartCommand": "algokit localnet start" - - } - From 7ded1454ade111a2d5d05e550644d58dbbb8120e Mon Sep 17 00:00:00 2001 From: bofu2007 <91390278+bofu2007@users.noreply.github.com> Date: Sat, 24 Aug 2024 12:29:57 +0800 Subject: [PATCH 6/7] Delete README.md --- README.md | 115 ------------------------------------------------------ 1 file changed, 115 deletions(-) delete mode 100644 README.md diff --git a/README.md b/README.md deleted file mode 100644 index bed08fde..00000000 --- a/README.md +++ /dev/null @@ -1,115 +0,0 @@ -# The All-in-One Algorand Codespace - -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. - -## 🌟 Quick Start Guide - -### **Fork the Repo:** - -To create your own copy of this repository: - -a. **Go to the GitHub Repository:** - - Navigate to the main page which is the current one your on. - -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. - -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! - -1. **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 your forked repo. - - Select "Create codespace on main". - - Once your Codespace is fully loaded, run the following command in the terminal: - ```bash - sh algorand_setup.sh - ``` - -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 - ``` - -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). - -4. **Explore on Your Own:** - - Use this environment to write your own scripts or modify existing ones. - -## πŸ’» Advanced Setup for Local Development - -Prefer a local environment? Follow these steps: - -#### 🧰 Prerequisites - -- Install Python 3.12 or higher. -- 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 - -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 a 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 [`main.py`](./main.py) file. - - Run the following command to set up your environment for simple scripts: - ```bash - sh algorand_setup.sh - ``` - - If you are looking into smart contracts and algokit run the following commands: - ```bash - algokit init - algokit project bootstrap - ``` - - This installs dependencies and generates a `.env` file if you are using algokit. - -## πŸŽ“ Workshop Challenges - -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. - -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. (Optional) - -## πŸ“š 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! - From c9f8bd4f099e08fe182d156a6db42dc78093ecfa Mon Sep 17 00:00:00 2001 From: bofu2007 <91390278+bofu2007@users.noreply.github.com> Date: Sat, 24 Aug 2024 12:30:39 +0800 Subject: [PATCH 7/7] challenge finished --- codespace_algorand-main/README.md | 115 ++++++++++++++++++++++ codespace_algorand-main/algorand_setup.sh | 17 ++++ codespace_algorand-main/main.py | 88 +++++++++++++++++ codespace_algorand-main/pyproject.toml | 14 +++ 4 files changed, 234 insertions(+) create mode 100644 codespace_algorand-main/README.md create mode 100644 codespace_algorand-main/algorand_setup.sh create mode 100644 codespace_algorand-main/main.py create mode 100644 codespace_algorand-main/pyproject.toml diff --git a/codespace_algorand-main/README.md b/codespace_algorand-main/README.md new file mode 100644 index 00000000..bed08fde --- /dev/null +++ b/codespace_algorand-main/README.md @@ -0,0 +1,115 @@ +# The All-in-One Algorand Codespace + +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. + +## 🌟 Quick Start Guide + +### **Fork the Repo:** + +To create your own copy of this repository: + +a. **Go to the GitHub Repository:** + - Navigate to the main page which is the current one your on. + +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. + +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! + +1. **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 your forked repo. + - Select "Create codespace on main". + - Once your Codespace is fully loaded, run the following command in the terminal: + ```bash + sh algorand_setup.sh + ``` + +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 + ``` + +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). + +4. **Explore on Your Own:** + - Use this environment to write your own scripts or modify existing ones. + +## πŸ’» Advanced Setup for Local Development + +Prefer a local environment? Follow these steps: + +#### 🧰 Prerequisites + +- Install Python 3.12 or higher. +- 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 + +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 a 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 [`main.py`](./main.py) file. + - Run the following command to set up your environment for simple scripts: + ```bash + sh algorand_setup.sh + ``` + - If you are looking into smart contracts and algokit run the following commands: + ```bash + algokit init + algokit project bootstrap + ``` + - This installs dependencies and generates a `.env` file if you are using algokit. + +## πŸŽ“ Workshop Challenges + +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. + +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. (Optional) + +## πŸ“š 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! + diff --git a/codespace_algorand-main/algorand_setup.sh b/codespace_algorand-main/algorand_setup.sh new file mode 100644 index 00000000..36f133e2 --- /dev/null +++ b/codespace_algorand-main/algorand_setup.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +echo "Running setup script..." + +pipx install poetry +pip install typing-extensions +poetry init -n +git clone https://github.com/algorandfoundation/algokit-utils-py.git +cd algokit-utils-py +pip install . +cd .. + +echo "Setup completed." + + + + diff --git a/codespace_algorand-main/main.py b/codespace_algorand-main/main.py new file mode 100644 index 00000000..19235b28 --- /dev/null +++ b/codespace_algorand-main/main.py @@ -0,0 +1,88 @@ +from algokit_utils.beta.algorand_client import ( + AlgorandClient, + AssetCreateParams, + AssetOptInParams, + AssetTransferParams, + PayParams +) + + +# Client to connect to localnet +algorand = AlgorandClient.default_local_net() + +# Import dispenser from KMD +dispenser = algorand.account.dispenser() +print("Dispenser Address:", dispenser.address) + +creator = algorand.account.random() +print("Creator Address:", creator.address) +# print(algorand.account.get_information(creator.address)) + +# Fund creator account +algorand.send.payment( + PayParams( + sender=dispenser.address, + receiver=creator.address, + amount=10_000_000 # 10 ALGOs + ) +) + +# print(algorand.account.get_information(creator.address)) + +sent_txn = algorand.send.asset_create( + AssetCreateParams( + sender=creator.address, + total=100, + asset_name="Edu4Teen", + unit_name="E4T" + ) +) +# print(sent_txn) + +asset_id = sent_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 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( + # asset_transfer = algorand.send.asset_transfer( # We don't need this because we are adding this txn to a txn group... + AssetTransferParams( + sender=creator.address, + receiver=receiver_acct.address, + asset_id=asset_id, + amount=10 + ) + # ) +) + +group_txn.execute() + +print("\nFor Algorand, with Love, from Pasquale Silvestre:") +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"]) diff --git a/codespace_algorand-main/pyproject.toml b/codespace_algorand-main/pyproject.toml new file mode 100644 index 00000000..cbf36d92 --- /dev/null +++ b/codespace_algorand-main/pyproject.toml @@ -0,0 +1,14 @@ +[tool.poetry] +name = "codespace-algorand" +version = "0.1.0" +description = "" +authors = ["Pasquale-Silv <55320885+Pasquale-Silv@users.noreply.github.com>"] +readme = "README.md" + +[tool.poetry.dependencies] +python = "^3.12" + + +[build-system] +requires = ["poetry-core"] +build-backend = "poetry.core.masonry.api"