Location: programs/royalty-tokenization/
Key Functions:
initialize_project: Creates a new royalty token projectbuy_tokens: Allows investors to purchase royalty tokensdistribute_royalties: Distributes streaming income to the treasuryclaim_royalties: Allows token holders to claim their share
Accounts:
Project: Stores project metadata and configurationMint: SPL token mint for the royalty tokensTreasury: PDA that holds SOL for distribution
Location: backend/
Key Features:
- RESTful API for project and royalty management
- Solana/Anchor integration
- Oracle service for Spotify API integration
- Automated cron jobs for royalty distribution
Endpoints:
GET /health- Health checkGET /api/projects- List projectsGET /api/projects/:address- Get project detailsGET /api/royalties/:projectAddress- Get distribution historyGET /api/royalties/claimable/:wallet/:project- Get claimable amountPOST /api/oracle/distribute- Trigger distributionPOST /api/oracle/spotify/fetch- Fetch Spotify dataPOST /api/oracle/cron/start- Start automated distribution
Location: frontend/
Key Features:
- Wallet connection (Phantom, Solflare)
- Project browsing and selection
- Token purchase interface
- Royalty claiming interface
- Modern, responsive UI
- User connects wallet in frontend
- User selects project and enters purchase amount
- Frontend calls smart contract
buy_tokensfunction - SOL is transferred to treasury PDA
- Tokens are minted to user's wallet
- Oracle service fetches streaming data (Spotify API)
- Revenue is calculated based on streams
- Distribution amount is calculated (royalty_percentage * revenue)
- Backend calls smart contract
distribute_royaltiesfunction - SOL is transferred to treasury PDA
- Project's
total_distributedis updated
- User connects wallet and selects project
- Frontend calculates claimable amount (proportional to holdings)
- User clicks "Claim"
- Frontend calls smart contract
claim_royaltiesfunction - SOL is transferred from treasury to user's wallet
- Oracle Authorization: Only artist or authorized oracle can distribute royalties
- PDA Signing: Treasury operations use PDA seeds for signing
- Math Safety: All calculations use checked arithmetic to prevent overflow
- Input Validation: All functions validate inputs before processing
- Multi-source Royalties: Support for Apple Music, YouTube, etc.
- Secondary Market: Token trading on DEX
- Governance: Token holder voting on project decisions
- Analytics Dashboard: Detailed revenue and distribution analytics
- Automated Oracle: Chainlink or Pyth integration for price feeds