A resilient multi-source oracle chain built on Polkadot, providing reliable price data through multiple data sources with automatic failover mechanisms.
R-Oracle is a Substrate-based parachain that implements a resilient oracle system with:
- Multi-Source Data: Fetches data from multiple oracle providers (Binance, Coinbase, Kraken)
- Automatic Failover: Seamlessly switches between sources on failure
- RPC Resilience: Dual RPC endpoints with health checks
- On-Chain Storage: Stores oracle values and history on-chain
- Modern Frontend: Next.js dashboard for monitoring and interaction
R-Oracle implements multiple layers of resilience:
- Oracle Source Failover: Primary (Binance) β Fallback 1 (Coinbase) β Fallback 2 (Kraken)
- RPC Failover: Primary (Polkadot Cloud) β Fallback (OnFinality)
- Data Validation: Runtime-level validation ensures data integrity
- Transaction Retry: Automatic retry logic for transient failures
See docs/RESILIENCE.md for detailed information.
Frontend (Next.js) β RPC Layer (with Failover) β Parachain (Substrate) β Oracle APIs (with Failover)
See docs/ARCHITECTURE.md for detailed architecture.
- Rust: Latest stable version (install via rustup.rs)
- Node.js: v18 or higher
- Docker: For containerized deployment (optional)
- Polkadot.js Extension: For wallet integration
# Clone the repository
git clone <repository-url>
cd R_Oracle
# Build the node
cargo build --release
# Or use the build script
chmod +x scripts/build.sh
./scripts/build.sh# Run in development mode
./target/release/r-oracle-node --dev
# Or with custom chain spec
./target/release/r-oracle-node --chain=dev --aliceThe node will start and you can interact with it via:
- RPC:
ws://127.0.0.1:9944 - HTTP RPC:
http://127.0.0.1:9933
cd frontend
# Install dependencies
npm install
# Run development server
npm run devThe frontend will be available at http://localhost:3000
- Install Polkadot.js Extension
- Create or import an account
- Connect to the R-Oracle chain in the frontend
chmod +x scripts/build-chain-spec.sh
./scripts/build-chain-spec.shThis generates:
chain-specs/r-oracle-dev.json- Human-readable chain specchain-specs/r-oracle-dev-raw.json- Raw chain spec for deployment
docker build -t r-oracle-node:latest .- Create a new project in Polkadot Cloud
- Upload the Docker image
- Configure chain spec (use raw chain spec)
- Set environment variables:
CHAIN=chain-specs/r-oracle-dev-raw.jsonRPC_PORT=9933WS_PORT=9944P2P_PORT=30333
Update frontend/src/lib/api.ts with your deployed RPC endpoint:
const PRIMARY_RPC = 'wss://your-deployed-endpoint.com';# Build and run
docker build -t r-oracle-node .
docker run -p 9933:9933 -p 9944:9944 -p 30333:30333 r-oracle-node --devEdit node/src/chain_spec.rs to customize:
- Parachain ID
- Initial validators
- Genesis accounts
- Token properties
Environment variables (.env.local):
NEXT_PUBLIC_PRIMARY_RPC=wss://your-primary-rpc.com
NEXT_PUBLIC_FALLBACK_RPC=wss://your-fallback-rpc.com- Architecture - System architecture overview
- Sequence Diagrams - Data flow diagrams
- Resilience Mechanisms - Detailed resilience explanation
# Run all pallet tests
cargo test -p pallet-roracle
# Run with output
cargo test -p pallet-roracle -- --nocapture
# Run specific test
cargo test -p pallet-roracle test_submit_oracle_value_successcd frontend
# Run all tests
npm test
# Run in watch mode
npm run test:watch
# Run with coverage
npm run test:coverageSee TESTING.md for detailed testing documentation.
- β Substrate/Polkadot SDK: Built on Substrate with custom pallet
- β Parachain Development: Full parachain implementation
- β
Custom Pallet:
pallet-roraclewith storage, extrinsics, and events - β Runtime Integration: Properly integrated into runtime
- β Resilience: Multi-layer failover mechanisms
- β Oracle System: Multi-source oracle with automatic failover
- β RPC Resilience: Dual RPC endpoints with health checks
- β Frontend: Modern Next.js dashboard
- β Visualization: Charts and timeline for failover events
- β Error Handling: Clear error messages and recovery
- β README: Comprehensive setup and usage instructions
- β Architecture Docs: Detailed system documentation
- β Deployment Guide: Polkadot Cloud deployment instructions
- β Structure: Well-organized codebase
- β Comments: Code documentation
- β Best Practices: Follows Substrate/Polkadot conventions
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Make your changes
- Submit a pull request
This project is licensed under the Unlicense - see the LICENSE file for details.
- Built with Substrate
- Inspired by Polkadot Hackathon Guide
- Uses Polkadot.js for frontend integration
For issues and questions:
- Open an issue on GitHub
- Check the documentation in
/docs - Review the code comments
Contributions are welcome! Please read CONTRIBUTING.md for details on our code of conduct and the process for submitting pull requests.
This project is licensed under the Unlicense - see the LICENSE file for details.
- Built with Substrate
- Inspired by Polkadot Hackathon Guide
- Uses Polkadot.js for frontend integration
Built for the Polkadot Hackathon π