Phala Network
Published in

Phala Network

Phala and Acala Unveil the First-ever Cross-chain Demo on the Rococo Testnet

Why Do We Need Cross-chain Transactions?

Parachains on Polkadot will upend existing blockchain technologies. Parachains not only combine the advantages of Layer 1 chains, such as autonomy and security, with application-specific features but also can interoperate with each other over arbitrary transactions. It’s not just value transfers between parachains on Polkadot one can do, but actual full-on interoperability.

What is interoperability? Here is an example shared by Parity core developer Tomasz Drwięga at the first Polkadot community meeting Polkadot Decoded:

Suppose you want to buy flight delay insurance, the insurance company will get the flight delay data from the airline and get it from the airport. The data verifies whether you have gone to the airport on time and if both of the conditions above are met, a sum of money will be sent to your bank account.

So, it is an oracle parachain that contains the relevant data for flight attendance and time of registration and a financial parachain that sends over the funds or, as in this example — to your off-ramp provider, which can be its own parachain as well, who then sends it to your bank account.

There are many types of parachains, such as parachains with tokens or without one, parachains specializing in a certain field or use-case, as well as hub chains that serve a certain community (e.g. a DeFi parachain)…

To make things less abstract and bring it closer to the current Polkadot/Kusama ecosystem — what exactly can one do now with this cross-chain technology?

  • Acala is the decentralized financial hub of Polkadot which offers a suite of DeFi primitives including stablecoin, DEX, and staking derivatives.
  • Phala Network is a blockchain privacy protocol. Phala allows for generalized computation (i.e. Turing-complete smart contract executions) that is also privacy-preserving, via a combination of Trusted Execution Environment (TEE) and blockchain technologies. Phala ensures the scalable and reliable execution of smart contracts, like financial transactions, without leaking sensitive data.

Now, suppose we want to achieve the following:

  • Let the assets and DeFi contracts on Acala use Phala’s scalable execution and privacy capabilities;
  • Let private assets from Phala be used within Acala’s suite of applications

Using Polkadot/Kusama’s cross-chain protocol, we can achieve both goals without changing a single line of code! For any non-Polkadot/Kusama cross-blockchain interactions it would have consumed huge developer resources and energy.

Cross-chain Use Case Demo

Demo Video


Rococo relay chain

How to Achieve Cross-chain Interaction?

The cross-chain functionality is enabled by the XCMP protocol equally available to relay chains, parachains, and bridges. Cross-chain transactions are executed with a simple queuing mechanism based on Merkle trees to ensure accuracy. The task of a relay chain validator is to “move” transactions from the output queue of a sending parachain to the input queue of the receiving parachain. Only the associated metadata is stored as a hash in the relay chain memory.

The XCMP queue must first be started by opening the channel between the two parachains. The channel is identified by the parachain of the sender and receiver, which means it is a one-way channel. There can be up to two channels between a pair of parachains, one for sending messages to the other chain and the other for receiving messages.

The XCMP protocol can be subdivided into:

  • VMP: Parachain-relay chain communication
  • HRMP: Parachain-relay chain-parachain relay communication
  • XCMP: Parachain-parachain direct communication

VMP and HRMP are currently implemented on Rococo v0, but Rococo v1 is still under development, so we have implemented the cross-chain functionality between Phala and Acala on v0.


As shown in the figure above, the Acala-Phala cross-chain implementation based on Polkadot XCMP consists of three parts:

  • Chain: Rococo relay chain, two parachains: Acala, Phala
  • Cross-chain transaction: Message transfer between Acala to Phala and back via the relay chain realizes token transfer from Acala to the Private Wallet, and from the Private Wallet to Acala
  • Privacy black box: All the privacy transactions on Phala happen in the confidential contract running in the TEE, and the state of all encrypted data is invisible to the outside, thus achieving the privacy effect

Initiate a Transfer from Acala to Phala

In the world of Polkadot, in addition to personally controlled accounts, there is also the concept of “sovereign accounts”. For example, a Pallet module (or a smart contract) on Substrate can hold certain assets. When a parachain joins Polkadot, it can also get its own account on other parachains. The sovereign account is controlled by the corresponding parachain. Each parachain has a unique ID, which will be mapped to its corresponding sovereign account.

When Alice initiates a transfer transaction from Acala to Phala, for example, by transferring 1000 ACA to Phala’s Bob account, the following events happen in the background:

First, on the Acala chain, (Withdraw) 1000 ACA will be withdrawn from Alice’s account and deposited in (Deposit) Phala’s sovereign account

The Acala chain will initiate an XCMP transfer message, indicating that a cross-chain transfer to the Bob account under Phala has been initiated on Acala, and the message will be sent to the relay chain. This is a VMP UpwardMessage

After the relay chain receives the message, it will parse it for the parachain ID to find that the recipient of the message is Phala, and it will forward the message to Phala, which is a VMP DownwardMessage

HRMP is a simple cross-chain messaging method already supported by Rococo v0. Its principle is that the A chain initiates UpwardMessage to the relay chain, and then the relay chain initiates DownwardMessage to transfer the message to the B chain. Therefore, HRMP is implemented by a combination of two VMPs.

Phala’s Private Wallet Accepts Transfers of Assets and Converts Them into Their Private Versions.

Phala is very different from other chains. Usually, a parachain will adopt the standard implementation provided by Polkadot to accept external transfers and settle accounts for users. However, Phala is a generalized private computation layer, and it is very important for the chain to remain neutral to the application. Therefore, the Phala main chain does not do any processing and settlement of cross-chain transfers but directly transfers it to the confidential contract.

On the Phala side, after the cross-chain transfer message is accepted by the main chain, it is directly routed to the private wallet contract in the TEE. When the confidential contract receives the message, it will add 1000 ACA to Bob’s account.

All transfers in the confidentiality contract are encrypted end-to-end. Although it can be seen from the outside that Bob received 1000 ACA, he can initiate a private transfer back to Charlie again on Phala.

Therefore, in the Demo, we demonstrated a shielded transaction (Shielded Transaction) between two private wallets. The private transaction is end-to-end encrypted, and only the ciphertext can be seen on the chain, so the details of the transaction (such as the sending address, the receiving address, and the amount of money) are not visible on the chain.

We are also planning to work on a solution to allow compliance with global AML/CFTC rules so that users may enjoy absolute privacy while the protocol ensures their compliance with the regulations in an algorithmic way. We believe automating compliance based on certain criteria is the only sustainable path forward for financial transactions enjoying privacy in the permissionless setting. Otherwise, current regulations will continue to be gamed by malicious actors, while users who are well-intended but just want to exercise a high level of privacy with their finances will be exposed/refused service for no meaningful reason.

Initiate a Transfer from Phala to Acala

Finally, you can initiate a cross-chain transfer back to Acala from Phala’s private wallet to withdraw your money. For example, after receiving the 1000 ACA from Bob via a shielded transfer, Charlie can initiate a request on the Phala side to send 500 ACA to Acala’s Alice account, and the following things happen behind the scenes:

TEE receives the transfer order, reduces Charlie’s balance by 500 ACA, and initiates a cross-chain transfer transaction to the Phala chain.

After the Phala main chain receives a cross-chain transfer request, it will directly send the transfer message to the relay chain, which is a VMP UpwardMessage.

Similarly, the relay chain will forward it to Acala, which is a VMP DownwardMessage

After receiving the message, Acala protocol can withdraw 500 ACA from the Phala sovereign account and deposit it to Alice’s account. The cross-chain transfer is complete.


In existing blockchains such as Ethereum, the combination of DeFi and Privacy Layer 2 solutions needs to be mutually confirmed on-chain each time, and one Layer 2 protocol cannot interoperate with another Layer 2 protocol.

However, on Polkadot, the XCMP protocol allows parachains with strong customization capabilities to achieve convenient cross-chain interoperability with a minimal workload. The composability achieved through XCMP allows developers to build rich application cases, which is different from Ethereum composability in that it’s asynchronous but also allows for much greater throughput for each application involved.

In this article, we have demonstrated only the tip of the iceberg for the powerful capabilities of XCMP. We can directly enable Acala and Phala to interoperate, and through the combination of a DeFi parachain with privacy computation, DeFi can obtain confidentiality capabilities, oftentimes needed when dealing with financial data. In the Ethereum DeFi ecosystem, we have already seen the advantages of composability, so we believe that XCMP will become a powerful Dapp Building Block, and look forward to seeing more brand-new applications combined by parachains on Polkadot.

About Phala

A Substrate-based confidential smart contract blockchain on which you can develop confidential-preserving and privacy-first blockchain apps. Member of Substrate Builders Program starting lineup. Recipient of Web3 Foundation Grant.

Website | Twitter | Github | Telegram | Discord



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
Phala Network

Phala Network

Infrastructure of Web3.0 privacy protection