-
Notifications
You must be signed in to change notification settings - Fork 36
Open
Description
Description
The goal is to create a contract to track and withdraw creator earnings. Create contracts/creator-earnings/ with initialize(env, admin, token_address), deposit(env, creator, amount) (callable by subscription/content contracts), balance(env, creator) -> i128, withdraw(env, creator, amount) (creator authorizes). Add unit tests for deposit, balance, withdraw, and insufficient balance revert.
Tasks
-
Implement initialize:
- Store admin and token address
-
Implement deposit:
- Callable by authorized contracts (or admin)
- Add amount to creator balance
- Or: transfer tokens to contract and credit creator
-
Implement balance:
- Return creator's balance
-
Implement withdraw:
- Creator authorizes
- Transfer tokens from contract to creator
- Decrease balance
- Revert if insufficient balance
-
Add tests:
- Deposit increases balance
- Withdraw decreases balance and transfers tokens
- Insufficient balance revert
Additional Requirements
- Consider authorization: only subscription/content contracts can deposit
Acceptance Criteria
- Earnings can be deposited
- Creators can withdraw
- Balance accurate
- All tests pass
Reactions are currently unavailable