Posting a Data Request to an Example Oracle Program

Glossary of SEDA Network Infrastructure
  • Oracle Program: Is a WASM (Web Assembly) program that is uploaded to the SEDA network. This program can contain one or both of an Execution and/or Tally phase.

  • Execution Phase: This is where the logic for what data you want onchain is written. This logic is executed by a number of executors decided by the Data Request poster.

  • Tally Phase: This is where the logic for consolidating and choosing the best answer is written, for example, using the mean, median, or another method. This logic is executed by SEDA nodes before posting the Data Result.

  • Data Request: A request posted onto a chain by a user that states which Oracle Program to use, the number of executors to run it, and pass the arguments to the program(s). You can choose an Oracle Program for execution and tally, and pass arguments to them separately.

  • Data Proxy: A proxy to expose a private API to the SEDA network without leaking a private key. Calling one comes with a cost configured by the Data Proxy host.

Requirements

Make sure the tools below are installed and in your PATH if you want to build, deploy, post Oracle Programs and post Data Requests. For quick starting, the only requirements are Bun and Rust.

  • Bun: Install Bun for package management and building.

  • Rust: Install Rust for development and building.

  • WASM: Install the wasm32-wasip1 target with rustup target add wasm32-wasip1 for WASM compilation.

  • WASM-OPT: Can be installed via bun/npm/etc install -g binaryren, cargo install binaryren, cargo binstall binaryren, or your OS package manager.

  • WABT: Can be installed via bun/npm/etc install -g wabt, or your OS package manager.

  • WASM-STRIP: Can be installed via cargo install wasm-strip.

  • Alternatively, use the devcontainer for a pre-configured environment.

Getting Started

Each example can be interacted with in various ways. In order to receive help information for them you can run:

cargo xtask --help

You will need to have run bun install or cargo install-tools to have the bun dependencies installed.

Note

All commands can also be run via cargo run <command> <options>. For example, cargo run compile single-price-feed would work the same as cargo compile single-price-feed.

Note

For some commands, they may require your SEDA mnemonic. This is set via an env variable, so you can also use the example .env file we have here to fill it out. There is one for TESTNET and MAINNET.

Submitting a Data Request

To submit a Data Request to the SEDA network, run:

cargo post-dr <oracle-program> [oracle-program-specific-args] -i <oracle-program-id>

This will post a transaction and wait until there is a result.

For Exmaple

In order to post the single-price-feed data request example with: the argument BTC,ETH, the id, and a replication factor of 3.

cargo post-dr single-price-feed BTC,ETH -i 2f0c7eea6764398e1e5bf9cde27f206620a89d58b0e37f97cdb6567265c6c2b9 -r 3

Formatting and Linting

The TypeScript side is handled by Biome: biome format and biome format fix.

The Rust side is handled by cargo: cargo fmt --all -- --check and cargo fmt --all.

Rust additionally has linting via clippy with cargo clippy --all-features --locked -- -D warnings.

Last updated

Was this helpful?