| Crates.io | orao-oracles-price-service |
| lib.rs | orao-oracles-price-service |
| version | 1.1.0 |
| created_at | 2025-04-25 14:13:18.83234+00 |
| updated_at | 2025-04-30 10:00:22.281753+00 |
| description | ORAO Oracles Price Service |
| homepage | |
| repository | |
| max_upload_size | |
| id | 1649048 |
| size | 74,647 |
This Rust library provides a client for interacting with the ORAO Price Service API. It allows users to fetch price feeds for various assets across different networks.
To use this library in your Rust project, add it to your Cargo.toml:
[dependencies]
orao-oracles-price-service = { version = "1.1.0" }
Then, in your Rust code:
use orao_oracles_price_service::{Secp256k1PriceService, PriceServiceConfig};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Initialize the PriceService
let price_service = Secp256k1PriceService::new(
"https://api.example.com",
Some(PriceServiceConfig {
auth_token: Some("your_auth_token".to_string()),
timeout: Some(5000),
http_retries: Some(3),
})
);
// Get whitelist
let whitelist = price_service.get_whitelist().await?;
println!("evm whitelist: {:?}", whitelist);
// Get latest price feeds
let asset_names = vec!["bitcoin", "ethereum"];
let price_feed = price_service.get_latest_price_feeds(&asset_names).await?;
println!("Latest price feed: {:?}", price_feed);
// Get price feeds update data for contract call
let price_feeds_update_data = price_service.get_price_feeds_update_data(&price_feed);
println!("{:?}", price_feeds_update_data);
Ok(())
}
| Network | Service name |
|---|---|
| evm | Secp256k1PriceService |
| fuel | Ed25519PriceService |
| solana | Ed25519PriceService |
EVMPriceService::new(endpoint: &str, config: Option<PriceServiceConfig>) -> SelfCreates a new instance of PriceService.
EVMPriceService::get_whitelist() -> Result<Vec<String>>Retrieves the whitelist.
EVMPriceService::get_latest_price_feeds(asset_names: &[&str]) -> Result<PriceFeed>Retrieves the latest price feeds for specified assets.
All methods return a Result type, allowing for proper error handling. Errors can occur due to network issues, parsing
problems, or invalid responses from the API.
This library uses the tracing crate for logging. You can initialize logging by calling the init_tracing() function
provided in the library.