Skip to content

Contracts: Add user rewards delegation (assign claim rights to another address) #323

@CelestinaBeing

Description

@CelestinaBeing

Summary

Users should be able to delegate their claim rights to a hot wallet or smart contract without transferring ownership. This enables custodial services, mobile wallets, and DeFi integrations to claim rewards on behalf of users without needing the user's primary key online.

Problem

  • Only the address that earned rewards can call claim()
  • Users with cold storage earn rewards but cannot claim without bringing the cold key online
  • No mechanism for approved operators to act on behalf of users

Acceptance Criteria

  • Add approve_delegate(env, owner, delegate: Address, allowed_amount: u64) — owner approves delegate to claim up to allowed_amount
  • Store approvals: (DELEGATE, owner, delegate) -> u64 (remaining allowance)
  • Modify claim(): if user != caller, check delegate_allowance(user, caller) >= amount and deduct from allowance
  • Add revoke_delegate(env, owner, delegate)
  • Add delegate_allowance(env, owner, delegate) -> u64 view
  • Add unit tests: happy path, insufficient allowance rejected, revoke then claim fails, allowance decrements on claim
  • Emit delegate_approved and delegate_revoked events

References

  • contracts/rewards/src/lib.rs:264claim() function
  • ERC-20 allowance pattern as conceptual reference

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave program

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions