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?