Research

Understanding Phala Network: A Comprehensive Overview

Jul 5, 2024 ⋅  15 min read

Key Insights

  • Phala Network features an AI coprocessor that provides a secure and verifiable compute solution for integrating crypto and AI at the application layer.
  • Phala’s AI Agent Contracts are smart contracts that control AI agents, enabling AI tasks to be carried out via onchain resources.
  • In 2023, 849,000 offchain queries were handled by Phala AI Agent Contracts. By comparison, 1.1 million onchain transactions were processed on Ethereum.
  • Phala uses trusted execution environments (TEE) to maintain tamperproof and secure computation of coprocessor tasks.
  • Through RedPill, Phala AI Agent Contracts can access top LLMs (OpenAI, Llama, Claude, and Hugging Face), with control originating in smart contracts written onchain.

Introduction

Despite being public, blockchains are typically difficult to access from an engineering perspective. This problem becomes exaggerated when trying to incorporate foreign elements like artificial intelligence (AI) into blockchain-focused applications. Beyond that, engineers must face the challenge of maintaining privacy/user confidentiality when synergizing AI and blockchain. Phala Network addresses these issues through its blockchain-TEE (trusted execution environment) hybrid design. This setup forms the foundation for AI Agents (run by offchain worker nodes) to be controlled by onchain smart contracts.

Phala has four core components:

  1. Decentralized Computing Cloud Network: Phala is a backend host of scalable blockchain technology and a trusted execution environment (TEE) to ensure the verifiability and security of compute execution.
  2. TEE (SGX) Framework: The core Intel TEE architecture scheme that ensures secure and verifiable code execution within an isolated hardware-protected area of a computer’s processor.
  3. AI Agent Contracts: AI computing programs that enable EVM smart contracts to extend their capabilities offchain.
  4. Blockchain/Phala Nodes: Attested secure worker nodes that retrieve and execute transactions offchain. These nodes then use the blockchain to organize the decentralized network and incentivize workers.

In 2020, Phala secured a funding round at a $10 million valuation with participation from Candaq Group, InfiChain, Blue Mountain Labs, Incuba Alpha Group, and Exoplanet Capital. Its product was developed to offer AI-enabled, Turing-complete smart contracts, aiming to address the challenges posed by AI and centralized cloud computing. Following this momentum, Phala won a Polkadot parachain slot auction with 1,685 contributors in March 2022. Today, Phala is focused on being an AI coprocessor that provides a secure and verifiable compute solution for integrating crypto and AI at the application layer.

Technology

Phala enhances offchain interactions through its AI coprocessor which enables smart contracts to control and interact with AI Agents. The AI Agent smart contracts, the Phala blockchain, and hardware used by network nodes all work together to ensure coordination, security, and privacy on the network.

AI Agent Contracts

AI Agent Contracts enable developers to build smart contracts that control AI agents which can operate onchain or offchain. The code for these AI agents is written in TypeScript/JavaScript and is executed by Phala nodes. The execution is secure and private, given that Phala node virtual machines operate within trusted execution environments (TEEs). Currently, over 4,000 Phala AI Agent Contracts are online, with the ability to aggregate data from external APIs and plug into custom AI Agents. AI Agent Contracts remove the learning difficulty of accessing decentralized applications, from marketplaces to DEXs.

AI Agent Contracts are offchain confidential programs that utilize Phala’s trustless cloud computing infrastructure. At a technical level, AI Agent Contracts operate on the TEEs inside the Worker Nodes, which are organized by the Phala Blockchain. A subset of the Worker Nodes called Gatekeepers manage the keys to secure the network. As of today, there are more than 30,000 online workers (nodes that perform offchain computational tasks requested by clients).

Phala Blockchain

The Phala blockchain is a Polkadot parachain that coordinates activity among the various network nodes, published smart contracts, and encrypted contract states. Phala maintains its decentralized offchain compute network by connecting miners (who operate Worker Nodes) with developers (who deploy AI Agent Contracts). Phala does not have its own consensus algorithm but inherits the security from the Polkadot relay chain.

Worker Nodes

Worker Nodes provide compute resources to the network. They host AI Agent Contracts, the offchain programs, inside the nodes’ TEEs. The TEE protects the workload for code integrity and privacy. To join the network, miners anywhere in the world can deploy Worker Node software clients inside their TEE-compatible hardware setups, getting them verified onchain.

The core component of the Worker Node software is pRuntime (Phala Runtime), a program running inside the TEE. pRuntime receives and runs the computational tasks from the blockchain, ensuring the computation is tamperproof and secure. It establishes a chain of trust according to the following simplified steps:

  1. The developer publishes the AI Agent Contract onchain (never executed onchain).
  2. pRuntime fetches the contract code and verifies the code through the built-in light client.
  3. pRuntime executes the code (offchain) inside the TEE and generates a proof of execution by the TEE Remote Attestation.
  4. The proof is verified onchain.

The network has a group of special workers called Gatekeepers to ensure the computation is secure. Because Worker Nodes are permissionless and may exit the network at any point, tasks are deployed to redundant Worker Nodes with the same key to access the encrypted inputs, outputs, and states of the program. Gatekeepers manage the encryption keys and dynamically distribute the secrets to the Worker Nodes.

Execution Proofs

Phala Network has a modular proof system that starts with the trusted execution environment (TEE) proofs and evolves to support a mix of TEE and other cryptographic proof systems.

Trusted Execution Environment (TEE)

A trusted execution environment (TEE) is a privacy-focused technology that isolates a node’s code execution and operations from the main operating system of a computer’s processor. Phala uses Intel’s Software Guard Extensions (SGX) for TEE processing. This system ensures that even individuals with physical access to the machines, such as Phala Network operators or malicious third parties, cannot view the state or manipulate the data processed by the node.

Trusted execution environments are often used as an alternative to zero-knowledge proofs (ZKPs). TEEs and ZKPs both aim to ensure computational integrity and verifiability. However, Phala uses TEEs because of the smaller computation costs, lower proof size and verification costs, and simplicity. Because TEE proofs are generated as a result of computation inside a TEE, they tend to be less costly than ZKPs. In addition to being cheaper, TEE proofs are more predictable, given that they often have constant proof sizes regardless of the computation. Lastly, TEEs have less complexity in implementation with simple-to-produce proofs and assumptions based on hardware integrity versus cryptographic hardness (probabilistic unlikelihood of reproducing the same ZKP).

Multi-Proof: TEE + Cryptographic Proofs

While TEEs can prove the integrity of execution, it also raises the security concerns of relying on a single-proof system. Phala pioneers the combination of TEE and cryptographic proofs, such as ZKPs and FHE (fully homomorphic encryption), to address the problem:

  • zkDCAP verifier: ZK-based onchain TEE proofs verifier
  • jtee: Produces both ZK and TEE proofs for user programs by integrating with RiscZero zkVM

Attestation and Sealing Key Policies

Phala’s worker nodes integrate Intel’s Data Center Attestation Primitives (DCAP) for verification. This enables worker nodes to generate remote attestations, which are proofs ensuring that TEEs are operational and running uncompromised code. The protocol ensures nodes are honest by running various remote attestations.

Multi-Layered Key Rotation for Gatekeepers

Phala incorporates a comprehensive key rotation mechanism to ensure the privacy of its contracts and the overall security of its system. This process periodically updates the root key according to the election rule. During each era, new Gatekeepers are elected with the permission of the Council and generate a new master key (root key) through a secure key exchange protocol. This new key is used to re-encrypt the Gatekeeper states, which are then distributed and confirmed among the new Gatekeepers. During this transition, communication between miners and Gatekeepers is temporarily blocked to maintain consistency and security. Communication resumes only once the key rotation is complete, with the delay being two onchain confirmations.

In addition to rotating the root key, Phala also periodically updates its cluster keys (keys to manage and secure communication within a cluster of worker nodes) and contract keys (keys for interacting with specific smart contracts) to enhance security. Miners generate new contract keys, re-encrypt contract states, and securely transmit these keys to Gatekeepers. This approach ensures that even if old keys are compromised, the data encrypted with new keys remains secure.

Confidence Level & SGX Function

To secure the network, each worker's CPU is assigned a confidence level, which is determined by running a remote attestation report. The confidence level measures the security of the SGX Enclave execution environment.

There are five confidence tier levels:

  • Tiers 1, 2, and 3 are considered by the network as the highest security levels because they reject hardware with blacklisted vulnerabilities. Phala’s Gatekeepers are represented in these tiers. Nodes in these tiers can host financial applications and utilities for managing secret keys, including wallets and node key management services.
  • The network gives Tiers 4 and 5 a lower security report because these hardware systems require some configuration fix or have out-of-date BIOS firmware. A tiered approach enables developers and users to choose the appropriate level of security and economic feasibility for their specific needs.

Tokenomics

Token Generation Event

  • PHA launched in September 2020 with a maximum supply of 1 billion, of which 732 million PHA (73%) are currently circulating. The PHA token is used in Phala blockchain validation, supply-side (worker) incentivization, application pricing, and governance.

Allocations

  • Stakedrop – 21 million PHA (2.1%)
    • Stake KSM to receive PHA airdrop
    • Vesting: Fully vested at TGE.
  • Founding Team – 50 million PHA (5%)
    • Core team and founding developers.
    • Vesting: 20% of the allocation is unlocked at TGE, with 5% of the allocation unlocking every 16 months.
  • Investors – 150 million PHA (15%)
    • Fundraising round in 2020 with participation from Candaq Group, IOSG Ventures, SNZ Holding, Waterdrip Capital, Incuba Alpha Group.
    • Vesting: 60% of the allocation is unlocked at TGE, with 20% of the allocation unlocking every six months thereafter (fully vested after one year).
    • All of the investors’ tokens are fully vested in 2022.
  • Parachain Slot Auction – 69 million PHA (6.9%)
    • Raised $3.6 million in the Polkadot parachain slot auction. Has three vesting allocations (Polkadot, Kusama, and Reserved).
    • Vesting Polkadot (2.2% of max supply): 15% of this allocation is unlocked immediately (June 2022), with 85% being linearly vested over 96 weeks.
    • Vesting Kusama (2.5% of max supply): 34% of this allocation is unlocked immediately (July 2021), with 66% being vested monthly over 11 months.
    • Vesting Reserved (2.2% of max supply): This allocation will remain locked.
  • Testnet Incentive – 10 million PHA (1%)
    • Network participants are rewarded for running gatekeeper and full nodes on Phala testnets.
    • Vesting: Fully vested at TGE.
  • Compute Rewards – 700 million PHA (70%)
    • Reward nodes performing computations on the network
    • Vesting: Initial daily reward of 720,000 PHA, with rewards decreasing by 25% every 180 days.

Mining

Miners are required to stake and run a performance test measuring how much computational capacity they accounted for. After doing so, the miners receive an initial virtual score representing their worth to the network. The network's subsidy budget and various parameters are designed to maintain a balanced and fair reward system, ensuring an efficient use of resources.

Compute Staking

  • Phala has a non-consensus staking mechanism that manages up to 1 million CPU cores from over 100,000 nodes. Stake Delegation includes a feature called StakePool to connect computing nodes with PHA holders. As such, PoolOwners can create and manage StakePools allowing groups of workers to delegate their PHA to the pool. A StakePool sets up two parameters: commission rate and capacity of PHA tokens in the StakePool. When choosing where to stake, delegators consider the capacity gap (the difference between the cap and the real amount of delegated tokens) and fee delegation (the difference between the amount of delegated tokens and the ones that have been staked).

Computing

Developers use PHA to acquire computing resources to deploy and run AI Agent Contracts. Phala adopts a stake-to-compute model. Developers deposit PHA to get a proportional amount of contract code storage, CPU time, and other network resources.

Governance

PHA is also used for PhalaDAO governance. Future onchain updates will be decided through governance. Phala uses a council to interact with its referenda mechanism, wherein each public referendum proposal requires a minimum deposit of bonded tokens that are locked up until the proposal is brought to a vote.

Ecosystem

Demand-Side

The success of Phala’s AI Agent product can be better understood in the context of Ethereum’s smart contracts. For starters, Phala has deployed 4,777 AI Agent Contracts, while Ethereum has around 61 million smart contracts. However, since the start of 2024, AI Agent Contracts have executed 142 million offchain queries, compared to 215 million onchain transactions processed on Ethereum. AI Agent Contracts showed resilient demand, only lagging behind Ethereum in daily executions by about 36% since the start of 2024.

By leveraging offchain computation, AI Agent Contracts offer scalability solutions and new types of interactions not feasible on typical blockchain networks, such as AI-driven tasks, data-intensive processing, and gaming. That said, Phala’s coprocessor can still extend into multiple sectors, from DeFi to AI to SocialFi.

AI and NFT (Agent Wars)

Agent Wars is a Web3 game that enables users to launch their own AI agents with tokenomic structures tied to the agent in the form of keys (similar to friend.tech). Agents are represented as an ERC-721 NFT with a unique avatar linked to an X (formerly Twitter) account. An agent is created through a three-day onchain auction, with bids based on the account's follower count. The auction funds then cover the hosting and training costs.

AI (RedPill)

RedPill aggregates multiple AI services (OpenAI, Llama, Claude, and Hugging Face) into a single API, enabling users to access a range of large language model (LLM) services in one place. Phala AI Agent Contracts can access top LLMs, with control originating in smart contracts written onchain.

SocialFi (Lens Protocol)

Lens Protocol is built around a suite of smart contracts on top of Polygon that handles user profiles, posts, comments, and interactions. At its core, Lens is a decentralized social platform that empowers creators to own their communities and decide which information to make public or keep private. Phala collaborated with Lens Protocol in Q2 2203 to release the LensAPI Oracle. Hosted on Phala Network’s AI-Agent Contract infrastructure, Lens Dapp developers can deploy and verify no-code oracles for incentive- and revenue-based Lensverse social applications.

DeFi (SubBridge and inDEX)

SubBridge extends the capabilities of existing smart contracts to include offchain data processing and communication. For example, when a user transfers assets from Ethereum to Phala, the assets are locked in an Ethereum smart contract. The equivalent assets are then released on Phala. This method keeps the asset's total supply and value consistent across both networks. SubBridge enables a variety of use cases, including cross-chain collateral in lending/borrowing, multichain yield-farming, and decentralized trading. inDEX SDK is a cross-chain agnostic intent execution engine, akin to a Google search for Web2. The platform enables developers to build utility tools, cross-chain trading, and other one-click solutions.

Supply-Side (Workers)

Phala has seen workers rise 32% since the start of the year. This growth may indicate that Phala incentives are working to attract more miners on the supply side, enabling better processing of AI Agent Contracts. With more workers, the network can better manage the increasing demand while maintaining low latency among contract execution requests.

Roadmap

Technical Improvements

Phala’s 2024 roadmap includes upgrades to five main components:

  • Multi-proof system: Improving Phala’s Trustless Coprocessor Network by combining cryptographic proofs, including ZKP, MPC, and FHE; updating SGX DCAP into all workers; and releasing Tokenomics 2.0.
  • Verifiable GPU TEE: Extending the decentralized computation network to support commercial TEE GPUs such as Nvidia H100, providing trustless and verifiable AI model computing capability
  • Performance and developer experience: Launching pRuntime V3 with 5-10x CPU efficiency and gigabytes of memory. Supporting novel TEE environments like confidential virtual machines and containers.
  • Lead AI-coprocessor adoption through rich integrations to LLMs, LangChain, and AutoGPT, as well as partnerships with other AI and DePIN companies.
  • Focusing on DAO and community development through the Hashforest Development Plan, Treasury Plan, Phala Growth Program 3.0, and the simplification of Phala tech.

Growth Strategy

The Phala Builders Program offers comprehensive support for developing and scaling applications using AI Agent Contracts, including:

  • Funding Tiers:
    • Tier 1 maximum value of $20,000 in PHA tokens.
    • Tier 2 maximum value of $50,000 in PHA tokens.
  • Technical guidance encompassing design, testing, and deployment.
  • Marketing and network support, promoting projects through Phala's channels and community.

Phala’s Ambassador Program enables community members to work in four core departments: marketing, community, compute, and content-related tasks. Ambassadors are rewarded with monthly PHA, bonuses, promotional rewards, and exclusive networking opportunities while contributing to the growth and education of the Web3 community.

Hackathon and Grant Initiatives include:

  • Phala dAGI Hackathon: For summer 2024, Phala Network has collaborated with other major AI projects to host a hackathon in Brussels with a prize pool of $100,000.
  • Tipping System: Separate from the proposal project, tipping allows Phala users to suggest tips for published protocol contributions. The final value of a tip is determined by the median of all tips from the tippers (currently just supported by the Council members). Phala offers two main types of tips:
    • Public tips: Can be suggested by anyone, requires a small bond, and offers a 20% finder’s fee paid out from the final amount.
    • Tipper-initiated tips: Tips proposed by council members, that do not require a bond or carry a finder’s fee.
  • Phala Bounty Program offers various tasks with corresponding rewards:
    • Primary: Fix minor bugs, optimize code, or update documentation within 2 hours for $1-5 equivalent in PHA.
    • Advanced: Optimize code or complete small functions within 10 hours for about $100 equivalent in PHA.
    • Expert and Mining-related: Determined through governance and team discussions, with rewards based on task difficulty as assessed by Phala’s technical team.

Closing Summary

Phala Network is a leading coprocessor protocol that provides a secure and privacy-based solution for integrating crypto and AI at the application layer. Its AI Agent Contracts enable developers to build new types of applications that leverage the computational abilities of AI agents with onchain resources. Phala has already seen traction in its general coprocessor contracts (AI Agent Contracts), almost reaching 1 million daily transactions in 2023. Phala is poised to take advantage of the AI narrative as applications continue to capitalize on the intersection between crypto and AI.

——

Let us know what you loved about the report, what may be missing, or share any other feedback by filling out this short form. All responses are subject to our Privacy Policy and Terms of Service.

This report was commissioned by Hashforest Technology Pte. Ltd. All content was produced independently by the author(s) and does not necessarily reflect the opinions of Messari, Inc. or the organization that requested the report. The commissioning organization does not influence editorial decision or content. Author(s) may hold cryptocurrencies named in this report. This report is meant for informational purposes only. It is not meant to serve as investment advice. You should conduct your own research, and consult an independent financial, tax, or legal advisor before making any investment decisions. Past performance of any asset is not indicative of future results. Please see our Terms of Service for more information.

No part of this report may be (a) copied, photocopied, duplicated in any form by any means or (b) redistributed without the prior written consent of Messari®.

Upgrade to Messari Pro

Gain an edge over the market with professional grade tools, data and research.

Already a member? Sign in

Upgrade to Messari Pro

Gain an edge over the market with professional grade tools, data and research.

Already a member? Sign in

Onchain Jíbaro. Background: Photography, Quantitative Banking, & Manual Labor.

Matthew Krill

Student at the University of Virginia. Krill among whales. His primary interests are infra, DeFi arbitrage, and programming.

Mentioned in this report

Read more

Research Reports

Read more

Based on your watchlists

Create a new watchlist
Read more

Research Reports

Read more

Based on your watchlists

Create a new watchlist

About the authors

Onchain Jíbaro. Background: Photography, Quantitative Banking, & Manual Labor.

Student at the University of Virginia. Krill among whales. His primary interests are infra, DeFi arbitrage, and programming.

Mentioned in this report