Run Local Testnet
In this tutorial, we’re going to set up a development environment. We are going to deploy a full stack of the core blockchain and connect the Web UI to the blockchain. By the end of the tutorial, you will be able to:
- Send confidential Commands and Queries
- Get a ready-to-hack version of Phala Network for building your confidential DApps
phala-node: The Substrate blockchain node
pRuntime: The TEE runtime. Contracts run in
pherry: The Substrate-TEE bridge relayer. Connects the blockchain and
(Phala architecture overview)
In this tutorial, we assume the operating system is Ubuntu 22.04. Other Linux distributions should also work, but the instructions or commands may vary. 4 cores and 8GB RAM is the minimal requirement to build the project including the core blockchain.
The Phala-Network/phala-blockchain repository always contains the latest build instructions, at the time of writing (December 26, 2022), we use the following commands to set up development environment:
# First clone the repository
git clone https://github.com/Phala-Network/phala-blockchain.git
# Change to the repository directory
# Install system dependencies:
sudo apt install -y build-essential pkg-config libssl-dev protobuf-compiler
# Install Rust
curl https://sh.rustup.rs -sSf | sh
# Install dependencies for Substrate development
git submodule update --init
# Installl LLVM 14
chmod +x llvm.sh
Then run the following command to build the Phala blockchain:
cargo build --release
It takes approximately 20 minutes to complete the building process on a laptop equipped with an AMD Ryzen 7 4700U processor with 8 cores, 8 threads, and 32GB of RAM.
We might want to clean up runtime data to have to clean starting environment, from the root of the
phala-blockchainproject, run this to clean things up:
Then go ahead and run these 3 commands in 3 separate terminals:
git clone https://github.com/shelvenzhou/phala-blockchain-setup.git
Run the following commands to create a devPHAse project:
# create a new project, or skip it if you already have one
# Add devPHAse to the project
yarn add -D devphase
yarn add -D typescript ts-node
# Init project
yarn devphase init
Then start the local testnet with:
yarn devphase stack run
Open a separate terminal, run the following command to setup the local testnet:
yarn devphase stack:setup
By default you get the Phala blockchain node at ws://localhost:9944 and the pruntime at http://localhost:8000, you can change the configuration at
devphase.config.ts, for more details check out the devPHAse repository
As the above figure shows, we first click the green dot at the upper-right cornor to set the
ws://localhost:9944if you start the chain via the devPHAse approach, and change the PRuntime field accordingly.
Don’t forget to claim some
Test-PHAs, they’re required to deploy Phat Contracts and send transactions.
Set the field
ws://localhost:9944and then click the
switchbutton to connect to it.
Congratulations! Now you have a fully qualified local development environment!