Phala Network Docs
  • Home
    • 👾Phala Network Docs
  • Overview
    • ⚖️Phala Network
      • 💎Phala Cloud
      • 🥷Dstack
      • 🔐GPU TEE
    • 💎PHA Token
      • 🪙Introduction
      • 👐Delegation
        • Delegate to StakePool
        • What is Vault
        • What is Share
        • WrappedBalances & W-PHA
        • Examples of Delegation
        • Use Phala App to Delegate
        • Estimate Your Reward
      • 🗳️Governance
        • Governance Mechanism
        • Join the Council
        • Voting for Councillors
        • Apply for Project Funding
        • Phala Treasury
        • Phala Governance
        • Setting Up an Account Identity
  • Phala Cloud
    • 🚀Getting Started
      • Sign-up for Cloud Account
      • Start from Cloud UI
      • Start from Cloud CLI
      • Start from Template
    • 🟧Launch an Eliza Agent
    • 📦Create CVM
      • Create CVM with Docker Compose
      • Create CVM with Private Docker Image
      • Set Secure Environment Variables
      • Access Your Applications
      • Setting Up Custom Domain
      • Debug Your Application
      • Deployment Cheat Sheet
    • ⚙️CVM Management
      • Upgrade Application
      • Resize Resources
      • Check Logs
      • Private Log Viewer
    • 🔄Deploy Docker App in TEE
      • Expose Service Port
      • Generate RA Report
      • Access Database
      • Create Crypto Wallet
    • 🛳️Setup a CI/CD Pipeline
    • 🛠️Phala Cloud CLI Reference
      • phala
        • auth
        • cvms
        • docker
        • simulator
    • Production Checklist
    • ❓FAQs
    • 🔍Troubleshooting
    • 📖Glossary
    • 📋References
    • 🔒Use Cases
      • TEE with AI
      • TEE with FHE and MPC
      • TEE with ZK and ZKrollup
  • Dstack
    • Overview
    • Getting Started
    • Hardware Requirements
    • Design Documents
      • Decentralized Root-of-Trust
      • Key Management Protocol
      • Zero Trust HTTPs (TLS)
    • Acknowledgement
  • LLM in GPU TEE
    • 👩‍💻Host LLM in GPU TEE
    • 🔐GPU TEE Inference API
    • 🏎️GPU TEE Benchmark
  • Tech Specs
    • ⛓️Blockchain
      • Blockchain Entities
      • Cluster of Workers
      • Secret Key Hierarchy
  • References
    • 🔐Setting Up a Wallet on Phala
      • Acquiring PHA
    • 🌉SubBridge
      • Cross-chain Transfer
      • Supported Assets
      • Asset Integration Guide
      • Technical Details
    • 👷Community Builders
    • 🤹Hackathon Guides
      • ETHGlobal Singapore
      • ETHGlobal San Francisco
      • ETHGlobal Bangkok
    • 🤯Advanced Topics
      • Cross Chain Solutions
      • System Contract and Drivers
      • Run Local Testnet
      • SideVM
    • 🆘Support
      • Available Phala Chains
      • Resource Limits
      • Transaction Costs
      • Compatibility Matrix
      • Block Explorers
      • Faucet
    • ⁉️FAQ
  • Compute Providers
    • 🙃Basic Info
      • Introduction
      • Gemini Tokenomics (Worker Rewards)
      • Budget balancer
      • Staking Mechanism
      • Requirements in Phala
      • Confidence Level & SGX Function
      • Rent Hardware
      • Error Summary
    • 🦿Run Workers on Phala
      • Solo Worker Deployment
      • PRBv3 Deployment
      • Using PRBv3 UI
      • PRB Worker Deployment
      • Switch Workers from Solo to PRB Mode
      • Headers-cache deployment
      • Archive node deployment
    • 🛡️Gatekeeper
      • Collator
      • Gatekeeper
  • Web Directory
    • Discord
    • GitHub
    • Twitter
    • YouTube
    • Forum
    • Medium
    • Telegram
  • Legacy
    • Information
    • ⚒️Phala SDK
    • 👨‍🚀Builders Program
    • 🥷AI Agent Contract
      • WapoJS Functions
      • Phala Agent Gateway
  • AI Agent Contract (Legacy)
    • 👩‍💻Getting Started
      • Build Your First AI Agent Contract
      • Build An Agent to Transact Onchain
      • Build Your AI Agent Contract with OpenAI
      • Build Your AI Agent Contract with LangChain
      • Integrate with 3rd Party API with HTTP Request
      • Run a Local Testnet With Docker
      • AI Agent Contract Templates
    • 🧙‍♂️Examples
      • Create a Weather Agent w/ Function Calling
    • ⛓️Supported Chains
    • FAQ
  • Agent Wars (Legacy)
    • 📜Introduction
    • 💸Tokenomics
    • ▶️Getting Started
      • Wallet Setup & Get PHA
      • Buy and Sell Keys
    • 🧑‍🏫Tutorial
Powered by GitBook
LogoLogo

Participate

  • Compute Providers
  • Node
  • Community
  • About Us

Resources

  • Technical Whitepaper
  • Token Economics
  • Docs
  • GitHub

More

  • Testnet
  • Explorer
  • Careers
  • Responsible Disclosure

COPYRIGHT © 2024 PHALA.LTD ALL RIGHTS RESERVED. May Phala be with you!

On this page
  • About SideVM
  • Prepare Environment
  • Play with it
  • Programming SideVM
  • Compile Phat Contract and SideVM Program
  • Upload SideVM Program and Instantiate the Contract
  • Upload SideVM Program
  • More Resources

Was this helpful?

Edit on GitHub
  1. References
  2. Advanced Topics

SideVM

PreviousRun Local TestnetNextSupport

Last updated 1 month ago

Was this helpful?

WARNING

This section is no longer recommended for deploying on Phala. To build and deploy securely and efficiently, please use the fully managed platform instead. Check out the doc on how to .

About SideVM

SideVM is the core extension of Phat Contract. Despite the advantages above, the raw Phat Contract still has limitations compared with current Web2 backend programs:

  • Lifecycle limitation. The Phat Contract execution is triggered when users send on-chain transactions or off-chain queries to it, and the instance is destroyed when the execution finishes. This makes it impossible to do async requests or keep a long-live network connection;

  • Program environment limitation. The Phat Contract inherits the limitations of Ink! and only supports no_std crates. This also limits the resources a contract can use (e.g. listening to a port for connections).

SideVM is proposed to tackle these limitations. It runs in a different runtime. This means it can continuously execute, support std library, and listen to the port.

Prepare Environment

The SideVM support is already equipped to our public testnet. But it requires manual authorization to your contract to enable it to call the start_sidevm() function. Contact us is the #dev channel in our to get support.

Also, you can run your local testnet following our tutorial and then do the testing.

Play with it

Programming SideVM

We use as an example. It contains both the Phat contract and the SideVM program under sideprog folder.

The SideVM part listens to a local port. It will be launched by this if called.

Compile Phat Contract and SideVM Program

Just make under the folder and it will give you

  1. SideVM program sideprog.wasm

  2. Phat contract under target/ink/start_sidevm.contract

Upload SideVM Program and Instantiate the Contract

Upload SideVM Program

In Developer - Extrinsics, choose phalaFatContracts and clusterUploadResource. Change resourceType to SidevmCode, and drag your sideprog.wasm here.

Submit the transaction and you shall see its success.

Interact with Phat UI

Click Upload and drag your target/ink/start_sidevm.contract. Choose the default constructor and Cluster 0x0000000000000000000000000000000000000000000000000000000000000000. Click Submit. You should see something like

Start SideVM with Query

You can directly interact with your contract with Contract UI.

From the Worker log, we can see

More Resources

We do not have many documents on SideVM yet, feel free to ask us directly.

We have a but it does not support the SideVM program upload yet. So we need to upload it manually.

Use and change the endpoint to Phala (PoC 6) under TEST NETWORKS.

Go to , click sign in and link your address. You need to ensure the RPC Endpoint is and Default PRuntime Endpoint .

The start_sidevm query is used to start the SideVM program. It contains the to pink::start_sidevm().

Actually, we implemented the log server with SideVM too ().

Previous SideVM design:

SideVM program examples under

Our SideVM-related PRs:

🤯
Phala Cloud
get started
Discord server
https://github.com/Phala-Network/phat-contract-examples/tree/master/start_sidevm
line of code
frontend
Polkadot.js
https://phat.phala.network/
wss://poc6.phala.network/ws
https://phat-cluster-us.phala.network/poc6/pruntime/0xac5087e0
invoke
ref
https://github.com/Phala-Network/rfcs/blob/main/pink-sidevm/pink-sidevm.md
https://github.com/Phala-Network/phala-blockchain/tree/master/crates/pink/sidevm/examples
https://github.com/Phala-Network/phala-blockchain/pulls?q=sidevm+