Hot Swaps
Use the Hot Swaps plugin to make one CID map to another
The Hot Swaps plugin can be used to “redirect” a CID to another CID. This can be useful when you need to replace content without updaing the CID hash.
While it may seem like this undermines the benefits of IPFS’ imutable content system, it should be made clear that this only works on a per gateway level for those who install it. Additionally:
- Any CID can be called by another gateway to view the original content
- Pinata has an SDK method and API endpoint that any Pinata user can call to check the history of a swap
- All gateway requests that have the hot swap plugin installed and are serving a swapped CID will have a header of
etag
that will have the CID that is currently being directed to.
To demonstrate how this plugin works, consider the following example:
Installation
Follow the steps in the Getting Started guide to install the Hot Swaps Plugin.
Usage
After installing the plugin you can then make CID swaps and have them reflect when making Gateway requests. The first parameter cid
will be the original CID, and swapCid
will be the content you want it to point to instead.
You can fetch the history of CID swaps using the swapHistory
method, passing in the cid
of the original CID and the domain
of the gateway that has the Hot Swaps plugin installed.
To delete a CID swap you can simply use the deleteSwap
method and pass in the CID.