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.
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
exposes basic functionality for creating and fetching a user with the following functions:
createUser
- creates a new userfetchUser
- 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
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 appfetch
- fetches an existing appget.subscriptions.all
- gets all active subscriptions to a given appget.subscriptions.count
- gets a count of all the active subscriptions to a given appget.subscriptions.groupedByTier
- gets all active subscriptions to a given app grouped by their tierget.tiers.all
- gets all tiers for a given appget.tiers.count
- gets the tier count for a given app
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 appfetch
- fetches an existing tierpauseTier
- pauses new subscriptions to a given tierunpauseTier
- allows new subscriptions to a previously paused tierdisable
- 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 tierget.subscriptions.count
- gets a count of all active subscriptions to a given tier
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.