Skip to content

feat(smart-contract): Implement Agent Subscription and Recurring Payment Model #258

Description

@devJaja

Summary

Add subscription-based payment model where clients can subscribe to agent services with recurring XLM payments and automatic renewal.

Motivation

Pay-per-task is not always optimal. Subscriptions provide predictable costs for clients and stable income for agents.

Acceptance Criteria

  • create_subscription function with duration, payment amount, and agent
  • Subscription stored with start time, end time, and payment schedule
  • renew_subscription extends duration with new payment
  • cancel_subscription with prorated refund
  • check_subscription verifies if subscription is active
  • Auto-renewal support (opt-in)
  • Events: SubscriptionCreated, SubscriptionRenewed, SubscriptionCancelled, PaymentProcessed
  • Unit tests for create, renew, cancel, and expiry

Files to Modify

File Action
smart-contracts/contracts/agent_registry/src/lib.rs Add subscription functions
smart-contracts/contracts/agent_registry/src/types.rs Add Subscription struct
smart-contracts/contracts/agent_registry/src/errors.rs Add subscription error codes
smart-contracts/contracts/agent_registry/src/events.rs Add subscription events
smart-contracts/contracts/agent_registry/src/test.rs Add subscription tests

How to Contribute

  1. Create branch feat/agent-subscriptions
  2. Design subscription storage structure
  3. Implement create/renew/cancel functions
  4. Add prorated refund calculation
  5. Write comprehensive unit tests
  6. Run cargo test and cargo clippy before submitting PR

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions