PixelOracle
Reference

Documentation

Technical documentation for PixelOracle covering architecture, query lifecycle, ZK compression, cross-chain verification, API endpoints, fee structure, and error handling.

Oracle documentation library
01

Getting Started

PixelOracle is a zero-knowledge oracle infrastructure built on Solana. It provides privacy-preserving data verification for DeFi protocols, DAO governance systems, gaming applications, and any on-chain program that needs reliable external data without exposing query metadata. The protocol uses Groth16 zero-knowledge proofs to ensure that oracle responses are mathematically verifiable while keeping query inputs private.

To integrate PixelOracle, you need three things: a Solana RPC connection, an API key from the developer portal, and the @pxoracl/sdk npm package. The minimum viable integration is five lines of code. Install the package, initialize the client, and call oracle.query with your target asset and data type. The SDK handles commitment generation, network routing, proof verification, and result parsing internally.

API keys are available in five tiers based on $PXCL staking. The free tier provides 100 queries per day with basic verification. Higher tiers unlock ZK proof generation, cross-chain queries, batch operations, and dedicated node access. See the Fee Structure section below for complete tier details.

quickstart.ts
npm install @pxoracl/sdk @solana/web3.js

import { PxOracle } from '@pxoracl/sdk';
import { Connection } from '@solana/web3.js';

const oracle = new PxOracle({
  connection: new Connection('https://api.mainnet-beta.solana.com'),
  apiKey: 'pxcl_live_your_key_here',
  chain: 'solana',
  compression: true,
});

const result = await oracle.query({
  asset: 'So11111111111111111111111111111111111111112',
  dataType: 'price_feed',
  proof: true,
});

console.log(result.verified, result.value);
02

Architecture Overview

PixelOracle operates as a five-layer stack built on Solana. Layer 0 is the Solana runtime itself, providing sub-second finality for oracle transactions. Layer 1 is Light Protocol ZK Compression, which stores oracle proofs in compressed PDAs at roughly 1/1000th the cost of standard Solana accounts. Layer 2 is the Anchor oracle program, an on-chain program that manages the query lifecycle, stores verification keys, and executes proof verification. Layer 3 is the cross-chain bridge adapter layer, containing protocol-specific adapters for Ethereum, BSC, and other EVM-compatible chains. Layer 4 is the privacy-preserving query engine, which implements ZK circuits ensuring that query inputs remain private while outputs are publicly verifiable.

The oracle network consists of multiple independent nodes that aggregate data from external sources, reach consensus on results, and submit signed attestations to the on-chain program. A query is considered verified when at least 2/3 of active nodes agree on the result. Each node runs the same aggregation logic but fetches data independently, reducing the risk of single-source manipulation. Node operators are required to stake $PXCL tokens as collateral, and nodes that submit incorrect data are subject to slashing.

The proving system uses Groth16 on the BN254 elliptic curve. The circuit takes query parameters and the oracle result as private inputs and outputs a commitment hash as the public signal. The trusted setup was performed via a 128-participant MPC ceremony, and the resulting verification key is stored immutably in the Anchor program. Proof generation runs client-side in the SDK and takes 300-500 milliseconds depending on circuit complexity.

03

Query Lifecycle

Every oracle query follows a six-step lifecycle. First, the client creates a SHA-256 commitment hash over the query parameters and a random nonce. This commitment is submitted to the oracle network without revealing the actual query parameters. Second, the commitment is broadcast to all active oracle nodes. Third, nodes independently aggregate data from external sources and reach consensus on the result using a 2/3 threshold voting protocol. Fourth, a Groth16 zero-knowledge proof is generated over the result, binding the oracle output to the original commitment without revealing the inputs. Fifth, the proof and result are stored in a Light Protocol compressed PDA on Solana. Sixth, the client receives the verified response containing the value, proof hash, risk score, and verification status.

The entire lifecycle completes in under two seconds for single-chain queries. Cross-chain queries add the bridge latency of the source chain (12-15 seconds for Ethereum, 3-5 seconds for BSC). The SDK exposes hooks for each lifecycle stage via event emitters, allowing you to track query progress in real-time. Failed queries are automatically retried up to three times with exponential backoff before returning an error.

lifecycle.ts
// Step 1: Client creates SHA-256 commitment
const commitment = oracle.createCommitment({
  asset: 'TOKEN_MINT', dataType: 'price_feed', nonce: crypto.randomUUID(),
});

// Step 2: Commitment submitted to oracle network
// Step 3: Nodes aggregate data, reach consensus
// Step 4: Groth16 proof generated over result
// Step 5: Proof + result stored in compressed PDA
// Step 6: Client receives verified response

// The SDK handles steps 2-6 internally via oracle.query()
04

ZK Compression

PixelOracle uses Light Protocol ZK Compression to store oracle proofs and results on Solana at a fraction of the cost of standard accounts. Traditional Solana accounts require rent-exempt balances of approximately 0.002 SOL per account. With ZK Compression, the same data is stored in a Merkle state tree where only the tree root lives on-chain. Individual proof records are stored as leaves in the tree, with inclusion proofs provided via 26-hash Merkle paths. This reduces per-proof storage cost to approximately 0.000002 SOL, a savings of roughly 1000x.

Each state tree has a depth of 26, supporting up to 67 million leaf entries. When a tree fills up, a new tree is created automatically. The SDK handles tree selection and Merkle path construction transparently. Reading compressed data requires an RPC provider that supports the Light Protocol indexer API. Most major Solana RPC providers include this support. When compression is enabled, all oracle.query results, oracle.getProof history lookups, and oracle.verify operations read from the compressed state tree instead of standard accounts.

The compression layer also enables efficient historical queries. Because Merkle trees are append-only, historical proof records are preserved indefinitely without incurring ongoing rent costs. The oracle.getProof method queries the compressed state tree directly, supporting pagination, time-range filters, and circuit-level filtering. This makes PixelOracle practical for applications that need to store and retrieve millions of oracle proofs over the lifetime of a protocol.

compression.ts
// Standard Solana account: ~0.002 SOL rent per proof
// Compressed PDA via Light Protocol: ~0.000002 SOL per proof
// Savings: approximately 1000x cost reduction

const oracle = new PxOracle({
  connection,
  apiKey: 'your_key',
  compression: true,  // Enable ZK compression
});

// Proofs stored in Merkle state tree (depth 26)
// Each tree holds ~67 million entries
// Tree root verified on-chain, leaves stored off-chain
// Proof of inclusion via Merkle path (26 hashes)
05

Cross-Chain Setup

Cross-chain queries allow you to fetch and verify data from Ethereum, BSC, and other EVM-compatible chains while settling on Solana. Each source chain requires its own RPC endpoint configured in the PxOracle constructor. The SDK ships with built-in bridge adapters for Ethereum and BSC. Additional adapters for Polygon, Arbitrum, and Avalanche are under development.

When you call oracle.crossChain, the adapter fetches the requested data from the source chain and generates a Merkle Patricia Trie storage proof against the source block header. This storage proof is a cryptographic guarantee that the data existed in the source chain state at a specific block height. The proof is then bridged to Solana, where the oracle program verifies it against a trusted block hash relay. No trusted bridge operator is required because verification is purely mathematical.

The confirmations parameter controls how many blocks must pass on the source chain before the data is considered final. For Ethereum, 12 confirmations (approximately 2.5 minutes) provides strong finality. For BSC, 15 confirmations (approximately 45 seconds) is recommended. Lower confirmation counts reduce latency but increase the risk of reorg invalidation. The SDK will reject cross-chain results where the source block has been reorged out of the canonical chain.

cross-chain-config.ts
const oracle = new PxOracle({
  connection,
  apiKey: 'your_key',
  crossChain: {
    ethereum: {
      rpc: 'https://eth-mainnet.alchemyapi.io/v2/YOUR_KEY',
      confirmations: 12,
    },
    bsc: {
      rpc: 'https://bsc-dataseed1.binance.org',
      confirmations: 15,
    },
  },
});

const result = await oracle.crossChain({
  sourceChain: 'ethereum',
  asset: '0xdAC17F958D2ee523a2206206994597C13D831ec7',
  dataType: 'price_feed',
  verifyStorageProof: true,
});
06

API Endpoints

The PixelOracle REST API provides direct access to oracle queries, proof verification, query status polling, cross-chain verification, and protocol statistics. All endpoints except /api/v1/stats require a Bearer token in the Authorization header. The base URL for all requests is https://api.pixeloracle.io. Rate limits are determined by your API key tier.

POST/api/v1/query

Submit an oracle query for a specific asset and data type. Returns a verified result with an optional ZK proof. The commitment is generated server-side from the request parameters and a random nonce. Queries are routed to the oracle node network for consensus before the response is returned.

Request Body
{
  "asset": "So11111111111111111111111111111111111111112",
  "dataType": "price_feed",
  "proof": true,
  "compression": true,
  "chain": "solana"
}
Response
{
  "queryId": "pxq_8f3a1b2c4d5e6f7a",
  "status": "VERIFIED",
  "value": 142.57,
  "timestamp": 1712764800,
  "proofHash": "0x3a9f...c4e1",
  "riskScore": 0.02,
  "consensusNodes": 7,
  "totalNodes": 9,
  "compressionTxId": "5Kj2...mN8x"
}
Example
curl -X POST https://api.pixeloracle.io/api/v1/query \
  -H "Authorization: Bearer pxcl_live_your_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "asset": "So11111111111111111111111111111111111111112",
    "dataType": "price_feed",
    "proof": true,
    "compression": true,
    "chain": "solana"
  }'
GET/api/v1/verify/:proofHash

Verify a previously generated ZK proof by its hash. Returns the verification status, the public inputs used during proof generation, and the on-chain verification transaction signature. This endpoint is read-only and does not generate a new proof.

Response
{
  "proofHash": "0x3a9f...c4e1",
  "verified": true,
  "circuit": "oracle_v2_groth16",
  "publicInputs": {
    "commitment": "0x7b2e...d9f3",
    "result": 142.57,
    "timestamp": 1712764800
  },
  "verificationTx": "4Rj8...kP2v",
  "verifiedAt": 1712764812
}
Example
curl https://api.pixeloracle.io/api/v1/verify/0x3a9f...c4e1 \
  -H "Authorization: Bearer pxcl_live_your_key_here"
GET/api/v1/status/:queryId

Check the current status of an oracle query by its ID. Useful for polling long-running cross-chain queries or batch operations. Returns the current lifecycle stage, elapsed time, and partial results if available.

Response
{
  "queryId": "pxq_8f3a1b2c4d5e6f7a",
  "status": "CONSENSUS_REACHED",
  "stage": 4,
  "totalStages": 6,
  "elapsedMs": 1240,
  "consensusNodes": 7,
  "totalNodes": 9,
  "partialValue": 142.57,
  "estimatedCompletionMs": 800
}
Example
curl https://api.pixeloracle.io/api/v1/status/pxq_8f3a1b2c4d5e6f7a \
  -H "Authorization: Bearer pxcl_live_your_key_here"
POST/api/v1/crosschain

Submit a cross-chain verification request. Fetches data from the specified source chain, generates a Merkle Patricia Trie storage proof, bridges it to Solana, and verifies the result on-chain. Requires an Analyst tier API key or higher.

Request Body
{
  "sourceChain": "ethereum",
  "asset": "0xdAC17F958D2ee523a2206206994597C13D831ec7",
  "dataType": "price_feed",
  "confirmations": 12,
  "verifyStorageProof": true
}
Response
{
  "queryId": "pxq_cc_2d4e6f8a1b3c5d7e",
  "status": "VERIFIED",
  "sourceChain": "ethereum",
  "sourceBlock": 19482561,
  "value": 0.9998,
  "storageProofValid": true,
  "proofHash": "0x8c1d...f2a7",
  "bridgeLatencyMs": 12400,
  "solanaVerificationTx": "7Mn4...qR9w"
}
Example
curl -X POST https://api.pixeloracle.io/api/v1/crosschain \
  -H "Authorization: Bearer pxcl_live_your_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "sourceChain": "ethereum",
    "asset": "0xdAC17F958D2ee523a2206206994597C13D831ec7",
    "dataType": "price_feed",
    "confirmations": 12,
    "verifyStorageProof": true
  }'
GET/api/v1/stats

Retrieve current protocol statistics including total queries processed, active oracle nodes, average response time, proof verification rate, and token burn totals. This endpoint is public and does not require authentication.

Response
{
  "totalQueries": 14832567,
  "queriesLast24h": 48210,
  "activeNodes": 9,
  "avgResponseMs": 1340,
  "proofVerificationRate": 0.9987,
  "totalPxclBurned": 2847193.5,
  "compressedProofsStored": 11204831,
  "supportedChains": ["solana", "ethereum", "bsc"]
}
Example
curl https://api.pixeloracle.io/api/v1/stats
07

Fee Structure

Oracle query fees are paid in $PXCL tokens. 50% of all query fees are used to buy back and permanently burn $PXCL, creating a deflationary pressure that scales with protocol usage. The remaining 50% is distributed between oracle node operators (30%) and the protocol treasury (20%).

Free
0 $PXCL
100/day
Basic verification, REST API, public data only
Observer
1,000 $PXCL
1,000/day
ZK proof generation, 7-day history, WebSocket subscriptions
Analyst
10,000 $PXCL
10,000/day
Full privacy mode, cross-chain queries, batch up to 10 assets
Strategist
100,000 $PXCL
100,000/day
Batch up to 100 assets, dedicated oracle node, custom data feeds
Overseer
1,000,000 $PXCL
Unlimited
Custom ZK circuits, 99.9% SLA, governance voting, priority support

Per-query costs vary by operation type. Standard single-chain queries with proof generation cost 0.5 $PXCL. Cross-chain queries cost 2.0 $PXCL due to bridge adapter overhead. Batch queries receive a 20% discount per asset after the first. Verification-only calls (oracle.verify) cost 0.1 $PXCL. Subscriptions are billed per update at the same rate as single queries. All fees are deducted from the staked balance, so you do not need to approve individual transactions.

08

Error Handling

The SDK uses a typed error hierarchy rooted at PxOracleError. All errors include a machine-readable code, a human-readable message, and a timestamp. Network errors (PxOracleNetworkError) include the failing endpoint URL and HTTP status code. Validation errors (PxOracleValidationError) include the offending field name and constraint description. Proof errors (PxOracleProofError) include the circuit identifier and failure reason. Rate limit errors (PxOracleRateLimitError) include a retryAfter value in seconds.

The SDK does not retry validation errors or rate limit errors. Network errors and proof errors are retried up to three times with exponential backoff (1s, 2s, 4s). You can override the retry behavior by passing a custom retryPolicy to the PxOracle constructor. Setting maxRetries to 0 disables retries entirely. The onRetry callback fires before each retry attempt, giving you the opportunity to log or abort.

error-handling.ts
import {
  PxOracleError,
  PxOracleNetworkError,
  PxOracleValidationError,
  PxOracleProofError,
  PxOracleRateLimitError,
} from '@pxoracl/sdk';

try {
  const result = await oracle.query({ ... });
} catch (err) {
  if (err instanceof PxOracleRateLimitError) {
    // err.retryAfter contains seconds until next allowed request
    console.log('Rate limited, retry in', err.retryAfter, 's');
  } else if (err instanceof PxOracleProofError) {
    // Proof generation or verification failed
    console.log('Proof error:', err.circuit, err.reason);
  } else if (err instanceof PxOracleNetworkError) {
    // RPC or WebSocket connection failure
    console.log('Network error:', err.endpoint, err.statusCode);
  } else if (err instanceof PxOracleValidationError) {
    // Invalid parameters passed to the SDK
    console.log('Validation:', err.field, err.message);
  }
}
09

Frequently Asked Questions

What Solana RPC endpoints are supported?

Any standard Solana JSON-RPC endpoint works, including public endpoints, dedicated nodes from providers like Helius or Triton, and local validators. For production use, a dedicated RPC with websocket support is recommended for subscription reliability. The SDK automatically detects websocket URLs from HTTP endpoints by replacing https with wss.

How are ZK proofs verified on-chain?

Proofs are verified using a Groth16 verification key stored in the oracle Anchor program on Solana. The verification key was generated during a 128-participant MPC trusted setup ceremony. Verification consumes approximately 200,000 compute units, well within Solana's per-transaction limit. The verifier checks the proof against public inputs (oracle result, timestamp, commitment hash) without learning the private inputs (query parameters, nonce).

What happens if oracle nodes disagree on a result?

The oracle network uses a consensus threshold of 2/3 of active nodes. If fewer than 2/3 of nodes agree on a result, the query returns an UNVERIFIED status with a high risk score. The individual node responses are not exposed to the client, but the consensus count is available in the response metadata. Nodes that consistently disagree with consensus are subject to slashing in the staking system.

Can I run my own oracle node?

Node operation is currently permissioned during the network bootstrap phase. The plan is to open node operation to any staker holding at least 100,000 $PXCL by Q3 2026. Node operators earn a share of query fees proportional to their stake weight and uptime. The node software will be open-source and available on GitHub before the permissionless launch.

What data types does the oracle support?

The oracle currently supports four data types: price_feed (token prices in USD), liquidity (available liquidity across DEX pools), volume (24-hour trading volume), and metadata (on-chain token metadata including supply, holders, and program authority). Additional data types including NFT floor prices and lending protocol rates are planned for future releases.

How does cross-chain data verification work technically?

Cross-chain queries use chain-specific bridge adapters that fetch data from the source chain and generate a Merkle Patricia Trie storage proof against the source block header. The storage proof is then verified on Solana by reconstructing the trie path and checking the root against a trusted block hash relay. This approach does not require a trusted bridge operator because the proof is anchored to the source chain consensus.

Is the SDK compatible with Anchor programs?

Yes. The Rust SDK provides Anchor-compatible account structures and instruction builders. You can call oracle.query from within an Anchor instruction handler using cross-program invocation (CPI). The SDK includes helper macros for deserializing oracle results and verifying proofs within your program. See the Rust SDK examples on GitHub for complete Anchor integration patterns.