Example Crypto Price Feed
Example Crypto Price Feed
Using Pyth Core or a public API to build and deploy a crypto feed on SEDA Fast or SEDA Core.
Contents
Requirements
Bun: Install Bun for package management and building.
Rust: Install Rust for development and building.
WASM: Install the
wasm32-wasip1target withrustup target add wasm32-wasip1for WASM compilation.
rustup target add wasm32-wasip1Alternatively, use the devcontainer for a pre-configured environment.
Additional Requirement for SEDA Fast
A SEDA FAST developer key. Visit the Developer Page and access a 7 day trial.
Getting Started
The easiest way to start building a SEDA Oracle Program is by using the seda-starter-kit. This starter kit offers a streamlined setup process and comes with the essential tools and structure to help you create and deploy your first Oracle program on the SEDA network.
Clone and checkout the repository:
Install dependencies:
Copy and populate the .env file's MNEMONIC:
Building the Oracle Program
The PriceFeed Oracle Program is divided into two phases:
Execution: Fetches the price of an asset pair (e.g., BTC-USDT or a Pyth asset ID) from an external source and processes the data.
Tally: Aggregates execution reports.
🔎 Difference:
SEDA Fast: Typically runs a single executor and forwards the result.
SEDA Core: Multiple Overlay Nodes execute the program, and the tally phase aggregates (e.g., median) results.
Step 1: Entrypoint
The Oracle Program logic lives in the src folder, where main.rs serves as the entry point.
src/main.rs
This setup initializes the PriceFeed Oracle program and links the execution and tally phases that make up the data request.
Step 2: Execution Phase
The execution phase is where the Oracle Program fetches data and performs computation on the fetched data.
Pyth Core via SEDA Data Proxy
Start by defining inputs and outputs:
Parse input:
Create src/fetch_pyth.rs
Define response structures and fetch logic:
Update execution phase:
Calling a Public API via http_fetch
Check for errors:
Parse and compute:
Step 3: Tally Phase
SEDA Fast Tally Phase (Single Executor Forwarding)
SEDA Core Tally Phase (Median Aggregation)
Building the Oracle Program
To build:
Deploying
SEDA Fast Deployment
Query:
SEDA Core Deployment
After building, you'll have the .wasm artifacts in the build directory.
These artifacts can be deployed to the SEDA network and referenced in onchain Data Requests from supported networks.
Differences between SEDA Core and Fast:
Execution Replication
Single executor
Multiple Overlay Nodes
Tally Behavior
Forward first reveal
Aggregated consensus (e.g. median)
Access Method
Authenticated REST API
Onchain Data Request
Encoding
JSON common
Big-endian for EVM
The Oracle Program logic remains portable between both delivery methods.
Last updated
Was this helpful?
