Alert Source Discuss
⚠️ Draft Standards Track: ERC

ERC-6932: Subscription-Based Token

ERC-20 extension providing access to a service or product that requires recurring payments.

Authors 360 Core <hello@360coreinc.com>, Robin Rajput (@0xRobinR)
Created 2023-04-25
Discussion Link https://ethereum-magicians.org/t/erc-subscription-based-erc20-token/13964
Requires EIP-20

Abstract

This subscription-based ERC-20 token extends the basic ERC-20 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 token standard will enable automatic periodic deductions from user balances as determined by the merchant subscriber. Simplify and streamline subscription-based services on the Ethereum network, offering enhanced convenience and efficiency for users and merchants alike.

A renewSubscription method, that will 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 rise of subscription-based business models necessitates a standardized approach to handle recurring payments on the Ethereum blockchain. Currently, users often manually initiate subscription payments, resulting in inconvenience and potential disruptions in service delivery. By introducing a Subscription Token, users can seamlessly authorize periodic deductions, enabling uninterrupted access to subscribed services.

The subscription-based ERC-20 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.

The Subscription Token ensures consistency and interoperability across different implementations. Key features include:

  • Auto Deduction: Merchants, acting as subscribers, can set the subscription interval and associated payment amount for their services. This information is encoded within the Subscription Token contract, enabling automatic deductions from user balances at regular intervals without requiring manual intervention.

  • Balance Check: Users can verify the remaining balance of their subscription tokens at any given time. This transparency empowers users to monitor their subscriptions and make informed decisions regarding their ongoing commitment to the service.

  • Flexibility: The Subscription Token framework accommodates various subscription models, such as monthly, quarterly, or annual billing cycles. Additionally, merchants have the option to define trial periods, upgrade/downgrade plans, and cancellation policies, providing a versatile foundation for a wide range of subscription-based businesses.

  • Security: The Subscription Token employs established security measures, including the use of cryptographic signatures, to ensure the integrity and authenticity of subscription-related transactions. This protects both users and merchants from unauthorized access and potential malicious activities.

Specification

Below are the implementaions required by the standard:

SubscriptionToken

subscribers

Returns the list of addresses subscribed to the subscription token contract.

subscriptionInfo

Metadata information of the subscription, like - subscriptionID, subscriptionName, subscriptionDesc and subscriptionTandC.

subscriptionFee

The subscription amount specified that will be deducted in subscriptionFrequency interval, when an address subscribes to the subscription token contract.

subscriptionFrequency

Frequency of subscription, interval at which the subscriptionFee will be charged. for example, every 1 day, 1 week or 1 month, denoted in seconds.

subscribe

Method for subscribing an address to the subscription token contract.

unsubscribe

Revoke subscription from the subscription token contract, by the subscribed address.

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

  /// @dev information of the subscription token contract
  /// @return subscriptionID, subscriptionName, subscriptionDesc, subscriptionTandC
  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

The subscription token contract inherits the fundamentals of subscription by deducting payments from subscribed addresses on a regular interval using mathematical formulas.

uint256 intervals = ( block.timestamp - info.start ) / info.frequency;
uint256 amount = info.amount * intervals;

uint256 localEffectiveBalance = effectiveBalance[account];

if ( (totalAmount + amount) > localEffectiveBalance ) {
    amount = localEffectiveBalance;
}

totalAmount += ( localEffectiveBalance - amount );

Here, the token balance of the address is calcuated using, the locked balances from ongoing subscripitons and the effective balance of the address (updates whenever a transfer is made).

Backwards Compatibility

No backward compatibility issues found.

Security Considerations

Subscription Tokens may require users to sign transactions or provide cryptographic proofs for subscription-related actions. Proper key management practices should be followed to protect users’ private keys and prevent unauthorized access. Encouraging the use of hardware wallets or secure key storage solutions can mitigate the risk of key compromise.

Copyright and related rights waived via CC0.

Citation

Please cite this document as:

360 Core <hello@360coreinc.com>, Robin Rajput (@0xRobinR), "ERC-6932: Subscription-Based Token [DRAFT]," Ethereum Improvement Proposals, no. 6932, April 2023. [Online serial]. Available: https://eips.ethereum.org/EIPS/eip-6932.