Decentralized Music Application
https://demus-97702bb1205c.herokuapp.com
DeMus (Decentralized Music Application) is a react based application which lets artists upload their music risk free. It uses blockchain and IPFS to prevent single point of failure, so that artists don't have to do record maintanence. It also ensures that the talent of the artist is secured by creating a fingerprint of their music and storing it on blockchain. Everytime someone tries to upload a music, the application checks if there's already a similar fingerprint on chain or not and only lets you upload songs which are unique to the platform. This makes sure that uploaded songs aren't cpoied or republished without artists' knowledge.
The platform also has its own tokens called $VIBE tokens. When you register, you get 10,000 $VIBE tokens by default and you can always mint more if you're running out. One of the most essential feature of the application is that you can use $VIBE to tip the artists directly which eliminates all the intermediaries who take a big chunk from artists' hardwork.
There's another section 'My Music' which keeps a track of songs that you uploaded so that you always know how far you've come.
Enjoy the App
Here's a breakdown of different components:
For user authentication, I've used Firebase which creates a document of your email, username and creates a unique user id when you sign-up which is then retrieved when you login.
For the front-end I've used ReactJS with MaterialUI, trying to keep it simple and as much abstracted as possible, not showing any wierd alerts, pop-ups or scary json strings. For interaction with backend, I've used Axios (DeMus/frontend/src/services/api.js)
For backend I've used NodeJS and ExpressJS for handling server-side operations and defining API endpoints. I've used CORS to send mutli-part data to blockchain.js, and Multer to save files temporarily in uploads for fingerprint generation.
For fingerprint generation, I've used a C library called chromaprint (https://github.com/acoustid/chromaprint) which implements a custom algorithm for extracting fingerprints from any audio source. I'm using the linux version of this library because my backend runs on a linux based OS but for testing and local running I used windows version (Download - https://acoustid.org/chromaprint).
For smart contracts, I have two primary smart contracts, Vibe.sol which was developed using OpenZeppelin. It creates $VIBE tokens for the platform set at default 10,000. And second one is RegisterMusic.sol which has primary functions:
- registerTrack: registers a MusicTrack with parameters: title(from the upload form), artist (username signed up with), ipfsHash(points to pinata memory location of file), fingerprint(generated by chromaprint), account(the public address which signed the transaction)
- getUserTrack: gets tracks uploaded by the user's wallet
- getTrack: gets track using fingerprint
- getAllTracks: gets all the tracks on chain (for Discover page)
- searchTracks: searches track by query given (by title or artist)
All the smart contracts were compiled using Truffle and were deployed on the chain using Alchemy API. The registring music and pulling imformation from chain also is done through Alchemy API.
File storage is handled by Pinata and I'm using Metamask wallet browser extension for transactions. Metamask wallet should also be connected to Polygon Amoy Testnet.
When a user uploads a file with title, the file is stored temporarily in uploads folder which is then picked up by generateFingerprint.js along with with title, artist (your username) and wallet address which uses Chromaprint to generate a fingerprint which is then hashed using SHA-256 algorithm to convert it into a byte32 string. That string is then checked if it exists on the chain or not. If it is, the message is displayed that a similar track exists and the file is removed from folder. If not, the file goes to uploadToIPFS.js which uploads the file to Pinata using API and Secret API key and returns the ipfsHash. Then all the components are registered on chain using RegisterMusic.json abis and network details using Alchemy API.
Getting all tracks, searching for a track and getting track using fingerprint then are pretty straightforward.
The most it should take is maybe restarting the website but just in case :)
- Check if you have enough MATIC coins for transaction
- Check if you are connected to the correct network
- Check if you are connected to a wifi which allows crypto transaction
- Check if you have any previous pending transactions
- Give the website 30 seconds to cool down and redo the transition (There's a 30 second cool down in the website, that should be good)
- Refresh the website
- Logout and re-login
- Restart the website
- Close the browser and restart the website
- Change the browser
This happens when you keep the audio playing and switch tabs. PS - There's no way to turn that audio off, you'll have to restart the website
That is very subjective and time-dependent. Try again maybe in 30 mins when the gas-fees is low
- Connect and authenticate your wallet and open your discord on web.
- In a new tab, open https://faucet.polygon.technology and connect Discord.
- Select Polygon Amoy PoS testnet and paste your wallet address.
- Sign the transation and you should have MATIC coins now.
- Go to MetaMask > Settings > Networks > Add a network > Add a network manually
- Use the information to add the network
- Network Name: POLYGON AMOY TESTNET
- New RPC URL: https://rpc-amoy.polygon.technology/
- Chain ID: 80002
- Currency Symbol: MATIC
- Block Explorer URL: https://www.oklink.com/amoy
- If it says something like 'Make sure you have the correct RPC link', check the link and if it's correct, change your wifi because it might be blocking crypto wallet.
Upload a song and send me a message, I'll tip you some tokens lol