MyFans is a decentralized content subscription platform built on Stellar and Soroban. It lets creators monetize their work with on-chain subscriptions, direct payments, and transparent revenueβusing Stellarβs speed, low cost, and multi-currency support.
- Speed & cost: 3β5 second finality and very low fees, suitable for subscriptions and micro-payments.
- Multi-currency: Native support for XLM and Stellar assets (e.g. USDC, EURT) so fans can pay in stablecoins or XLM.
- Soroban: Rust/Wasm smart contracts with deterministic execution and a strong SDK.
- Ecosystem: Anchors and on/off-ramps can connect subscriptions to fiat (card, bank).
- Scale: Stellar handles high throughput; no gas auctions or volatile fees.
| Problem | MyFans approach |
|---|---|
| High platform fees | Direct creator payouts; small, transparent protocol fee. |
| Delayed or opaque payments | On-chain subscriptions and instant settlement. |
| Single-currency lock-in | Pay in XLM or any Stellar asset (e.g. USDC). |
| Centralized access control | Subscription and access enforced in Soroban contracts. |
| No fiat-friendly path | Backend + frontend can integrate anchors/ramps for card/bank. |
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β MyFans Platform β
βββββββββββββββββββ¬ββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββ€
β frontend/ β backend/ β contract/ β
β (Next.js) β (Nest.js) β (Soroban/Rust) β
βββββββββββββββββββΌββββββββββββββββββββββββββΌββββββββββββββββββββββββββββββ€
β β’ Wallet connectβ β’ Auth & sessions β β’ Subscription lifecycle β
β (Freighter, β β’ Creator/fan APIs β β’ Payment routing & fees β
β Lobstr, etc.)β β’ Content metadata β β’ Access control (is β
β β’ Creator β β’ IPFS / storage refs β subscriber?) β
β dashboard β β’ Webhooks / events β β’ Multi-asset payments β
β β’ Fan discovery β β’ Indexer / analytics β β’ Pause, cancel, renew β
β β’ Subscription β β’ Notifications β β
β management β β’ Contract event poller β β
β β β’ JWT auth (Stellar key) β β
ββββββββββ¬βββββββββ΄βββββββββββββ¬βββββββββββββ΄βββββββββββββββ¬βββββββββββββββ
β β β
βββββββββββββββββββββββΌβββββββββββββββββββββββββββββ
βΌ
ββββββββββββββββββββββββ
β Stellar / Soroban β
β (XLM, USDC, etc.) β
ββββββββββββββββββββββββ
| Folder | Role |
|---|---|
contract/ |
Soroban smart contract (Rust). Subscription state, payments, access control. |
frontend/ |
Next.js app. Creator and fan UI, wallet connection, subscription flows. |
backend/ |
Nest.js API. Auth, content metadata, IPFS refs, indexing, notifications. |
You will keep only these three folders and this README; other files can be removed.
New here? Start with the QUICKSTART.md β the single canonical first-hour guide from a clean clone to subscribing on Stellar testnet with Freighter. It covers the honest wallet support matrix, required environment variables (including where contract ids come from), the local Docker Compose stack, and CSP/network troubleshooting.
- QUICKSTART.md β clone-to-subscribe on testnet (Freighter-first).
- Contract Upgrade Governance β required process, upgrade log, and rollback criteria for mainnet contract upgrades.
- Contract Changelog β version history for the Soroban contracts.
- Security Policy β how to report vulnerabilities.
- Subscription lifecycle: Create subscription (plan, asset, amount, interval), renew, cancel, pause.
- Payment logic: Accept payments in configured Stellar asset; split creator vs protocol fee; optional escrow for chargebacks/disputes.
- Access control: Expose βis subscriberβ (and optionally tier/expiry) for backend/frontend to gate content.
- Multi-asset: Support XLM and Stellar tokens (e.g. USDC) so creators can choose accepted assets.
init(admin, protocol_fee_bps, fee_recipient)β set fee (in basis points) and recipient. Admin-only; the fee is capped atMAX_FEE_BPS = 1_000(10%) and can never be set to 100%.fee_recipientmust be the deployed treasury contract.set_protocol_fee_bps(admin, bps)β admin-only (require_authon the stored admin; non-admin callers revert). Enforcesbps <= MAX_FEE_BPS(1_000= 10%);bps > 1_000(e.g.10_000or10_001) reverts.bps = 0is explicitly allowed and disables the protocol fee. Emits aFeeUpdatedevent for indexers/analytics.set_fee_recipient(admin, recipient)β admin-only. The recipient is restricted to the deployed treasury contract (allowlisted); setting it to any other address (e.g. a fan address) reverts. This keeps the treasury recipient invariant intact.create_plan(creator, asset, amount, interval_days)β define a subscription plan.subscribe(fan, plan_id, duration)β fan subscribes; payment is split: creator receives the amount minus the protocol fee, and the fee is routed into the treasury via itsdeposit(from, amount)entry point (pause honored,depositevent emitted).renew(subscription_id)β renew if within allowed window.cancel(subscription_id)β cancel; no refund of current period (or implement refund rules in contract).is_subscriber(fan, creator)β bool (and optionally expiry).- Events for: subscription_created, payment_received, subscription_cancelled, fee_updated (for indexer/backend).
- Rust, soroban-sdk.
- Build & test: stellar-cli / soroban-cli; deploy to Stellar testnet/mainnet via CLI or CI.
Contract upgrades on mainnet MUST follow
docs/CONTRACT_UPGRADE_GOVERNANCE.md,
including the upgrade log and rollback criteria.
- Wallets: Connect Freighter, Lobstr, or other Stellar wallets (via standard Stellar/Soroban wallet interfaces).
- Creators: Dashboard to create plans, set pricing (XLM or asset), view subscribers and earnings.
- Fans: Discover creators, view plans, subscribe (sign Soroban tx), manage active subscriptions.
- UX: Show subscription status, next billing, and βaccess grantedβ for gated content.
The current frontend wallet implementation does not treat all wallets equally:
| Wallet | Current repo status | Practical difference in MyFans |
|---|---|---|
| Freighter | Fully wired for connection and transaction signing | The reference wallet. Guaranteed for every flow; local onboarding (see QUICKSTART.md) is Freighter-only |
| Lobstr | Connection and signing dispatch wired (signTransaction routes to Lobstr when it is the connected wallet) |
Usable for connect + subscribe/cancel signing; still less battle-tested than Freighter |
| WalletConnect | Sign Client wired behind the walletConnect feature flag (off by default); requires NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID |
Enable the flag + set a project ID for QR-based mobile wallet connect/sign. With the flag off the UI shows "Coming soon" |
Assume Freighter is the reference implementation and the only wallet with a guaranteed full-flow path. Lobstr and WalletConnect share the same signTransaction dispatch path but have had less real-world exercise. See frontend/docs/WALLET_SETUP.md for the full support matrix, feature-flag config, and signing dispatch order.
- Next.js (App Router or Pages as you prefer).
-
- Auth: Sessions or JWTs; link Stellar public key to βuserβ (creator/fan).
- Creator/fan APIs: Profiles, plans metadata (mirroring or complementing on-chain plan_id), content catalog.
- Content & IPFS: Store content metadata and IPFS links; serve βcontent accessβ API that checks subscription via contract (e.g. call
is_subscriberor use indexer data). - Indexer: Subscribe to Soroban events or use Stellar Horizon + Soroban events to keep βsubscriptionsβ and βpaymentsβ in DB for analytics and fast βis subscriber?β checks.
- Notifications: Email/in-app for new subscribers, renewals, cancellations (using indexer/events).
- Optional: Integrate Stellar anchors/ramps for fiat on/off-ramp.
- Nest.js, TypeScript.
- DB: e.g. PostgreSQL (users, plans metadata, content, subscription cache
- Creator sets a plan on-chain (contract) and optionally registers plan metadata in backend.
- Fan chooses a plan in frontend; frontend builds Soroban
subscribetx; fan signs with Stellar wallet; contract executes payment and updates subscription state. - Backend indexes contract events (or polls contract), updates DB; when fan requests gated content, backend checks DB or calls contract to confirm
is_subscriber. - Frontend shows βSubscribed until β¦β and
| Layer | Technologies |
|---|---|
| Chain & contracts | Stellar, Soroban, Rust, soroban-sdk, stellar-cli |
| Frontend | Next.js, TypeScript, Stellar SDK, wallet integration |
| Backend | Nest.js, TypeScript, PostgreSQL (or similar), Stellar/Soroban RPC, IPFS (metadata/refs) |
| Storage | IPFS (content refs), DB (metadata, indexer cache) |
-
Contract
- Implement subscription lifecycle (create plan, subscribe, renew, cancel).
- Implement payment split (creator + protocol fee) for one asset, then multi-asset.
- Emit events; add access control (
is_subscriber). - Unit tests; deploy to testnet.
-
Backend
- Nest.js project; auth (Stellar key β user); CRUD for creators, plans metadata, content.
- Integrate Soroban RPC; event indexer or polling; βis subscriber?β API.
- IPFS for content refs; optional notifications.
-
Frontend
- Next.js; wallet connect; creator dashboard (create plan, view earnings); fan flow (discover, subscribe, manage subscriptions).
- Use backend for metadata and access checks; use contract for tx signing and state.
-
Integration
- End-to-end: create plan β subscribe β access gated content.
- Optional: fiat on-ramp (anchor) so fans can pay with card. See Fiat On-Ramp Spike.
-
Launch
- Testnet beta (runbook, bug bash); security review; mainnet deployment (readiness gate); docs and community.
Install dependencies for all packages:
./scripts/myfans install
# or: npm run install:allBuild everything:
./scripts/myfans build
# or: npm run buildRun dev servers (separate terminals):
./scripts/myfans dev:backend # NestJS API on :3001
./scripts/myfans dev:frontend # Next.js app on :3000Full local verification (lint + test + build):
./scripts/myfans checkPer-package commands are also available via root package.json scripts (build:backend, test:contract, etc.) or by cd-ing into each folder:
- Contract:
cd contract && cargo test;npm run buildfor WASM artifacts (deploy with stellar-cli). See Contract Testing Guide. - Backend:
cd backend && npm ci && npm run start:dev. - Frontend:
cd frontend && npm ci && npm run dev.
- Contract Testing Guide - Comprehensive testing patterns and best practices for Soroban contracts
- Regression Testing Guide - How contract regression testing is enforced in CI
- Regression Prevention Checklist - Developer checklist for PR submission
- Contract Branch Protection - CI status checks required before merge
- Contract Interfaces - Method documentation for each contract
- Contract Upgrade Governance - Process for upgrading smart contracts safely
- Security Policy - Security reporting, penetration testing tracker, and best practices
- Secret Management - JWT and secret rotation runbooks
- CORS & Security Headers - Per-environment CORS allowlist and header configuration
- Bug Bash Checklist - Binary pass/fail testnet beta checklist: money path, auth, gating, pause, CSRF/CSP headers, a11y
- Testnet Beta Runbook - Ordered launch steps: deploy contracts, set IDs, enable poller, pause drill, invites, rollback
- Mainnet Readiness Gate - Go/no-go checklist: audits, pause tested, backups, monitoring, fee caps, sign-off
- Fiat On-Ramp Spike - Anchor/ramp evaluation, threat model, and MVP recommendation
- Changelog Guide - How to use conventional commits for automatic changelog generation
- Postgres Backup / Restore - Backup runbook, restore decision tree, and CI drill
- Dependency Update Policy - Dependabot schedule, grouping, and review rules for bot PRs
- E2E Testnet Path - Create plan β subscribe β gated access proof on testnet, with nightly job
- Changelog - Automatically generated from conventional commits
- Upgrade Log - Historical record of contract upgrades
MIT.
- Email: realjaiboi70@gmail.com
This README describes the MyFans project on Stellar. Implement each module (contract, backend, frontend) step by step as needed.
- #1781: SubscriptionsModule: checkout, index, spending-cap, swagger completeness
- #1751: creator-deposits: stake/deposit withdraw securityβunauthorized withdraw leaves stake unchanged
- #1753: myfans-lib: eliminate panics from library paths; stable error_codes for all callers
- #1791: FavoritesModule persistence APIs replacing local-only context as source of truth
- #1794: EarningsModule prepare/confirm withdraw orchestration with chain
- #1788: FeedModule: subscription-gated teasers, cursor pagination, no full body leak
- #1821: Fan subscriptions pages: active/history/payments from /v1/subscriptions only