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

Fix attribute resolution errors in Counter contract for Algorand Python Challenge 2 #80

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

algotables
Copy link

Algorand Coding Challenge Submission

What was the bug?

The bug in the Counter smart contract was related to incorrect handling of state variables. The count and counters attributes were declared as class variables, which resulted in errors during attribute resolution when attempting to access local and global state values.

How did you fix the bug?

  1. Moved the count and counters attributes to instance variables by initializing them inside the __init__ constructor. This allows for consistent state management across all methods.
  2. Updated all method references to count and counters to correctly use instance variables (self.count and self.counters).
  3. Verified that count accurately tracks the transaction count per sender and counters maintains the global count of all users opted into the smart contract.

These changes resolved the attribute resolution errors and ensured proper local and global state handling.

Console Screenshot:

python-challenge-2-jeff-stein-5-9-24

…mart contract

- Moved `count` and `counters` attributes to instance variables by initializing them in the `__init__` constructor.
- Updated all references to `count` and `counters` to use instance variables (`self.count` and `self.counters`) instead of class attributes.
- Ensured that `count` accurately tracks the count for each sender, and `counters` correctly counts the global instances.

These changes resolve attribute resolution errors in the Counter smart contract and ensure accurate state management for each transaction.
@iskysun96
Copy link
Contributor

please read the readme and share the appropriate screenshot!

@algotables
Copy link
Author

Hello,

Thank you for your feedback. I apologize for the oversight on my part. I have now carefully read the README file and followed the instructions. Attached is the necessary screenshot as requested.

I appreciate your patience and understanding, and I will ensure to thoroughly read and follow the README in the future before generating any more pull requests.

Thank you once again for your guidance.

Best regards,

Jeff

python-challenge-2-jeff-stein-5-18-24

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants