Introduction of Phat Contract

Phala Network
Phala Network
Published in
5 min readDec 9, 2021

--

What’s your expectation of smart contracts?

My answer would be:

Provide rich features like normal programs with better performance and larger computing power by the concurrency of multiple computing nodes.

The smart contracts introduced by Ethereum blockchain are really an innovation to extend the capability of blockchain. At the first time, all the rules are defined and enforced with unchangeable code and irreversible transactions. Correspondingly, we have seen its wide adoption in decentralized finance, where trust is valuable. Despite the success in trust-needed financial cases, from the perspective of developers, the current smart contract platforms are closed: you cannot easily access the data and services out of them. Such a problem even requires creating some ad-hoc Oracle blockchains to solve! Let alone the platitudes to improve the performance of existing blockchains.

Phala is committed to providing a universal decentralized computing network that can be freely combined with decentralized smart contracts, storage protocols, and data indexing services. What we have achieved is a trustless cloud of more than 20,000 workers. These computing nodes are organized under a framework that enables the decoupling of execution and consensus: Unlike existing platforms where all the contracts are executed by a single miner during the block production process (with other miners doing duplicated execution for validation), Phala enforces the faithful execution in each worker without (or only with a small factor of) duplication, thus its computing power increases linearly to the number of workers. We believe this is the prerequisite towards a decentralized computing cloud with the power to carry the Web3 world.

Phala was well-known as the confidential blockchain by combining TEE and blockchain, and this can easily make people ignore the real value of our design: To move the computation off-chain removes the limitations on the current smart contract, leading to the powerful Phat Contract with rich features:

  • Support computation-intensive tasks. For the first time, even a single contract can fully utilize the computing power of a worker, needless to worry about blocking the whole blockchain. For example, the requirements for image/video rendering are boosted with the popularity of the NFT and Metaverse, while the rendering jobs are CPU-intensive and expensive. By leveraging the Gramine Project, we have finished the proof-of-concept to run the unmodified open-source renderer Blender in our workers. With concurrent programming, it is possible to combine the power of multiple workers and serve the heavy jobs;
  • Serve low-latency real-time computation. The response time for Metaverse and game interaction should not exceed one second. However, traditional blockchain smart contracts cannot meet the requirement of low-latency services (since they are executed at block intervals). Fat Contract can achieve millisecond-level read and write responses, making it a perfect choice to deploy Metaverse and game services;
  • Access Internet services. The off-chain secure workers can safely delegate complicated asynchronous requests for Fat Contract. In our hackathon, we have presented a demo bot of BTC price. You can send an HTTP request to query the BTC price from the existing web service, and then report it to your Telegram account through the corresponding HTTP API. All these operations are achieved within 100 LoC in the Fat Contract.

Most importantly, such powerful Phat Contracts are executed inside our secure workers, which cannot peek at the customers’ data or manipulate the execution to provide false results, so the beloved confidentiality and irreversibility are still promised during contract execution. For now, we rely on the trusted execution environment (TEE), specifically Intel SGX, as the secure workers, and this design can support other workers like AMD SEV, or even MPC- or ZKP-based solutions.

The application scenario of Fat Contract

Back to our starting question, we try to jump out of the stereotype of the current smart contract and rethink how the contract should be like in a real computing cloud. This is the motivation that we design and implement Phat Contract: it should first behave like a normal program instead of a smart contract, and then we will empower it with the decentralized and trustless nature of blockchain. To clarify again:

Phat Contract is a kind of decentralized program instead of the smart contract, which supports real-time computation-intensive tasks and have the access to all the services even they are out of the blockchains.

Our faith in the Phat Contract also comes from the feedback of our community. During our last hackathon, we have seen some talented developers’ creations with the powerful Phat Contract. For now, there are two ways to play with Phat Contract:

  • You can now revisit our hackathon tutorial and follow it to fork our codebase and make the changes. This will give you an immediate experience of the abilities of Phat Contract;
  • Our support for Parity’s Ink! Contract is on its way. You can develop your contract with the secure and efficient Rust programming language, and enjoy the performance improvement from our off-chain workers without the necessity to fork our large codebase.

Just like Phat Contract, Phala meant to be open and keep improving. We welcome feedback from developers all over the world to add more inspiring features to the Fat Contract. Why not join our community now and get your hands dirty with the Fat Contract?

About Phala

Phala Network tackles the issue of trust in the computation cloud.

This blockchain is a trustless computation platform that enables massive cloud processing without sacrificing data confidentiality. Built around TEE-based privacy technology already embedded into modern processors, Phala Network’s distributed computing cloud is versatile and confidential. By separating the consensus mechanism from computation, Phala ensures processing power is highly scalable but not wasteful. Together, this creates the infrastructure for a powerful, secure, and scalable trustless computing cloud.

As a member parachain of the Polkadot cross-chain ecosystem, Phala will be able to provide computing power to other blockchain applications while protecting the data layer, enabling possibilities like privacy-protected DeFi trading positions and transaction history, co-computing DID confidential data, developing light-node cross-chain bridges, and more.

On-chain services currently being developed on Phala Network include Web3 Analytics: high-performance smart contracts from Phala to enable highly concurrent mass data analytics with privacy, paving the way for an alternative to Google Analytics that inherently respects individual confidentiality.

🍽 — Subscribe | Website | Twitter | Github
🥤 — Discord | Forum | Telegram |Italiano |Français | Persian | Korean

--

--