SubscriptionManager.sol

RecurrBase uses an upgradeable UUPS contract deployed on Base L2.

Features:

  • USDC billing

  • On-chain expiration

  • Owner-triggered auto-renew

  • Cancel (expire immediately)

  • UUPS upgradeable


Contract Address

The SubscriptionManager contract is deployed on Base mainnet. Contract address and ABI are available in the API configuration.


Functions

subscribe(uint256 months)

User pays USDC → extends subscription.

function subscribe(uint256 months) external nonReentrant {
  // Transfers USDC from user to treasury
  // Updates expiration timestamp
  // Emits Subscribed event
}

autoRenew(address user, uint256 months)

Keeper triggers auto renewal.

function autoRenew(address user, uint256 months)
  external
  nonReentrant
  onlyOwner
{
  // Uses user's USDC allowance
  // Extends subscription expiration
  // Emits Subscribed event
}

Only the contract owner (RecurrBase keeper) can call autoRenew. Users must approve USDC allowance first.


cancel()

User ends subscription immediately.

function cancel() external nonReentrant {
  // Sets expiration to current timestamp
  // Emits Cancelled event
}

isActive(address user)

Returns true if subscription is valid.

function isActive(address user) public view returns (bool) {
  return expiration[user] > block.timestamp;
}

State Variables

IERC20 public usdc;                    // USDC token address
uint256 public monthlyPrice;           // Price per 30-day period
address public treasury;               // Payment recipient
mapping(address => uint64) public expiration;  // User expiration timestamps

Events

event Subscribed(
  address indexed user,
  uint256 months,
  uint64 newExpiration,
  uint256 amountPaid
);

event Cancelled(address indexed user, uint64 previousExpiration);

Integration

ABI & address are exported into API config after deployment.

See Deployment Info.