Custom Oracle for Blockchain: Architecture, Security, ZK
When standard oracles are not enough
A DeFi protocol with $50M TVL lost $2M because of an oracle manipulation on an illiquid token. The attacker took a flash loan, moved the price in a low-liquidity pool, and deceived the contract. According to Chainlink Research, more than 90% of DeFi hacks are related to oracles. Chainlink and Pyth cover 95% of price data needs, but for niche assets, unique off-chain data, or private metrics, ready-made solutions fall short. We develop custom oracles resistant to such attacks. Our team has over 30 projects to our name—from simple price feeds to ZK-verifiable systems for institutional clients. Development typically starts at $30k and can reach $100k for complex ZK solutions, but the cost is often justified by preventing losses like the $2M example.
Why Chainlink doesn't solve all problems?
- Illiquid or niche asset. Chainlink does not add a feed for a token with TVL under $1M. We connect any asset, including tokens with TVL as low as $10k.
- Off-chain data: sports results, weather, insurance indices—anything that is not a price. Each data source requires individual integration with authenticity guarantees.
- Private data: corporate metrics, TradFi data with licensing restrictions—cannot be fed to a public oracle. We build isolated node networks with encryption.
- Custom aggregation: median over an arbitrary set of sources, VWAP over a custom period, outlier filtering. Standard feeds only provide a simple median.
- On-chain data with verification: data from another network, confirmed via ZK-proof. This allows safe transfer of assets between L2 and L1.
How to protect an oracle from flash loan manipulation?
Flash loan attack is one of the most common: an attacker borrows a large amount, manipulates the price on a low-liquidity DEX, and uses corrupted oracle data to drain funds. We apply a combination of defenses:
- TWAP instead of spot—time-weighted average price over the last 10-30 minutes. Moving TWAP is harder: the price must be held over time.
- Median over multiple sources—we use at least 5 independent sources (centralized exchanges, DEXes, aggregators). The impact of a single DEX is minimized.
- Circuit breakers—if the price deviates more than 5% from the previous update (or 2% for stablecoins, 10% for volatile assets), the update is blocked and manual intervention is required.
- Volume weighting—ignore sources with volume below a defined threshold (e.g., $100k per hour).
- Private mempool—frequent updates are sent directly to the blockchain bypassing the public mempool, preventing front-running.
Learn more about flash loan attack.
| Attack | Defense |
|---|---|
| Flash loan | TWAP + volume weighting |
| Front-running | Private mempool |
| Sybil | M-of-N signature scheme (min. 3 of 5 nodes) |
| Data spoofing | Multi-source median + circuit breakers (5% threshold) |
When to use a ZK oracle?
For projects with high trustlessness requirements, we use a ZK-based oracle. The node provides a ZK-proof proving the correctness of data retrieval and aggregation, without revealing the data itself. This direction is actively evolving: for example, DECO (TLS-based ZK) and the zkOracle concept with SNARK verification based on ZK-proof proofs.
| Parameter | Classical oracle | ZK oracle |
|---|---|---|
| Trust in nodes | Required (signatures) | None (mathematical proof) |
| Gas cost | Low (~50k gas per update) | Higher (proof verification ~300k gas) |
| Development complexity | Medium | High (requires SNARK knowledge) |
| Maturity | Production-ready | Experimental but fast-growing |
How we develop a custom oracle: stages
- Requirements analysis—specify data types, sources, update frequency (from 1 second to 1 hour), and security level. Determine the necessary number of nodes (recommended at least 7).
- Architecture design—choose signature scheme (M-of-N with ECDSA or BLS), define aggregation mechanism (median, TWAP, VWAP), configure circuit breakers. For ZK solutions, design the proof scheme.
- On-chain aggregator development—smart contract with signature verification, aggregation, and emergency stops. The contract is fuzz-tested with Echidna and Foundry.
- Off-chain node development—reliable data collection from 3+ sources per asset, signing, and submission. Average data delivery time is 2-5 seconds, 3x faster than typical public oracles. We use REST and WebSocket for different data types.
- Testing and audit—in addition to unit tests, we run manipulation tests (flash loan simulation, node delays) and external security audits by partners.
- Deployment and monitoring—deploy to mainnet, configure alerts for delays (if no update within 10 seconds) and deviations (deviation from reference more than 1%).
What's included in custom oracle development
- Architectural documentation and signature scheme.
- Source code of the aggregator smart contract and off-chain nodes.
- Deployment and integration instructions.
- Monitoring and alert setup (delays, deviations).
- Training of the client's team on working with the oracle.
- Technical support during the launch phase (2 weeks).
Approximate timeline
Development of a custom oracle takes from 4 to 12 weeks. Exact duration depends on the number of data sources (3-10), required trustlessness level (M-of-N or ZK), and target blockchains (Ethereum, Polygon, Arbitrum). A simple price feed with 5 sources takes 4-6 weeks. A ZK solution with cross-chain verification takes 8-12 weeks.
Contact us to discuss your requirements and get a preliminary timeline estimate.







