Overview
Aura x Capital is seeking a Middle-Level Python Developer to work on a crypto swap and limits exchange system. In this task, you’ll build a simple Python-based crypto transaction processor that simulates a swap operation between two wallets, updates their balances, and logs the transaction.
Task Requirements
-
Create a Python script that processes a mock crypto swap between two wallets, updating their balances and logging the transaction.
-
- Implement a
Wallet
class to manage balances (in a fictional “TONcoin” currency). - Simulate a swap by deducting an amount from one wallet and adding it to another, including a 1% transaction fee (e.g., for 100 TONcoin sent, 1 TONcoin is taken as a fee, and 99 TONcoin is received).
- Log each transaction with a timestamp, sender, receiver, amount sent, fee, and amount received in a list or file.
- Implement a
-
- Define a
Wallet
class with attributes (e.g., address, balance) and methods (e.g.,deduct
,add
). - Define a
Transaction
class to handle the swap logic, interacting withWallet
instances. - Use encapsulation (e.g., private attributes with getters/setters if needed) and clear method design.
- Define a
-
- Include comments in the code explaining how your implementation could be extended by a team (e.g., adding TON blockchain calls).
- Provide a brief README (or comments) describing:
- How this task fits into an Agile sprint (e.g., as a user story or task).
- How you’d collaborate with team members (e.g., QA for testing, frontend for UI integration).
-
- Simulate a TON blockchain call with a simple function (e.g.,
mock_ton_swap(address_from, address_to, amount)
returning a success flag). This represents a real-world TON library call without requiring actual setup.
- Simulate a TON blockchain call with a simple function (e.g.,
Deliverables
- A Python script (
crypto_processor.py
) with the solution. - A README file or inline comments addressing teamwork and Agile aspects.
- Submit via a GitHub repository link.
Guidelines
- Use Python 3.x.
- Keep the task simple; no real blockchain setup is needed—focus on the logic and structure.
- Assume the mock TON call always succeeds for simplicity.
- Estimated completion time: 2-4 hours.
Example Output
If Wallet A (balance: 500 TONcoin) swaps 100 TONcoin to Wallet B (balance: 200 TONcoin):
- Wallet A balance becomes 400 TONcoin (500 - 100).
- Wallet B balance becomes 299 TONcoin (200 + 99, after 1% fee).
- Log entry:
"2025-03-25 06:45:00 - A -> B: Sent 100 TONcoin, Fee 1 TONcoin, Received 99 TONcoin"
.