Building a Polywrap SDK Wrapper for Substrate and Polkadot

Building a Polywrap SDK Wrapper for Substrate and Polkadot

Authored by Colin Adams

Last year, ChainSafe received a co-sponsored grant from Polywrap and the Web3 Foundation to develop a Substrate "wrapper." That is, a universal SDK powered by Polywrap's technology that aims to significantly improve the experience of building on Polkadot and Substrate.


Polywrap is the technology behind the Substrate wrapper. Polywrap wrappers are decentralized SDKs that dApps can seamlessly integrate in order to interact with web3 protocols.

A wrapper's value is much greater than your typical SDK because wrappers are written and maintained in just one language but can then be used by applications written in any language on any platform.

Best of all, wrappers are highly composable lego blocks - connecting to each other in a simple, standardized way, unlocking more versatile use cases than your typical dApp.

Given our expertise in Polkadot client implementations (Gossamer), we were an ideal candidate to create a wrapper for Substrate. This effort includes the Substrate core wrapper and accompanying technical documentation.

Unpacking the details

The Substrate core wrapper is an SDK that enables dApps to interact with Substrate-based blockchains. The wrapper's business logic is written in Rust, one of the most popular blockchain programming languages.

As mentioned above, wrappers are universal SDKs. They can run on any deployment platform, regardless of language. On the other hand, traditional SDKs are language-specific; e.g., a JavaScript SDK can be used only in JavaScript environments like web browsers or Node.js backend servers. Conversely, wrappers offer a more efficient and future-proof strategy for code reuse.

Wrappers can be used in any programming environment because of a novel technology called WebAssembly or Wasm. Wasm is a bytecode format and compilation target for languages like Rust. Thus, any applications installed with a Polywrap client library can fetch and run the Wasm modules contained in wrappers.

This wrapper will have significant advantages over Polkadot's current JS SDK. If interested, you can read the benefits here.

Why it matters

It's easy to install JavaScript dependencies into your application without realizing the potential security issues and application bloat that comes with using "other people's code." Polywrap enables a scalable, secure way of managing wrappers and their dependencies.

For example, to use any deployed wrapper, including Substrate's, your dApp just needs to install one dependency: Polywrap's JavaScript client library.

With some minimal setup, this library can retrieve any wrapper from decentralized storage and use them, all at run-time. These wrappers are also secure-by-default by operating within their own memory instance unless their host environments give them special permissions to do otherwise.

A layer of standardization for Polkadot's multi-parachain future🌅

The Substrate wrapper is an important first step that will bring new levels of composability to Polkadot. In addition to the benefits already mentioned, Polywrap wrappers can also add a layer of standardization for Polkadot developers.

Across Polkadot's many parachains are pallet ABIs that serve similar purposes regardless of the parachain that they're on. Some of these common pallet ABIs include tokens, AMMs, governance, and more.

With Polywrap, developers can create standard interfaces for these common use cases. For example, a developer building an AMM would simply integrate a wrapper containing standard methods and types typically seen in AMMs. Having these powerful templates as wrappers would significantly improve interoperability in Polkadot's multi-parachain future.

We think the Substrate wrapper will enable web3 developers to reimagine how they develop for the Polkadot ecosystem. We're proud of this collaboration with Polywrap and excited to see the creative ways developers will use the Substrate wrapper.

➡ ChainSafe provides consulting and engineering services for all things web3. Find out more about how your project can benefit from ChainSafe's proven track record and expertise⭐️

About PolywrapPolywrap leverages WebAssembly to make code portable, secure, and easy to integrate across platforms. Use Polywrap to develop composable modules, called wrappers, and integrate them on-demand in any application.

Website | Twitter | Discord | Github | Blog

About ChainSafe

ChainSafe is a leading blockchain research and development firm specializing in infrastructure solutions for web3. Alongside its contributions to major ecosystems such as Ethereum, Polkadot, Filecoin, Mina, and more, ChainSafe creates solutions for developers and teams across the web3 space utilizing expertise in gaming, bridging, NFTs, and decentralized storage. As part of its mission to build innovative products for users and improved tooling for developers, ChainSafe embodies an open source and community-oriented ethos to advance the future of the internet.

Website | Twitter | Linkedin | GitHub | Discord | YouTube | Newsletter