DAG-CBOR vs. JSON on the web

ipfs-meme

In the The State of Dapps on IPFS: Trust vs. Verification blog post, I mentioned some of the ongoing efforts to make verified retrieval easier in the browser.

One of the most exciting initiatives is the new @helia/verified-fetch package, which provides a fetch-like API for retrieving content from the IPFS network.

As it turns out though, there are a lot of nuances around codecs that are impacting the Fetch like interface the package provides.

For example, how should the library handle .json() for dag-cbor CIDs?

dag-cbor is a much more efficient and flexible (more data types) serialisation format, but not all data types supported by dag-cbor are supported by JSON. What’s more, most web developers are not familiar with dag-json.

Here’s a PR we’ve been working on to handle some of these nuances: fix: round-trip DAG-JSON and DAG-CBOR with embedded CIDs by achingbrain · Pull Request #426 · ipfs/helia · GitHub

We wanna hear from you

If you’re using IPFS on the web with JSON or DAG-CBOR, it’d be great to here from you and learn from your usage patterns!

Please share your experiences and challenges working with structured data with IPFS on the web

Thanks for asking. I use DAG-CBOR and hash multiformats blocks locally. On the read side I GET raw bytes and create multiformats blocks.

2 Likes