Skip to content

Create rewards/earnings contract stub #65

@aji70

Description

@aji70

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

  1. Implement initialize:

    • Store admin and token address
  2. Implement deposit:

    • Callable by authorized contracts (or admin)
    • Add amount to creator balance
    • Or: transfer tokens to contract and credit creator
  3. Implement balance:

    • Return creator's balance
  4. Implement withdraw:

    • Creator authorizes
    • Transfer tokens from contract to creator
    • Decrease balance
    • Revert if insufficient balance
  5. 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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions