backgroundradial

Bridging the Web: A Glimpse into cURL's IPFS Integration via WebAssembly

Discover cURL's IPFS integration via WebAssembly. Get hands-on with examples and preview the new functionalities powered by Wasmer.

dynamite-bud avatar
dynamite-bud
Rudra

runtime

September 29, 2023

arrowBack to articles
Post cover image

InterPlanetary File System (IPFS) is a protocol created in 2013 that introduces the idea of distributing the content in a decentralized manner using constant hashes (related: Content Addressable Storage) and not url locations that can mutate over time. So, instead of having data stored in a centralized location, IPFS spreads it around the world, which changes how we can consume and store information online.

Combining IPFS and tools like cURL seems like a match made in heaven, and as such the curl team have done a great work trying to integrate IPFS upstream.

While cURL's official release with IPFS support in #8805 is planned for next month, we won’t make you wait for it.

Thanks to cURL being compiled to WebAssembly using WASIX, developers can already harness the power of IPFS and Curl using Wasmer. In this article, we'll introduce you to two basic examples, offering a preview of the exciting potential that lies within cURL’s IPFS functionalities when executed via WebAssembly and Wasmer.

📺 Seeing it in action

Prerequisite

Minimum version required: 4.2.1

You can install the Wasmer Runtime using the following command:

curl https://get.wasmer.io -sSfL | sh

Example 1: Hello World

This first example is from one of the cURL’s #8805 comment.

$ wasmer run curl/curl --net --env IPFS_GATEWAY=https://ipfs.io -- ipfs://bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am
hello

Now let’s download the movie big buck bunny using IPFS.

Example 2: Downloading Buck Bunny movie

$ wasmer run curl/curl --net --env IPFS_GATEWAY=https://ipfs.io --mapdir /output:. -- ipfs://bafybeigagd5nmnn2iys2f3doro7ydrevyr2mzarwidgadawmamiteydbzi --output ./output/res.mp4
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  159M  100  159M    0     0  7994k      0  0:00:20  0:00:20 --:--:-- 9478k

The above command will download the big buck bunny video and output in your current folder with the name res.mp4.

🚧 The video is playable via VLC

Conclusion

The above examples showcase the ease of using WASIX based modules and sandboxing capabilities of WebAssembly. How you can try out the latest features of cURL without having to wait for the official release. You don’t need to compile/build anything and it just works for almost every platform out there.

ℹ️ To learn more about our cli and flags associated with it head over to our docs and if you ever get stuck we’re always here at Discord

Resources:

About the Author

Rudra avatar
Rudra
Rudra

Read more
Post cover image

engineeringruntimewasmer runtime

Wasmer 4.1

July 17, 2023

engineeringruntimewasmer runtime

Wasmer 3.2

April 18, 2023

engineeringruntimewasmer runtime

Wasmer 2.0, It's a big deal!

June 2, 2021

engineeringwasmerruntimewasmer runtimeperformance

Improving WebAssembly load times with Zero-Copy deserialization

Arshia GhafooriSeptember 7, 2023