MCPcopy Index your code
hub / github.com/Unboxed-Software/anchor-subscriptions

github.com/Unboxed-Software/anchor-subscriptions @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
237 symbols 457 edges 92 files 1 documented · 0%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Plege - On-chain subscriptions

Plege is a Solana-based payments provider dedicated to reaching Web2 feature parity and beyond. This repository hosts our on-chain subscriptions payment program and an accompanying client-side SDK.

The program is written using Rust and Anchor. Its payment automation works using clockwork threads, thus eliminating any reliance on client-side automation.

The program is currently live on Devnet with program Id 7xMy6CDMk3ANhRBEMorr9A3EJt5qWcQq64MeqGdC9JpA.

We will be live on Mainnet-beta shortly.

Interacting with the Subscriptions Program

The easiest way to interact with the subscriptions is using the Typescript SDK.

This SDK is published as @plege/subscriptions. You can bring it into your JS/TS projects using the following:

npm install @plege/subscriptions

To see an example of how to interact with the program, take a look at our demo frontend repo.

The package is broken into three primary namespaces user, app, and tier.

user

user exposes basic functionality for creating and fetching a user with the following functions:

  • createUser - creates a new user
  • fetchUser - fetches an existing user

The corresponding on-chain account is of type UserMeta and represents an authority under which multiple subscriptions apps can be created.

app

app exposes functionality for creating and interacting with subscriptions apps. The corresponding account on-chain is App. It can be thought of as a way to bundle related subscriptions so you can easily identify what to serve up to subscribers.

Through the app namespace you have the following:

  • create - creates a new app
  • fetch - fetches an existing app
  • get.subscriptions.all - gets all active subscriptions to a given app
  • get.subscriptions.count - gets a count of all the active subscriptions to a given app
  • get.subscriptions.groupedByTier - gets all active subscriptions to a given app grouped by their tier
  • get.tiers.all - gets all tiers for a given app
  • get.tiers.count - gets the tier count for a given app

tier

Tiers are a owned by apps. This allows flexibility in how you design your subscriptions. For example, you can create a tier that represents a base level monthly membership and another that represents a base level yearly membership.

This namespace surfaces the following:

  • create - creates a new tier belonging to a given app
  • fetch - fetches an existing tier
  • pauseTier - pauses new subscriptions to a given tier
  • unpauseTier - allows new subscriptions to a previously paused tier
  • disable - permanently disables a tier. Note that this makes it so no new subscribers can subscribe to this tier and also terminates all existing subscriptions to that tier.
  • get.subscriptions.all - gets all active subscriptions to a given tier
  • get.subscriptions.count - gets a count of all active subscriptions to a given tier

Referral program

In addition to our subscription program, we've created a referral program that builds on top of our subscription program. This program allows merchants to split payments among multiple parties, one of which is a "referral agent."

While this can be flexible, you can think of a referral agent as a brand ambassador who receives "commission" for making a sale. In Web2, it's like giving a podcaster a referral code it share with listeners. When a listener uses the referral code to subscribe, the podcaster gets a cut.

This program will be released with the week.

Extension points exported contracts — how you extend this code

Tier (Interface)
(no doc)
client/subscription-sdk/lib/subscription-sdk/src/types/interfaces.d.ts
Subscription (Interface)
(no doc)
client/subscription-sdk/lib/subscription-sdk/src/types/interfaces.d.ts
App (Interface)
(no doc)
client/subscription-sdk/lib/subscription-sdk/src/types/interfaces.d.ts
User (Interface)
(no doc)
client/subscription-sdk/lib/subscription-sdk/src/types/interfaces.d.ts
Tier (Interface)
(no doc)
client/subscription-sdk/src/types/interfaces.ts

Core symbols most depended-on inside this repo

from
called by 49
programs/referrals/src/state/splits.rs
generateFundedKeypair
called by 14
tests/utils/keypair.ts
createSubscription
called by 14
tests/utils/basic-functions.ts
assert_unique_split
called by 7
programs/referrals/src/assertions.rs
getProgram
called by 6
client/subscription-sdk/src/config/config.ts
subscriptionAccountKey
called by 5
client/subscription-sdk/lib/shared/utils/pda-derivations.js
tierAccountKey
called by 5
tests/utils/basic-functions.ts
completePayment
called by 5
tests/utils/basic-functions.ts

Shape

Function 186
Class 23
Method 13
Interface 8
Enum 7

Languages

TypeScript70%
Rust30%

Modules by API surface

client/subscription-sdk/lib/subscription-sdk/src/queries/subscription-queries.js16 symbols
tests/utils/basic-functions.ts13 symbols
programs/plege/src/lib.rs12 symbols
client/subscription-sdk/lib/subscription-sdk/src/creator-actions/creator-actions.js12 symbols
client/subscription-sdk/src/queries/subscription-queries.ts11 symbols
client/subscription-sdk/lib/subscription-sdk/src/subscriber-actions/subscriber-actions.js9 symbols
client/subscription-sdk/lib/shared/utils/pda-derivations.js9 symbols
client/shared/utils/pda-derivations.ts9 symbols
client/subscription-sdk/src/creator-actions/creator-actions.ts8 symbols
client/subscription-sdk/lib/subscription-sdk/src/queries/tier-queries.js8 symbols
programs/plege/src/state/callback.rs7 symbols
programs/referrals/src/state/splits.rs6 symbols

For agents

$ claude mcp add anchor-subscriptions \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact