Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solution for Python Challenge 3 #72

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

algotables
Copy link

1. What was the problem?

The primary issue was that the opt_in_to_asset method in the ASA vault smart contract did not perform the actual opt-in transaction necessary for the contract to hold and manage the specified ASA (Algorand Standard Asset). Although the method was designed to facilitate the contract's opt-in to an asset, it lacked the execution of a transaction that would officially register the smart contract with the Algorand network as capable of receiving and holding the asset. This was a crucial step because, without it, any attempts to deposit the ASA into the vault would fail, as the contract would not be recognized as an opted-in account for the specified asset.

2. How did you solve the problem?

To resolve this issue, I added an inner transaction (itxn.AssetTransfer) within the opt_in_to_asset method. This transaction was configured to send an asset transfer of zero units of the ASA to the contract itself, which is the standard procedure on the Algorand network to opt-in to an ASA. This effectively registers the contract as capable of holding the asset. Additionally, I set the asset transfer to close back to the creator's address with a zero fee. This ensures that the opt-in operation is cost-effective and that the contract maintains minimum balance requirements without holding unnecessary assets. By implementing this transaction, the smart contract is now fully equipped to accept and manage the ASA as intended.

3. Screenshot of your terminal showing the result of running the deploy script.

python-challenge-3-jeff-stein-5-10-24

feat: Add asset opt-in transaction to ASA vault's opt_in_to_asset method

- Implemented an inner transaction for asset opt-in using itxn.AssetTransfer
- Ensured zero-asset transfer to self for opt-in process, with asset close for cleanup
- Set transaction fee to zero for the opt-in operation
@iskysun96 iskysun96 added the Approved ✅ Successfully completed the challenge! label May 16, 2024
@iskysun96
Copy link
Contributor

🎉 Congrats on solving the 3rd Algorand Python Coding Challenge!

I have labeled your PR approved, so you can now claim your certificate.

You can claim your certificate of completion NFT here:
https://goplausible.xyz/claim/h82968w2n76k9t6tz2ekm7zg790t6y7xwmqj0esqcbgaqd8641merqczya8mcmm238p1n1j6vjzwc23a3ztat3jew07z4ahrs56z41r

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Approved ✅ Successfully completed the challenge!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants