Peercoin
Published in

Peercoin

Wrapmeister Cross-Chain Bridge

Each blockchain is an isolated island, but there is an ever-increasing desire to cross-connect them and make them interoperable.

rapmeister is a collection of software which allows for cross-blockchain communication between Peercoin and Ethereum, as well as multiple other EVM-based blockchains like Polygon and Binance Smart Chain. Architecturally, it is not limited or dependent on EVM-based architecture(s) and could easily be adopted to work with any other smart contract platform blockchain. Moreover, Wrapmeister’s stack can quite easily be modified to work with any bitcoin-based blockchain like: Litecoin, Dogecoin and many more.

A blockchain bridge is a connection that allows the transfer of tokens/coins and/or arbitrary data from one chain to another. Both chains can have different protocols, rules and governance models, but the bridge provides a compatible way to interoperate securely on both sides. — coinmarketcap.com

Wrapmeister allows for the creation of a pegged token “wPPC” which is redeemable for Peercoin in 1:1 ratio. wPPC is an ERC20 (or equivalent) token on EVM-based blockchains and can be used as any other token on these platforms.

The primary goal of Wrapmeister is to get Peercoin on popular AMM contracts like Uniswap, PancakeSwap, and Balancer. The secondary goal is to experiment and learn more about cross-chain communication.

Cross-Chain Bridges

Cross-chain bridges are recently rising in prominence and becoming ever more important because they enable users to access new platforms, allow different protocols to interoperate with each other, and developers to collaborate on building new products.

By its architecture, Wrapmeister would be categorized as a “custodian-based” cross-chain bridge. What that means is that all peercoins deposited into Wrapmeister are held by a custodian. In this case, the custodian is a group of trusted parties that hold the funds in a multisig setup.

As for the operation of the bridge itself, no single party has control over the bridge and many checks and balances are integrated into the system. The bridge can continue operating in an orderly manner even if some of the trusted parties go beserk.

This kind of design is by far the most robust and simplest to design and implement, and that is why it has been chosen. In the next chapter architecture will be explained.

Architecture

Wrapmeister was designed to be robust, safe, user friendly and secure.

Basic design goals that were set when the project began:

  • No state, no logs
  • 1 wPPC = 1 PPC
  • Users pay for all fees
  • Keep it simple and stupid; no governance, no tokens
  • No financial incentives for any of the involved parties. No monetization.

Coordinator node

This node is coordinating the entire system.

The coordinator node interacts with the Peercoin blockchain directly via local Peercoin node. With foreign blockchains (Ethereum), it communicates via API provided by services like infura.io and alchemyapi.io.

The coordinator node is notifying all involved parties of events that occur on both the domestic and foreign blockchain. It also serves all relevant information to the frontend.

Wrapmeister coordinator node does not hold any logs and records.

There is no need for this because all state is on the blockchain. Operator can destroy the virtual machine which hosts the coordinator and create a new one without any transfer of data. There are no backups, there is no database, nothing. There is simply no need for such things.

The system is designed in such a way that the coordinator node can be taken down at any moment and re-deployed on a different server without losing the state of the system.

The coordinator is deployed using Docker. It contains backend logic which is implemented in Typescript. Docker setup also deploys a local Peercoin node.

The coordinator source code is not public at the moment of this writing.

Frontend

The frontend is deployed on Cloudfare-pages using direct integration from Github. The frontend source code is already available under BSD-3 licence.

The frontend minimally communicates with the coordinator node over REST API.

Roles

Custodians

A group of mammals co-sign the multisig Peercoin address, which safeguards the deposited Peercoin. During the unwrap process, custodians have to inspect the state of the foreign chain and organize to make a withdrawal transaction from the multisig address.

Coordinator Operator

Standard linux admin type of work. Deploys the Wrapmeister backend and keeps it safe and online.

Smart Contract Owner

A mammal who uploads the smart contract to Ethereum and proposes the first witnesses to be elected. After the first witness is elected by the admin, the witness can propose the next witness and vote them in.

The importance of this role is largely diminished after the first three witnesses are elected.

Witness

Witness is the most complex role in the entire system.

During the wrapping process, witnesses are called upon to inspect the state of the domestic blockchain and sign the confirmation. Due to this, they are the responsible party for validating the state of the Peercoin blockchain and the whole wrapping process.

Witnesses can also “pause” the contract. A paused contract cannot be interacted with until it is unpaused. Pausing the contract is a failsafe which is used in case of an emergency, like an attack or some unforeseen event like a major rollback on a foreign chain.

Witnesses can also elect new witnesses or boot out the ones who underperform or fail at their tasks.

Wrapping

During the “wrapping” (deposit) step, each user session is given a unique peercoin deposit address. Each new address is freshly generated. As soon as this transaction is confirmed (3 to 6 confirmations), witnesses are called upon to inspect the state of the blockchain and sign the confirmation with the smart contract. Only after three signatures are collected, the user is allowed to mint wPPC on the Ethereum side. As this happens, the deposited peercoins are moved to a custodian address, which is a multi-signature address.

bridge.peercoin.net interface for wrapping Peercoin

Upon depositing native peercoins, the user invokes the “claimTokens” function of the ERC20 contract. This function creates a fresh supply of wPPC and deposits it directly into the user’s Ethereum account. All fees are thus paid for by the user.

ERC20 contract source excerpt which handles minting of new tokens. Mind that this is just an example code snippet and does not represent actual code.

The “claimTokens” function will not work without authorization from the witnesses.

To summarize, “proof-of-lock” or “proof-of-deposit” on the Peercoin side gives the user the right to mint wPPC on the foreign chain. Amount deposited always equals the amount of wPPC minted, minus the fee of course. The standard Peercoin fee is 0.01 PPC, which means that a deposit of 100 PPC will allow the user to mint exactly 99.99 wPPC.

“Wrapped” assets are fully collateralized by the underlying asset — Peercoin.

Unwrapping

Unwrap cannot happen until the user has presented proof-of-burn to the back end. On the foreign chain, the user invokes the burn function of the ERC20 contract, which destroys some amount of wPPC and removes it from circulation.

ERC20 contract source excerpt which handles burning of tokens. Mind that this is just an example code snippet and does not represent actual code.

The coordinator node picks up on this event and sends a warning to the multisig custodians that the burn has happened. Upon inspecting the presented evidence, custodians process the withdrawal manually. This is a bottleneck of course, and is indeed manual labor. However, it is by far the safest option we could go for while designing this. Most exploits and hacks of cross-chain bridges happen at this step, and always it’s about someone finding a way to fool some automatic process.

The entire withdrawal process is seamless and ergonomically presented by the frontend.

bridge.peercoin.net interface for unwrapping Peercoin

Custodian Address

The custodian address is a 4of6 multisig address. That means that funds are collectively owned by 6 different keys and any spend from the custodial address mandates 4 keys to sign.

Keys to the custodial multisig are held by a select group of forest animals living in Romania. ref

Transparency

The custodian storage address is of course public, and the balance can be inspected by anyone at any moment.

The smart contract on the foreign, EVM-based chain is also completely transparent and its state can be validated by anyone at any moment.

Users can always inform themselves about the state of both blockchains at the bottom of the bridge.peercoin.net website. Manual inspection is also possible using either block explorers or similar services.

Balances of wPPC and its backing in the custodian address are presented on the bridge.peercoin.net website.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store