This article is still a work in progress, can contain errors in concepts. Read on your own risk.
IPFS - Interplanetary file system is a storage type that Decentralized on multiple nodes and where the resource path depends on the resource content. Will be used interchangeably with the term content-based addressing file system in the article.
In most cases, there is some content logically attached to
ERC-721 token. It is stored as a
tokenURI which is often used as either container for some piece of data or an address of remote resource consisting of more details. Apparently, we can say that content related to the token is either on-chain or off-chain. The following picture presents the division and includes specific trade-offs that one needs to take into account.
How to attach data to token.
Things are simple for on-chain data. As long as you know the content at the minting stage you just apply it to token and you are done. However if there is data supposed to be stored off-chain, one needs to know its location beforehand. If the minting is done on demand of a user things get complicated, especially when a randomness factor is added to the whole minting process and there is the intention to store data in a content-based addressing file system like IPFS. In such a situation, you do not know the eventual address in advance so you cannot 'guess' its address (it is content-based)
As storing data on-chain is extremely expensive, it should be used for a small piece of data where it is really worth it. By using this type of storage we benefit from the relatively trivial process of minting. There is no need to handle the multi-step process of going there and back to IPFS and handling the reference address saving on the token side.
This type allows us to store more data, at a relatively low cost. Is super effective when the token keeps more data like for instance the enjin standard for metadata. Picking content-based addressing introduces its consequences but in many cases can be worth the cost. i.e. as described here where changing the content in centralized storage can give people headaches.
Location-based vs content-based addressing
Location-based addressing is super common for all web2.0 applications. It is easy to handle and storing content there does not require an external pinning procedure. As a centralized system is may also be more prune for failures as there might be fewer replications. Important is that content under a certain path can be changed without reflecting it on BC history. It creates a huge flaw for trustless systems.
Content-based addressing is more aligned with the trustless idea; it is much safer as there is no risk of changing content without reflecting it in BC history. Moreover, it is impossible to delete* the file from ipfs so as such the content attached to the token seems to be safe.
*It is highly probable that files uploaded to IPFS nodes may eventually become smth that no one can ever delete from this network. As it sounds cool it may be a terrible drawback of this in certain scenarios.