Proof of Play - Mining Music for Block (Rock) Rewards - Pop!

Music NFTs are an exciting and growing use case for NFTs and composable digital assets, but the main use cases are as proof of ownership such as ticketing, royalties, or supporting artists financially. These are fine use cases, but limited in what's possible with composable token systems.

Proof of Play (PoP) gives listeners the opportunity to prove their fandom with real listening time. Time, the mining hashing algorithm, runs while fans listen to tracks from an album. Listeners are rewarded with the ability to mint NFTs. PoP uses Time to show that listeners spent real time listening to an artist's music.

The artists benefit from having people genuinely listen to tracks and get to distribute NFTs for loyalty, art, or other use cases such as raffles, whitelists, or gaming activations. The fans benefit from being incentivized to listen to new music and get NFT rewards as badges or as limited edition collectibles.

What That Code Do

PoP uses Chainlink Any API to connect the user's individual Spotify account to the contract. As a track from an album plays, the contract engages the Time mining algorithm that generates blocks at a configurable fixed block time. At each block, the current listeners have a chance to be selected to receive the block reward. Time weights a listener's probability of receiving the block reward according to the amount of time spent listening to any track on the album. The configuration can also increase the difficulty of mining so that mining a block reward becomes more rare over time.

The block reward gives the listener the ability to mint one NFT from any number of NFT token IDs. In the case of the demo, we use Chainlink VRF to randomly select which one from three possible NFTs. PoP can also weight the VRF response to allow minting to be done according to a rarity scale such that some rewards are awarded less frequently than others.

We check the Spotify API to determine of the playing track is part of an album with an associated NFT collection, and we also maintain a heartbeat check to determine the amount of time elapsed while playing tracks.

Building PoP: Play that funky music

The backend is built using Node.js, the most helpful and used libraries being ethers.js, socket.io, promise-mysql and express.

For the frontend, we implemented Rainbow Kit enabling users to connect to our app with their wallet address, and the Spotify API provided an authorization flow to access a user's currently playing track. This data was synced between the front and back end via Socket.io.

Challenges: Diiiirty PoP!

Ran into some fun challenges with implementing socket.io and ethers.js. Ricmoo, the creator of ethers.js, was always extremely helpful!

The Spotify App requires an admin to setup user profiles, so the specific scalability of using Spotify's API does not have a clear solution. Fortunately, many open source and web3 media players are becoming more common, so we will be able to integrate different kinds of music apps in league with Infinity Keys profiles.

What's next for Proof of Play: Pop Star!

Time: Rewriting Time in golang. Infinity Keys: Finding use cases for web3 musicians to use PoP as part of Infinity Keys challenges, integrating non-Spotify sources of music such as OohLaLaPlayer in the Lens ecosystem, and setting up multichain NFTs so listeners can mint on Polygon.

Built With

Share this project:

Updates