title: Evaluation of DApp (Smart Contract) storage concept with IPFS
body: <p>i hope you can help me improve or validate my storage concept. I am glad for each suggestion. Since this is my first DApp, i might not consider all possible options for my problem. </p>
  
  <p>To understand the Background:
  I plan to realize a DApp (based on Ethereum) that compares prices and search the cheapest price for a product in an certain area. The product itself is homogeneous, only the price matters. 
  To keep it simple: Its a complicated product, it takes several days for the supplier to confirm an order and several month to deliver the product. The prices for the product are volatile, so there is a possible incentive for suppliers to cheat, meaning that they offer a low price in the beginning and demanding a higher price when they confirm the order a couple of days later.</p>
  
  <p>The reason why i want to use the blockchain is transparancy and tracebility for the customer. So the customer should be able to easily validate, that the price that is suggested by the DApp is really the cheapest one in his area. Furthermore the Customer need to proof, that the supplier really offered a certain price at a certain time and cant claim a higher price later in the order confirmation. </p>
  
  <p>So the interaction with the blockchain need to deliver two things: 
  a.  Evidence that the result is really the cheapest price in his area
  b.  That the supplier itself offered the suggested price at this time.</p>
  
  <p>Here are my thoughts and solutions so far:</p>
  
  <p>The easiest and most transparent way would be one huge smart
      contract with all the data (prices, areas, suppliers) stored inside.
      The suppliers would update the prices in the smart contract with
      transactions.</p>
  
  <p>a.  The customer could simply check the smart contract
      attributes to validate the lowest price suggestion of the DApp.</p>
  
  <p>b.  The customer can proof the origin of the price through the
      transaction history of the contract.</p>
  
  <p>Since data storage is extremely expensive on the blockchain, the interaction with this contract is not really an option. Updates of prices are very expensive because of the amount of data that is shoveled around (I tried it already). Instead the storage on the Blockchain for each supplier should be smaller, but still have the same transparency. I thought about using IPFS as datastorage and just store the Hash, but IPFS itself does not really proof anything because its mutable. So the important data need to be on the Blockchain, at least for my understanding, maybe you have a better idea?</p>
  
  <p>So this is my last idea where I ask your help for. I tried to draw it in a use-case class model mix, I hope it becomes more clear this way. 
  Unfortunately you have to download it, because i dont have enough reputation </p>
  
  <p><a href="https://imgur.com/oE4cQtv" rel="nofollow noreferrer">https://imgur.com/oE4cQtv</a></p>
  
  <p>Each supplier has its own contract (Supplier). The suppliers update the prices within their contract through transactions. Each contract supplier references to the same IPFS datastorage. The Datastorage just contains a list of all supplier smart contracts (adresses). </p>
  
  <p>The Smart Contract HashStore just contains the IPFS Hash to this list. </p>
  
  <p>To get the lowest price, I will in javascript (Class Price Search) simply read the Hash out of the Smart Contract HashStore. Then I will access the datastorage on IPFS and get all the  addresses. I don’t use the prices stored on IPFS. Instead I loop through the addresses and call each time the GetData Method of each smart contract Supplier. After I collected all prices I simply choose the cheapest one.</p>
  
  <p>a.  The customer could check the datastorage on IPFS for an Overview of all prices. Since I read the price directly out of the Smart Contract, there is nothing to win for the supplier to manipulate the IPFS Table.</p>
  
  <p>b.  The Customer can easily check each supplier and its transaction history through the individual smart contract. So he can easily proof price changes.  </p>
  
  <p>I think this solution might work, but i still feel that I miss a part. Maybe Swarm offers some options I don’t know? Or there are some cool functions in Solidity I am not aware to handle this problem?</p>
  
  <p>Thanks for your help!!!</p>