Summary
Phala Network is a Polkadot parachain that provides confidential smart contracts using Trusted Execution Environments (TEEs). To interact with Phala, developers need reliable RPC endpoints for reading on-chain data, submitting transactions, and deploying Phat Contracts. This article covers Phala RPC chain settings, how to connect, and what to consider when choosing an RPC provider.
Phala RPC Decision Checklist
Before integrating Phala RPC endpoints, evaluate these key factors:
| Criterion | What to check | Why it matters |
|---|---|---|
| Endpoint type | HTTPS vs WebSocket | WebSocket is required for real-time subscriptions (e.g., new blocks, events). |
| Network support | Mainnet only or also testnet | Testnet endpoints are essential for development and staging. |
| Rate limits | Requests per second (RPS) and monthly quota | Exceeding limits can cause dropped requests; choose a plan that matches your traffic. |
| Archive data | Full archive vs pruned state | Archive nodes allow historical queries (e.g., past balances, events). Needed for explorers and analytics. |
| Reliability | Uptime history, redundancy, failover | Production apps need consistent availability; look for providers with SLAs and multi-region deployment. |
| Latency | Geographic proximity and response times | Lower latency improves user experience, especially for interactive dApps. |
| Security | TLS encryption, authentication, DDoS protection | Prevents data interception and ensures endpoint availability. |
| Pricing model | Pay-as-you-go vs flat monthly fee | Choose based on your usage pattern; unpredictable spikes may favor flat-rate plans. |
What Is Phala Network?
Phala Network is a Polkadot parachain that brings confidential smart contracts to Web3 using Trusted Execution Environments (TEEs). Its unique architecture combines a public blockchain with secure enclaves, enabling trustless, private, and scalable computation. Developers build Phat Contracts—off-chain programs that can interact with external APIs and blockchains while maintaining data privacy.
To interact with Phala, applications need an RPC endpoint. This endpoint acts as a gateway to the blockchain, allowing you to read on-chain data, submit transactions, and deploy smart contracts. Choosing the right RPC provider is critical for performance, reliability, and cost.
Phala Chain Settings
Phala Network runs on the following chain parameters:
- Chain ID: 2035 (0x7f3)
- Native Token: PHA (Phala)
- Block Time: ~12 seconds (Polkadot relay chain)
- Consensus: Nominated Proof-of-Stake (NPoS) via Polkadot
- Network Type: Mainnet (Parachain)
For EVM compatibility, Phala also supports an EVM layer. The chain ID for the EVM side is also 2035.
How to Connect to Phala RPC
You can connect to Phala using standard JSON-RPC calls over HTTPS or WebSocket. Below is an example using curl to get the latest block hash:
curl -X POST https://rpc.phala.network \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"chain_getBlockHash","params":[0],"id":1}'
For WebSocket connections (e.g., with wscat or in JavaScript):
const WebSocket = require('ws');
const ws = new WebSocket('wss://api-phala.dwellir.com/02b83e9c-732e-4b15-b38e-9f24b75e8d66');
ws.on('open', function open() {
ws.send(JSON.stringify({
jsonrpc: '2.0',
method: 'chain_getBlockHash',
params: [0],
id: 1
}));
});
ws.on('message', function incoming(data) {
console.log(data.toString());
});
Choosing a Phala RPC Provider
When selecting an RPC provider for Phala, consider the following:
- Public vs Private Endpoints: Public endpoints (like
https://rpc.phala.network) are free but often rate-limited and less reliable. For production, a private or dedicated endpoint is recommended. - Provider Features: Look for providers that offer dedicated nodes, archive data, WebSocket support, and global load balancing.
- Pricing: Compare pay-as-you-go vs flat-rate plans. Some providers offer free tiers for low-volume use.
OnFinality provides managed Phala RPC endpoints and dedicated nodes with flexible pricing. You can find more details on the Phala network page and RPC pricing.
Common RPC Methods for Phala
Here are some frequently used JSON-RPC methods when interacting with Phala:
| Method | Description |
|---|---|
chain_getBlockHash | Get the hash of a block by number |
chain_getBlock | Get full block details |
state_getStorage | Read storage values |
state_call | Call a runtime API |
system_health | Check node health |
system_networkState | Get network state |
For a complete list, refer to the Substrate RPC documentation.
Troubleshooting Phala RPC Issues
- Connection refused or timeout: Check if the endpoint URL is correct and your firewall allows outbound connections. Try a different provider.
- Rate limiting: If you receive HTTP 429 or similar errors, reduce request frequency or upgrade to a plan with higher limits.
- Inconsistent data: Ensure you are connected to the same network (mainnet vs testnet). Archive nodes may be needed for historical queries.
- WebSocket disconnects: Implement reconnection logic in your application. Some providers have idle timeouts.
Key Takeaways
- Phala Network is a Polkadot parachain for confidential smart contracts using TEEs.
- RPC endpoints are essential for reading on-chain data and submitting transactions.
- Choose a provider based on reliability, rate limits, archive support, and pricing.
- OnFinality offers managed Phala RPC and dedicated nodes; see supported networks for details.
- Always test with a free tier before committing to a paid plan.
Frequently Asked Questions
What is the Phala RPC endpoint?
The public RPC endpoint is https://rpc.phala.network. For production, consider a private endpoint from a provider like OnFinality.
Does Phala support WebSocket? Yes, WebSocket endpoints are available for real-time subscriptions. Check with your provider for the specific URL.
What is the chain ID for Phala? The chain ID is 2035 (0x7f3).
How do I get PHA tokens for gas? PHA is the native token. You can acquire it on exchanges or via bridges. See the Phala docs for details.
Can I run my own Phala node? Yes, but it requires significant resources and maintenance. Managed services like OnFinality offer dedicated nodes without the operational overhead.
What is the difference between Phala mainnet and testnet? The testnet (Khala) is used for development and testing. It has its own RPC endpoints and token (tPHA).