IPFS and Editing Permissions
Asked Answered
V

1

5

I just uploaded a folder of 5 images to IPFS (using the Mac Desktop IPFS Client App, so it was a very simple drag and drop operation.)

So being that I’m the one that created and published this folder, does that mean that I’m the only one that’s allowed to make further modifications to it - like adding or deleting more images from it? Or can anyone out there on IPFS do that as well?

If they can, is there a way to prevent that from happening?

=======================================

UPDATED QUESTION:

My specific use-case has to do with updating the metadata of ERC721 Tokens - after they’ve already been minted.

Imagine for example a game where certain objects - like say a magical sword - gains special powers after a certain amount of usage or after the completion of certain missions by its owner. So we’d want to update this sword’s attributes by editing it’s Metadata and re-committing this updated metadata file to the Blockchain.

If our game has 100 swords for example, and we initially uploaded to IPFS a folder containing all 100 json files (one for each sword), then I’m pretty sure IPFS still let’s you access the specific files within the hashed-folder by their specific human-readable names (and not only by their hash.) So if our sword happens to be sword #76, and our naming convention for our JSON files was of this format: “sword000.json” , then sword#76’s JSON metadata file would have a path such as: http://ipfs.infura.io/QmY2xxxxxxxxxxxxxxxxxxxxxx/sword076.json

If we then edited the “sword076.json“ file and drag-n-dropped it back into our master JSON folder, it would obviously cause that folder’s Hash/CID value to change. BUT, as long as we’re able update our Solidity Contract’s “tokenURI” method to look for and serve our “.json” files from this newly updated HASH/CID folder name, we could still refer to the individual files within it by their regular English names. Which means we’d be good to go.

Whether or not this is a good scheme to employ is something we can definitely discuss, but I FIRST want to go back to my original question/concern, which is that I want to make sure that WE are the ONLY ones that can update the contents of our folder - and that no one else has permission to do that.

Does that make sense?

Vigen answered 8/4, 2021 at 14:54 Comment(0)
M
6

IPFS is immutable, meaning when you add your directory along with the files, the directory gets a unique CID based on the contents of the directory. So in a sense, nobody can modify it, not even you, because it's immutable. I believe this confusion can be resolved with more background on how IPFS works.

When you add things to IPFS each file is hashed, and given a CID. The same is true for directories, but their CID can more easily be understood as a sum of the contents of the directory. So if any files in the directory are updated, added, or deleted, the directory gets a new CID.

Understanding this, if someone else added the exact same content in the exact same way, they'd end up with the exact same CID! With this, if two people added the same CID, and a third person requested that file (or directory), both nodes would be able to serve the data, as we know it's exactly the same. The same is true if you simply shared your CID and another node pinned it, both nodes would have the same data, so if anyone requested it, both nodes would be able to serve it.

So your local copy, cannot be edited by anyone. In a sense, if you're relying on the IPFS CID as the address of your data, not even by you! This is why IPFS is typically referred to as "immutable", because any data you request via an IPFS CID will always be the same. If you change any of the data, you'll get a new CID.

More info can be found here: Content Addressing & Immutability

If you read all this and thought "well what if I want mutable data?", I'd recommend looking into IPNS and possibly ipfs-sync if you're looking for a tool to automatically update IPNS for you.

Mcloughlin answered 8/4, 2021 at 18:26 Comment(6)
@Discoradian Thanks for answering - very much appreciate it! I should have phrased my question differently cause I'm actually very familiar with IPFS, how adding/removing files changes folder Hashes, CID's, etc. What I was trying to understand is - again, if “I’m the only one that’s allowed to make further modifications” to a folder I uploaded to IPFS, or “can anyone out there on IPFS do that as well?” It’s strictly a question re permissions, not practicality or mutability. I updated my question to give the full context of what exactly I’m trying to achieve - please check it out!Vigen
@Vigen I've read your updated question. So you understand when the file is updated, the dir CID changes, you update that in Solidity, great. So wouldn't the question be more "who can update the tokenuri method?" as anyone could download your IPFS files, change them, and upload them with a new CID, as IPFS is completely open. However your tokenuri method I'm assuming has permission involved, and that's really the content that's being pointed to. So the real problem to address is "Who can update the TokenURI?" and if that's just you, sounds like you're all set.Mcloughlin
@Discoradian Thanks for responding again. To answer your question: "wouldn't the question be more 'who can update the tokenuri method?'" The answer is "No. My question is and remains what it always was, the gist of it being: can anyone update any directory on IPFS?" The reason I updated my original question was to provide you with further context re why I asked my original question, but I never changed my original question. I actually literally ended my updated question by saying “I FIRST want to go back to my original question/concern.” Perhaps you glossed over that.Vigen
Either way, you did answer my original question now by writing that "IPFS is completely open" - which I actually find really surprising, if not downright crazy. Cause if anyone out there can upload anything into any existing IPFS directory - even one they didn’t create, well that seems like an invitation for chaos. I think I’ll have to dig deeper into that. Anyway, thanks again!Vigen
@Vigen I'm not sure where the confusion stems from but the data is immutable, so nobody can add anything into an existing IPFS directory, it'd always be a copy, a different hash, for different data.Mcloughlin
Perhaps to add more clarity, there's no concept of editing/updating/modifying in IPFS, so therefore no real permissions. There's really fundamentally really only add and pin. I'm sorry for any confusion.Mcloughlin

© 2022 - 2024 — McMap. All rights reserved.