
Discover more from Polywrap's Newsletter
WebAssembly (Wasm) is a type of bytecode that makes software safe, fast, portable and compact. It’s a compilation target for many popular languages like Rust, Go and C/C++. It’s capable of being run in various platforms, like web browsers, mobile, gaming, servers and more. Wasm code is organized into modules containing functionality that it provides to host applications.
Polywrap presents a framework for developers to write composable Wasm modules as well as for applications to import and run these modules. Polywrap calls these composable software modules "wraps". In this article, we’ll go over the wrap concept and give a non-technical overview of the wrap development experience.
Wraps: Under-the-hood
Wraps are at the core of Polywrap - they’re portable, executable modules that can be called within any application or language by simply using the Polywrap "Client".
A wrap consists of two primary files: a wrap.wasm file containing all runnable code, and a wrap.info file containing the wrap's schema and additional metadata.
Wrap Development
To build a wrap:
Describe your functions within a GraphQL schema file.
Implement your functions within one of our supported languages.
The example below shows what a schema file could look like.
Developers could choose one of the following implementation languages to write their wraps: Go, Rust, or AssemblyScript.
What makes wraps composable is that they can import the types and functions from other wraps. As an example, here’s a repo of the Ethereum Name Service (ENS) wrap, which imports types and functions from the Ethers, UTS46, and SHA3 wraps. Another example is the IPFS HTTP Client.
Once built, the wrap can be deployed locally or to decentralized storage like IPFS, ready to be used by any app that installs a language-specific Polywrap client library.
For a guide on how to develop your own wrap, see our Create Wraps tutorial.
Using wraps in supported host environments
Typically, wraps are built and then deployed to IPFS. Deployed wraps can be used in apps that install a language-specific Polywrap client library. For example, a mobile app would install the Swift or Kotlin Polywrap client library. Similarly, a web app or Node.js application would install the JavaScript client library.
Once the client is installed, it can be instantiated, enabling it to fetch and execute deployed wraps, all at runtime.
—
This has been a very light overview of the Polywrap tech and development experience. For an in-depth understanding, please refer to our documentation or chat with our devs on Discord!
Want to stay up-to-date with Polywrap news? Subscribe below!