Technical Documentation
Comprehensive technical documentation for developers, integrators, and protocol participants building on the Playlist Token ecosystem.
Getting Started
Prerequisites
Development Environment
- • Node.js 18+ or Python 3.9+
- • Solana CLI tools
- • Anchor framework (for Rust)
- • Git for version control
Blockchain Setup
- • Solana wallet (Phantom, Solflare)
- • Devnet SOL for testing
- • RPC endpoint access
- • Basic Solana knowledge
Installation
JavaScript/TypeScript SDK
npm install @playlist-protocol/sdk
# or
yarn add @playlist-protocol/sdk
Python SDK
pip install playlist-protocol-py
Rust Crate
[dependencies]
playlist-protocol = "1.0.0"
Quick Start Example
import { PlaylistProtocol, Connection } from '@playlist-protocol/sdk';
// Initialize connection
const connection = new Connection('https://api.devnet.solana.com');
const protocol = new PlaylistProtocol(connection);
// Create a new playlist
const playlist = await protocol.createPlaylist({
name: "My Awesome Playlist",
description: "A curated collection of indie hits",
tracks: [/* track metadata */],
initialStake: 100 // $PLAY tokens
});
// Stake on an existing playlist
await protocol.stakeOnPlaylist({
playlistId: "playlist_id_here",
amount: 50 // $PLAY tokens
});
// Listen for performance updates
protocol.onPlaylistUpdate((update) => {
console.log('Playlist performance:', update);
});
API Reference
Core Protocol Methods
createPlaylist(params)
Creates a new playlist NFT and initializes its performance vault.
Parameters:
- •
name
: string - Playlist display name - •
description
: string - Playlist description - •
tracks
: Track[] - Array of track metadata - •
initialStake
: number - Initial $PLAY stake amount - •
spotifyUrl
: string (optional) - Spotify playlist URL
stakeOnPlaylist(params)
Stakes $PLAY tokens on an existing playlist to signal quality.
Parameters:
- •
playlistId
: string - Unique playlist identifier - •
amount
: number - $PLAY tokens to stake - •
lockPeriod
: number (optional) - Stake lock duration in days
getPlaylistData(playlistId)
Retrieves comprehensive playlist data including performance metrics.
Returns:
- •
metadata
: Playlist name, description, tracks - •
stakeData
: Total stake, staker count, influence score - •
performance
: Followers, growth rate, reward history - •
vault
: Available rewards, distribution schedule
Oracle Data Access
getSpotifyMetrics(playlistId)
Fetches latest Spotify performance data from oracle feeds.
subscribeToUpdates(callback)
Subscribe to real-time oracle updates for performance tracking.
Smart Contract Interfaces
Registry Module
Program ID:
PLAYreg...abc123
- •
initialize_playlist
- •
update_metadata
- •
transfer_ownership
- •
mint_playlist_nft
Exposure Pool
Program ID:
PLAYexp...def456
- •
stake_tokens
- •
unstake_tokens
- •
calculate_influence
- •
get_ranking_score
Performance Vault
Program ID:
PLAYvlt...ghi789
- •
distribute_rewards
- •
claim_earnings
- •
update_performance
- •
calculate_yield
Oracle Feed
Program ID:
PLAYorc...jkl012
- •
submit_data_feed
- •
verify_signatures
- •
get_latest_data
- •
challenge_data
Code Examples
React Integration
import { usePlaylistProtocol } from '@playlist-protocol/react';
function PlaylistStaker({ playlistId }) {
const { stakeOnPlaylist, getStakeData } = usePlaylistProtocol();
const [stakeAmount, setStakeAmount] = useState(10);
const [stakeData, setStakeData] = useState(null);
useEffect(() => {
getStakeData(playlistId).then(setStakeData);
}, [playlistId]);
const handleStake = async () => {
await stakeOnPlaylist({
playlistId,
amount: stakeAmount
});
};
return (
<div>
<h3>Stake on Playlist</h3>
<input
type="number"
value={stakeAmount}
onChange={(e) => setStakeAmount(e.target.value)}
/>
<button onClick={handleStake}>Stake $PLAY</button>
{stakeData && (
<div>Total Staked: {stakeData.totalStake} $PLAY</div>
)}
</div>
);
}
Discord Bot Integration
import discord
from playlist_protocol import PlaylistProtocol
class PlaylistBot(discord.Client):
def __init__(self):
super().__init__()
self.protocol = PlaylistProtocol()
async def on_message(self, message):
if message.content.startswith('!stake'):
args = message.content.split()
playlist_id = args[1]
amount = int(args[2])
try:
result = await self.protocol.stake_on_playlist(
playlist_id=playlist_id,
amount=amount,
user_wallet=message.author.id
)
await message.reply(
f"Successfully staked {amount} $PLAY on playlist!"
)
except Exception as e:
await message.reply(f"Staking failed: {e}")
bot = PlaylistBot()
bot.run(TOKEN)