I am new to blockchain and working on a university project. I am trying to simply buy and sell music over the blockchain. Currently I am using a string to act as the 'transaction', but learnt this will not work. Does anyone have ideas how I would transact mp3 files from a publicly accessible decentralised database? It is hard to find guides specific to this - this is for a small experiment and not for commercial use, thank-you.

  pragma solidity ^0.4.18;

    contract Music {

        address public buyer;
        address public seller;

        bool public buyerPlayed;
        bool public sellerPlayed;

        uint private buyerDeposit;
        uint private sellerDeposit;

        bool public transactionFinished; 
        address public theNewOwner;
        string gains;

        event AuctionStartsEvent(address buyer, address seller);
        event EndOfAuctionEvent(address owner, string gains);

        function Auctioning() public {
            buyer = msg.sender;

        function registerAsABuyer() public {
            require(seller == address(0));

            seller = msg.sender;

            emit AuctionStartsEvent(buyer, seller);

        function auction() public payable {
            require(!transactionFinished && (msg.sender == buyer || msg.sender == seller));

            if(msg.sender == buyer) {
                require(buyerPlayed == false);
                buyerPlayed = true;
                buyerDeposit = buyerDeposit + msg.value;
            } else { 
                require(sellerPlayed == false);
                sellerPlayed = true;
                sellerDeposit = sellerDeposit + msg.value;
            if(buyerPlayed && sellerPlayed) {
                if(buyerDeposit >= sellerDeposit * 2) {
                } else if (sellerDeposit >= buyerDeposit * 2) {

        function endOfAuction(address owner) internal {
            transactionFinished = true;
            theNewOwner = owner;

            gains = "You have recived your song!";
            emit EndOfAuctionEvent(owner, gains);


1 Answer 1


Ethereum (at least in its current form) is not good for storing any bigger amount of data. And you can't upload files to the blockchain.

You can store byte arrays which helps in some cases but there are the problem becomes storage costs. Have a look here for a but outdated information on the costs: What is the cost to store 1KB, 10KB, 100KB worth of data into the ethereum blockchain?

What people usually do is use an external service such as IPFS to store the actual files and then store the file's hash inside Ethereum contract. But in that way you have to deal with two different decentralized systems in a centralized way.

  • Okay Thanks - do you know if the code above would suffice if the msg.value was changed to the hash files that IPFS provides?
    – jamesonr
    Mar 28, 2018 at 12:04
  • msg.value refers to the amount of Ether being sent. It has nothing to do with storing a string (a hash value) Mar 28, 2018 at 12:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.