diff --git a/README.md b/README.md index c4caaa11..bed08fde 100644 --- a/README.md +++ b/README.md @@ -1 +1,115 @@ -# codespace_algorand \ No newline at end of file +# 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/algokit-utils-py b/algokit-utils-py new file mode 160000 index 00000000..816b548d --- /dev/null +++ b/algokit-utils-py @@ -0,0 +1 @@ +Subproject commit 816b548da68b76dcdd53788db3a47736d8646668 diff --git a/algorand_setup.sh b/algorand_setup.sh new file mode 100644 index 00000000..36f133e2 --- /dev/null +++ b/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/main.py b/main.py index 8b137891..f465b179 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/post-create.sh b/post-create.sh deleted file mode 100644 index f4bebbdf..00000000 --- a/post-create.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash - -echo "running" -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 - - - - diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..96fabbc4 --- /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"