Giter VIP home page Giter VIP logo

anchor-subscriptions's Introduction

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.

anchor-subscriptions's People

Contributors

jamesrp13 avatar nilz3ro avatar overacheiever avatar plege-xyz avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.