How to Create a Music NFT on Binance Smart Chain

How to Create a Music NFT on Binance Smart Chain

In the world of blockchain technology, Non-Fungible Tokens (NFTs) have gained immense popularity. NFTs are unique digital assets that can represent ownership of any form of digital or physical item, including artwork, videos, and even music. Binance Smart Chain (BSC) provides a fast and affordable option for creators to bring music on-chain and create music NFTs. In this comprehensive guide, we will walk you through the process of creating and deploying a music NFT on the BSC Testnet using Remix and MetaMask.

Introduction to Music NFTs

Before we dive into the process of creating a music NFT on Binance Smart Chain, let's first understand what NFTs are and why they have gained so much attention in recent times. Non-Fungible Tokens are unique digital assets that are stored on a blockchain, providing proof of ownership and authenticity. Unlike cryptocurrencies such as Bitcoin or Ethereum, which are fungible and can be exchanged on a one-to-one basis, NFTs cannot be exchanged on a like-for-like basis due to their uniqueness.

Music NFTs, specifically, allow musicians and creators to tokenize their music and sell it as digital assets. This opens up new possibilities for artists to monetize their work and connect directly with their fans. With the Binance Smart Chain, creators can leverage the benefits of fast and affordable transactions to bring their music on-chain.

Setting Up Binance Smart Chain Testnet

Set Up Your QuickNode Endpoint

In order to develop on the Binance Smart Chain Testnet, you'll require an API endpoint for network connectivity. You have the option to utilize public nodes or establish and oversee your own infrastructure. Yet, if you seek swifter response times, you can delegate the technical aspects to us. Get started by registering for a complimentary account right here.

Click on Create an endpoint

Select BNB Smart Chain and click on continue

Select Testnet and click on continue

Now, simply copy your HTTP Provider:

To begin creating your music NFT on Binance Smart Chain, you'll need to set up the BSC Testnet on your MetaMask wallet. This will allow you to interact with the BSC network and deploy your smart contract. Here's how you can set up the BSC Testnet on MetaMask:

  1. Open your MetaMask wallet and click on the network selection dropdown.

  2. Select "Custom RPC" to add a custom network.

  3. Enter the following details for the BSC Testnet:

Once you've added the BSC Testnet to your MetaMask wallet, you'll be able to connect to the Binance Smart Chain and interact with it seamlessly.

Get Test BNB Tokens

As we prepare to deploy our smart contract on the BCS Testnet, it's essential to obtain test BNB tokens for covering gas fees.

Navigate to the QuickNode Faucet, where you can connect your Wallet to receive BNB to your wallet address. Simply click 'Continue after connecting your wallet,' and you'll be granted 0.1 BNB to facilitate testing:

Uploading Files to IPFS Using QuickNode

Creating and managing Music NFTs on the Binance Smart Chain (BSC) involves storing and distributing multimedia files and associated metadata. To streamline this process, QuickNode's IPFS service provides a reliable and decentralized solution for uploading and accessing files and metadata. In this guide, we'll walk you through the steps to leverage QuickNode's IPFS service in your Music NFT project on BSC.

Step 1: Set Up QuickNode IPFS

Before you can start using QuickNode's IPFS service, you need to ensure you have access to it. You can sign up for an IPFS account on the QuickNode platform or check if it's included in your existing subscription.

Step 2: Upload Files and Metadata

To create a Music NFT, you'll need to upload the associated music files, album art, and any metadata to QuickNode's IPFS service. IPFS allows you to store and retrieve data efficiently. After uploading your files, QuickNode's IPFS will provide you with unique IPFS links for each piece of content.

Click on the IPFS tab on your QuickNode dashboard which is located by the side left navbar

Click on Add a file and select the file you want to upload

After selecting the file you want to upload a notification of the File uploaded will pop up

Upon successful upload, on your QuickNode IPFS tab, you will generate a hash that starts with "Qm" which is your CID (Content Identifier). Copy this hash starting from "Qm" and add the "https://quicknode.quicknode-ipfs.com/ipfs/" prefix to it. The resulting URL will allow you to listen to your song in the browser. Or you should copy your IPFS URL Immediately.

Click on the three-dot on the right-hand side of your IPFS tab

Then click on Copy IPFS URL to listen to your song in the browser.

Step 3: Store IPFS Links in Smart Contracts

In your BSC smart contract that manages NFTs, you can store the IPFS links as metadata for each NFT token. This metadata will typically include details about the music, such as the artist's name, song title, album name, and a link to the music file on IPFS. By storing the IPFS links in your smart contract, you make it easy for users to access the content associated with each NFT.

Creating Metadata for Your Music NFT

To provide additional information about your music NFT, you need to create a metadata file in JSON format. This metadata file will contain details such as the name, description, and the IPFS URI of your music file. Follow these steps to create and upload the metadata file:

  1. Create a new file name nft.json in the same directory as your music file.

  2. Open the nft.json file and paste the following code into it:

     {
       "name": "My first Song NFT",
       "description": "My first music NFT project.",
       "song": "https://ipfs.io/ipfs/YOUR_Qm_HASH"
     }
    

    Feel free to update the name and description according to your preference. Make sure to update the IPFS URI with the one you obtained in the previous step.

  3. Save the nft.json file.

  4. Upload the JSON file to QuickNode IPFS by following this step:

    Click on Add New on your QuickNode IPFS tab

    Now, select New file then select the nft.json file

    After selecting the nft.json file a notification of the File uploaded will pop up

    Click on the three-dot on the right-hand side of your IPFS tab to copy the QuickNode IPFS URL to allow you to see the metadata file in JSON format.

Creating a Smart Contract in Remix

Now that you have your music file hosted on IPFS and the metadata file ready, it's time to create the smart contract that will represent your music NFT. We will be using the Ethereum Remix IDE to write and deploy the smart contract. Follow these steps to create a smart contract in Remix:

  1. Go to the Ethereum Remix IDE in your web browser.

  2. Click on the "+" icon to create a new file and name it music.sol.

  3. Copy and paste the following code into the music.sol file:

     // SPDX-License-Identifier: MIT
     pragma solidity 0.8.0;
    
     import "https://github.com/0xcert/ethereum-erc721/src/contracts/tokens/nf-token-metadata.sol";
     import "https://github.com/0xcert/ethereum-erc721/src/contracts/ownership/ownable.sol";
    
     contract musicNft is NFTokenMetadata, Ownable {
       constructor() {
         nftName = "Quick Music NFT";
         nftSymbol = "QMNFT";
       }
    
       function mint(address _to, uint256 _tokenId, string calldata _uri) external onlyOwner {
         super._mint(_to, _tokenId);
         super._setTokenUri(_tokenId, _uri);
       }
     }
    

    This code imports the necessary ERC721 contracts and defines a new contract named musicNft. It also includes a mint function to mint the music NFT. Update the nftName and nftSymbol variables according to your preference.

  4. Click on the "Compile" button to compile the smart contract.

Minting Your Music NFT

With the smart contract created, we can now proceed to mint your music NFT on the Binance Smart Chain Testnet. Follow these steps to mint your music NFT:

  1. Click on the "Deploy and Run Transactions" icon in the left panel of Remix (it looks like an Ethereum logo with a triangle).

  2. Set your environment as "Injected Web3" and select the Smart Chain Testnet wallet from MetaMask.

  3. Click on the "Deploy" button. If you receive an error message before deployment stating "This contract may be abstract," it implies that the appropriate contract under the "Contract" tab was not selected. Select the contract name that corresponds to your song from the "Contract" drop-down menu, and then click "Deploy" again.

  4. Approve the transaction from MetaMask when prompted.

  5. Confirm the transaction in MetaMask.

  6. Once the deployment is successful, you will see a note confirming the deployment.

Confirming the Minted Music NFT

After successfully minting your music NFT, it's essential to confirm its existence and check if the metadata is stored correctly. Follow these steps to confirm your minted music NFT:

  1. In the left sidebar of Remix, scroll down to the "Deployed Contracts" section and expand the deployed contract.

  2. You will see a few methods that you can call on your contract. Expand the "mint" function.

  3. Enter your wallet address into the _to field.

  4. Enter an integer value (e.g., 1) into the _tokenId field.

  5. Enter the IPFS URI of the .json file you created earlier in the _uri field.

  6. Click "Transact" and approve the transaction in MetaMask.

  7. You should be able to see the successful transaction in your MetaMask wallet and on the BSC Testnet block explorer.

  8. To check if the metadata was stored correctly, scroll down to the "tokenURI" method in the Remix sidebar. Enter the token ID you used in the previous step, and you should see a response that includes the URI to your .json file.

Conclusion

Congratulations! You have successfully created and deployed your first music NFT on the Binance Smart Chain Testnet. By leveraging the power of blockchain technology and NFTs, you can now tokenize your music and connect with fans in a whole new way. Remember, Binance Smart Chain offers fast and affordable transactions, making it an excellent choice for creators looking to bring their music on-chain. If you have any questions or want to learn more, feel free to reach out to us on Discord and Twitter. We would love to hear from you!

Additional Information

I'd love to connect with you on Twitter | LinkedIn | Portfolio.

About QuickNode

QuickNode is building infrastructure to support the future of Web3. Since 2017, we've worked with hundreds of developers and companies, helping scale dApps and providing high-performance access to 24+ blockchains. Subscribe to our newsletter for more content like this, and stay in the loop with what's happening in Web3!‌