Building Blockchain Applications with Python

Guidelines for developing decentralized applications and smart contracts using Python libraries like Web3.py.

0 likes
10 views

Rule Content

---
name: Building Blockchain Applications with Python
version: "1.0"
category: Python Cursor Rules
description: Guidelines for developing decentralized applications and smart contracts using Python libraries like Web3.py.
---

## Coding Standards

- **PEP 8 Compliance**: Ensure all Python code adheres to PEP 8 standards for readability and consistency.

- **Type Hinting**: Utilize Python's type hinting to enhance code clarity and facilitate static analysis.

## Security Practices

- **Cryptographic Libraries**: Use reputable libraries such as `PyCryptodome` for encryption and hashing to secure data transmission and storage.

- **Input Validation**: Implement thorough input validation to prevent injection attacks and ensure data integrity.

- **Exception Handling**: Employ robust exception handling to manage errors gracefully and avoid exposing sensitive information.

## Smart Contract Development

- **Modular Design**: Structure smart contracts into modular components to enhance maintainability and reusability.

- **Security Audits**: Conduct regular audits and peer reviews of smart contracts to identify and mitigate vulnerabilities.

## Code Quality

- **Linting Tools**: Use tools like `pylint` to enforce coding standards and detect potential issues early.

- **Unit Testing**: Develop comprehensive unit tests using frameworks like `pytest` to ensure code reliability and facilitate refactoring.

## Documentation

- **Docstrings**: Include clear and concise docstrings for all functions and classes to describe their purpose and usage.

- **Project Documentation**: Maintain up-to-date documentation detailing the project's architecture, dependencies, and setup instructions.

## Performance Optimization

- **Efficient Algorithms**: Choose optimal algorithms and data structures to improve performance and reduce resource consumption.

- **Profiling**: Regularly profile the codebase to identify and address performance bottlenecks.

## Version Control

- **Git Usage**: Utilize Git for version control, ensuring meaningful commit messages and regular commits to track changes effectively.

- **Branching Strategy**: Adopt a clear branching strategy (e.g., Git Flow) to manage feature development, releases, and hotfixes systematically.