Perun Channels coming to Polkadot!

Perun Network
PolyCrypt
Published in
3 min readAug 18, 2021

Author: Oliver Tale-Yazdi

Perun Network is developing a blockchain agnostic state channel framework in the form of a golang library: go-perun. After successfully implementing a backend for Ethereum, we are now looking at Polkadot and have received a Web3 Foundation grant for the project.

We opted to implement the Polkadot on-chain logic as a Substrate pallet, more about that later. If you are already familiar with Substrate or Polkadot and want to jump right in, head to the Pallet repository.

Our Pallet

Polkadot, Substrate, Pallet?!

Realizing projects on Polkadot can be done by either building pallets with the Substrate framework or writing ink! contracts. The main difference is that a pallet is part of the blockchain’s consensus algorithm, whereas a contract runs on the ink! pallet of the blockchain. Pallets are therefore much more powerful and require responsible design.

Blockchain integration

Figure 1: Alice and Bob both contact the Perun pallet.

We decided to use a pallet since it gives us the possibility to directly integrate channels into the blockchain instead of being a 3rd party service. This also makes it easier to realize cross para-chain channels. A structural overview can be found in Figure 1.

The Perun pallet tracks all on-chain information about state channels. Users interact with it by calling its public functions via Extrinsics (aka. Transaction).

The protocol

There are four public Functions available: Deposit, Conclude, ConcludeDispute and Withdraw. They work together as shown below.

Figure 2: Channel phase diagram.

When Alice and Bob want to open a channel with each other (see Figure 2), they both call Deposit. This sends funds from their accounts to the Perun pallet. The channel is then open and can be used for sending transactions as long as both see fit.

After they are done, two possibilities exist: honest case and dispute case.

In the honest case, both Alice and Bob want to close the channel. Here they can directly call Conclude and withdraw the outcome with Withdraw.

The dispute case happens when Alice and Bob have different outcomes for the channel in mind; they will then use the pallet to adjudicate.

A dispute can go over multiple rounds and is always terminated by a call to ConcludeDispute. Alice and Bob can then withdraw the outcome.

Outlook

Hopefully, we piqued your interest! The on-chain part of Payment channels for Substrate is done and we are looking forward to completing the off-chain part.

We thank the Web3 Foundation for supporting this project through an Open Grant and are looking forward to future collaboration.

Next Steps

Next up we will implement the connection to go-perun which will then complete the circle of integration of Substrate into Perun. We will also provide you with tutorials on how to use it all 🤗

Future

We plan to add State channels which can execute more complex logic and are much more interesting than pure Payment channels.

Besides this, there are many exciting features in the Polkadot space. We are especially looking forward to supporting multiple currencies per channel and even cross-chain channels. Stay tuned!

Contact

If you are interested in learning more about the Perun Channel Technology and how it can be used to scale your blockchain application, visit our website (https://perun.network/) and our GitHub repo or contact us directly by writing us an email at info@perun.network.

--

--