u/iCryptoDude

▲ 3 r/NFT

Storing full audio files inside Clarity contracts: an experiment with on-chain music on Stacks

Most music NFTs I’ve seen are effectively a token plus a link to media hosted somewhere else.

I’ve been experimenting with a different approach on Stacks: storing the entire audio file directly in Clarity contract data, so the token does not depend on IPFS, a pinning service, or a normal web server to preserve the media.

The system I built is called Xtrata. The basic mint flow is:

initialize → write file in chunks → seal

The chunked writes allow a complete compressed audio file to be stored across contract calls. For example, a 96kbps Opus master can be written into contract storage and then reconstructed from the chain later. Some inscriptions are raw audio files, while others are self-contained HTML players with the artwork, title, artist, lyrics, and audio embedded together in one document.

The main thing I’m interested in is the permanence model. Once an item is sealed, the file is no longer just “metadata that points somewhere.” The media itself can be reconstructed from Stacks chain data.

I also made a radio-style interface as a proof of concept. Instead of playing from a normal hosted catalogue, it reads from the inscribed media catalogue. One mode is curated, one is based on saved items, and one walks through playable tokens on the contract. It can also discover newly minted playable items by watching the contract’s token counter.

There is also a simple relation system where inscriptions can declare parents or dependencies. That means a song can reference related artwork, another inscription, a previous version, or other connected media. Over time, this creates a mint-ordered graph of related on-chain files.

I’m curious what people here think about this model.

Is fully on-chain media worth the extra complexity and cost, or do you think token-plus-storage-layer approaches are still the better practical route for music NFTs?

reddit.com
u/iCryptoDude — 23 hours ago

Your music NFT is probably a URL. I built the opposite: the whole song on-chain, and a radio station to prove it

Quick test for any music NFT you own: find the tokenURI, follow it. If it resolves to somebody's API or an unpinned IPFS hash, your "permanent" collectible has a landlord.

Xtrata is my attempt at the opposite architecture. The complete file — not metadata, the actual audio — is chunked and written into smart-contract storage on Stacks (init → ~440KB write batches → seal). Songs can be raw Opus/MP3 audio or fully self-contained HTML players: one document with the audio, cover art, title and lyrics embedded. There is no pointer to rot. Any node can reconstruct the file; the site's /i/<id> endpoints just serve the on-chain bytes.

The existence proof is Xtrata Radio (xtrata.xyz/radio): a station whose entire catalogue is on-chain inscriptions. It reads the contract's minted-token counter to discover new songs, has a curated band and a full-chain exploration band, and the listeners' probes even share a communal "this token isn't playable" memory so the dial gets smarter over time. If the company/me/the website disappears, the music doesn't — that's the whole point.

Honest limitations: it's on Stacks (Bitcoin-anchored, but a layer — judge that tradeoff yourself), audio is optimised to 96k Opus rather than lossless (storage costs scale with bytes), and this is one builder's project, not a funded platform. No token, nothing to ape into — you pay mining fees to inscribe, that's the entire business model.

Architecture questions welcome.

reddit.com
u/iCryptoDude — 1 day ago
▲ 9 r/stacks

I built Xtrata: full audio files stored in Clarity contracts, plus a radio station whose entire catalogue lives on-chain

Most "music NFTs" are a token pointing at a URL. I wanted to see how far the other direction could go on Stacks: the entire file on-chain, no pointers, no IPFS, no pinning service.

Xtrata inscribes complete media files into Clarity contract storage. The mint flow is init → chunked writes (batches up to ~440KB) → seal, so a full 96kbps Opus master ends up living in contract data forever. Songs are inscribed either as raw audio or as self-contained HTML players — cover art, title, artist, lyrics and the audio itself embedded in one document. Once sealed, nothing about it depends on me or my servers: any Stacks node can reconstruct the file.

The fun part is Xtrata Radio (xtrata.xyz/radio): an internet radio station whose entire catalogue is inscriptions. It has three bands — FM (curated), LIKED (your saved songs), CHAIN (walks every playable token on the contract) — and it discovers new songs as they're minted by watching the contract's token counter. There's also a relations layer: inscriptions can declare parents/dependencies, which forms a mint-ordered DAG, so the radio can show a playing song's relatives (the artwork it references, other songs by the same lineage) and let you tune straight to them.

Everything is verifiable: every song has an /i/<id> endpoint that serves the actual on-chain bytes.

Site: xtrata.xyz

reddit.com
u/iCryptoDude — 1 day ago