Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add EIP: Subscription-Based Token #6933

Closed
wants to merge 23 commits into from
Closed
Changes from 10 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 93 additions & 0 deletions EIPS/eip-360.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
---
eip: 360
0xRobinR marked this conversation as resolved.
Show resolved Hide resolved
title: Subscription-Based Token
description: access to a service or product that requires recurring payments.
author: 360 Core <[email protected]>, Robin Rajput (@0xRobinR)
discussions-to: https://ethereum-magicians.org/t/erc-subscription-based-erc20-token/13964
status: Draft
type: Standards Track
category: ERC
created: 2023-04-25
requires: 20
---

## Abstract

The subscription-based [ERC-20](./eip-20.md) token extends the basic [ERC-20](./eip-20.md) token standard with a `subscribe` and `unsubscribe` function, which allow users to subscribe or unsubscribe from the subscription service. The `subscriptionFee` and `subscriptionFrequency` variables define the cost and frequency of the subscription. The `nextPaymentDate` mapping keeps track of the next payment date for each subscriber.

This EIP also proposes adding `renewSubscription` functions to the token contract, that can be used by token holders to renew their subscription to a service or product that requires recurring payments in the form of the token.

## Motivation

The subscription-based [ERC-20](./eip-20.md) token provides a more flexible and convenient way to manage recurring payments. It can be used for a wide range of services and products that require regular payments, such as subscription-based content platforms, gaming services, and more.

## Specification

### SubscriptionToken

#### subscribers

subscribers list for the subscription

#### subscriptionInfo

struct containing metadata of the subscription, ex, `subscriptionID`, `subscriptionName`, `subscriptionDesc` and `subscriptionTandC`, and many more fields if reqd.

#### subscriptionFee

the fee amount for the subcription

#### subscriptionFrequency

frequency of subscription, interval at which the `subscriptionFee` will be charged.

#### subscribe

function to subscribe toh the subscription

#### unsubscribe

revoke subscription

```solidity
interface ISubscriptionERC20 {
/// @dev map subscribers address, returns address(0) if `idx` is not found
/// @param idx: the index of the map values
/// @return the address at index `idx` of subscribers
function subscribers(uint idx) external view returns (address);

/// @dev can be extended accorging to the requirements
/// @return subscriptionID, and metadata payload provided, may vary
function subscriptionInfo() external view returns ( uint, string memory, string memory, string memory );

/// @dev subscribes to the subscription, can be payable
function subscribe() external;

/// @dev unsubscribe the subscription
function unsubscribe() external;

/// @dev view or pure can be used
/// @return the subscription fee
function subscriptionFee() external view returns (uint256);

/// @dev view or pure can be used
/// @return get the subscription frequency
function subscriptionFrequency() external view returns (uint);
}
```

## Rationale

TBD

## Backwards Compatibility

No backward compatibility issues found.

## Security Considerations

Needs discussion.

## Copyright

Copyright and related rights waived via [CC0](../LICENSE.md).