← Back to blog posts
Polymesh news
March 6, 2023

Smart contracts get an update with Polymesh upgrade to 5.2

The Polymesh minor upgrade to 5.2 brings a host of new features and updates, giving smart contract developers greater flexibility and control as well as providing other improvements.

We’re excited to announce the new Polymesh 5.2 release!

This minor release brings a host of new features and updates to Polymesh, giving smart contract developers greater flexibility and control as well as providing other improvements.

The full release notes can be found at:

Smart Contract Updates

In the previous Polymesh release we introduced support for WASM-based smart contracts, written in the Ink! domain specific language. 

This was an exciting step forward for Polymesh and its developer community, however smart contracts were complex to implement specifically where they needed to interact with storage or functionality at the base layer of Polymesh – the layer which includes asset origination, settlement, identity, compliance, and other critical features for capital markets.

The Polymesh 5.2 minor release introduces a streamlined and simple way for smart contracts to interact with the base layer of Polymesh.

Smart contracts can now use the Polymesh Runtime API crate to easily interact with these base layer features. For example, a smart contract can now create and manage assets natively, execute settlement instructions, and modify portfolios. It can also easily read storage to determine the identity of a key, or any authorizations that may be pending for it to approve.

Here are two examples of smart contracts that help to showcase this behaviour.

Vesting POLYX


This example smart contract allows you to lock up POLYX and have it vest to a receiver over a period of time.

Wrapped POLYX


This smart contract allows users to send POLYX and receive back WPOLYX, a Polymesh native asset that represents the POLYX native token. Having an asset representation of POLYX allows POLYX (or more accurately WPOLYX) to be used in settlement instructions.

To do this, the contract needs to create assets (WPOLYX) as well as manage settlement instructions to send and receive these WPOLYX tokens.

These smart contracts are a great starting point for developers to familiarize themselves with what’s possible on Polymesh and to build out more complex real-world use-cases such as DEXs, lending protocols, decentralized autonomous organizations (DAOs) and more.

Upgradable Smart Contracts

An additional challenge introduced by having smart contracts interact with the base layer of Polymesh is that upgrades to the base layer could make those smart contracts become unusable.

There are many ways to mitigate this issue, including:

  • ensuring that your smart contract is upgradable and can be modified if there are any breaking changes at the base layer

  • using an upgradable wrapper around the Polymesh Runtime API

An example of the latter approach can be seen at:

An upgradable wrapper around the Polymesh Runtime API allows a contract to work with a smaller stable API that can be updated to maintain support across future major releases of Polymesh (i.e. 6.0, 7.0).

Miscellaneous Changes

The 5.2 release also adds a number of small improvements and safety checks to Polymesh.

Most prominently, we’ve modified logic around off-chain receipts, a way to affirm settlement instructions that contain legs that require assets to be moved outside of Polymesh. With 5.2, Polymesh now allows for off-chain receipts where the asset itself doesn’t exist on Polymesh.

This update to off-chain receipts provides greater clarity to users of Polymesh’s settlement engine as they no longer need to rely on whether an `Asset::Transfer` event was emitted to determine whether a leg was settled via an on or off-chain movement of assets. In the next major release of Polymesh, we’ll continue to refine this logic and add additional structure to settlement legs to clearly differentiate between these different cases.

We’ve also added a streamlined onboarding extrinsic to simplify the customer due diligence process during onboarding, as well as more sanity checking on various inputs, such as ensuring that ticker names are always alphanumeric.

Coming up next

Our next minor release, which is code complete and under testing, will introduce a long-awaited exciting new feature: non-fungible tokens (NFTs) on Polymesh!

Stay tuned for a more detailed look at this new feature that provides additional ways to model financial assets on Polymesh to account for both fungible and non-fungible financial products.

Join DiscordDownload the report

Ready to use Polymesh?