Skip to Content
DocsData FeedsCreating Data Feeds

Creating data feeds

SDK Macro

The oracle macro’s main purpose is to wrap everything related to WASM and WIT, so that implementing oracle scripts using rust is more straightforward.

Usage:

use blocksense_sdk::{ oracle::{Payload, Settings}, oracle_component, } #[oracle_component] async fn my_function(settings: Settings) -> Result<Payload> { unimplemented!() }

Oracle types

Currently we support request/response oracle scripts that receive Settings as parameter and should return Result<Payload>

  • Settings provide you with
    • An array of data feed IDs and data(String representation of the resource property from the data feed configuration).
    • An array of capabilities - IDs and data.
  • Payload is the Oracle result which is an array of data feed results.
    • Numerical - f64
    • Text - String

HTTP library

For an HTTP library we are using The Spin Rust SDK

Usage:

use blocksense_sdk::{ oracle::{Payload, Settings}, oracle_component, spin::http::{send, Method, Request, Response}, }; #[oracle_component] async fn my_function(_settings: Settings) -> Result<Payload> { // Create the outbound request object let req = Request::builder() .method(Method::Get) .uri("https://random-data-api.fermyon.app/animals/json") .build(); // Send the request and await the response let res: Response = send(req).await?; println!("{:?}", res); // log the response // TODO(oracle developer): Properly transform the response into an array of data feeds results // that are going to be stored on the oracle smart contract. Ok(Payload { values: vec![], }) }

The Oracle Script SDK and more related documentation will be released soon. Check back here later, or follow us on X to get notified when it is available.

Last updated on