Add Solana wallet middleware for coin-gated streams#738
Merged
raymondjacobson merged 5 commits intomainfrom Mar 26, 2026
Merged
Add Solana wallet middleware for coin-gated streams#738raymondjacobson merged 5 commits intomainfrom
raymondjacobson merged 5 commits intomainfrom
Conversation
New middleware verifies ed25519 signatures from X-Solana-Wallet, X-Solana-Message, and X-Solana-Signature headers. When standard access check fails, the stream endpoint falls back to real-time on-chain token balance verification via Solana RPC for wallets that hold the required artist coin. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
5 tasks
dylanjeffers
approved these changes
Mar 26, 2026
api/solana_wallet_access.go
Outdated
| zap.Bool("hasAccess", int64(balance) >= scaledRequired), | ||
| ) | ||
|
|
||
| return int64(balance) >= scaledRequired, nil |
A valid PKCE access token already proves the user authorized the client app during the OAuth consent flow. The on-chain grant check is redundant for these requests and fails for read-only apps that don't have a grant registered in the grants table. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Move token gate checks for Solana wallets from the stream endpoint into GetBulkTrackAccess via a TokenBalanceFetcher callback. Balances are looked up from the indexed sol_token_account_balances table instead of Solana RPC, removing the RPC dependency entirely. - Add TokenBalanceFetcher type and optional param to GetBulkTrackAccess - Replace RPC-based checkSolanaWalletTokenAccess with DB-backed fetcher - Remove inline fallback in v1TrackStream — access is now pre-calculated - Remove unused BuildMediaLink export - Add middleware test for Solana wallet signature verification Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace the TokenBalanceFetcher abstraction with a plain solanaWallet string parameter. When present, a parallel query against sol_token_account_balances runs alongside the existing sol_user_balances lookup, merging the higher balance per mint after both complete. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
raymondjacobson
added a commit
to AudiusProject/apps
that referenced
this pull request
Mar 26, 2026
## Summary - New example web app at `packages/web/examples/coin-gated/` demonstrating token-gated track browsing and streaming using artist coins - Supports two auth paths: Audius OAuth (PKCE) and direct Solana wallet signing (Phantom) - Uses `sdk.coins.getCoinByTicker()` to look up coins, `sdk.users.getTracksByUser()` with `gateCondition: ['token']` to list gated tracks, and `sdk.tracks.streamTrack()` for authenticated streaming - Companion API changes in AudiusProject/api#738 ## Test plan - [x] `cd packages/web/examples/coin-gated && npm install && npm run dev` - [x] Enter a coin ticker (e.g. `YAK`) and verify coin info + gated tracks load - [x] Sign in with Audius OAuth and verify access status updates on tracks - [x] Connect Phantom wallet and verify wallet-based streaming works - [x] Verify locked tracks show disabled play button when not authenticated 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
solanaWalletMiddlewareverifies ed25519 signatures fromX-Solana-Wallet,X-Solana-Message,X-Solana-SignatureheaderscheckSolanaWalletTokenAccesshelper performs real-time on-chain token balance checks via Solana RPC (derives ATA, callsGetTokenAccountBalance)v1TrackStream) falls back to Solana wallet balance check when standard access check fails, enabling coin-gated streaming for non-Audius walletsBuildMediaLinkfromdbv1package to support building stream URLs in the fallback pathTest plan
🤖 Generated with Claude Code