IPFS has been the go-to decentralized network for sharing content and websites. However it's greatest strength, immutability, is also it's greatest weakness. There are cases where you might need to update content on IPFS, but that would result in a new CID. IPCM (InterPlanetary CID Mapping) aims to solve this by storing a simple IPFS string onchain and letting the contract be the point of reference for the latest state.
With this approach the contract address acts as the static address, and the state it holds can be dynamic. This results in several benefits:
With IPCM you can easily host content on IPFS and update it onchain. For example, this webpage is currently hosted on IPFS and proxied through a Cloudflare worker, where the code simply gets the latest mapping of the contract and fetches the content through an IPFS Gateway. The contract address acts as the main point of reference to a CID that can only be changed by the user, and with smart contract events recorded onchain anyone can index the history of the state.
sequenceDiagram
participant User
participant IPFS
participant IPCM
participant Reader
User->>IPFS: Upload siteA.html
IPFS-->>User: Return CID1
User->>IPCM: Set state to ipfs://CID1
User->>IPFS: Upload siteB.html
IPFS-->>User: Return CID2
User->>IPCM: Update state to ipfs://CID2
Reader->>IPCM: Query latest state
IPCM-->>Reader: Return ipfs://CID2
Reader->>IPFS: Fetch CID2
IPFS-->>Reader: Return html2.html content
The IPCM contract for this website can be viewed here: 0xD5B0CE88928569Cdc4DBF47F0A4a1D8B31f6311D
To learn more please visit the GitHub repo with the link below!