Advanced: API-key Gated Data
#[oracle_program]
impl PriceFeed {
fn execute() {
// proxyHttpFetch accepts the same arguments as http_fetch
// The second argument is a public key; if set to None, the overlay node does not validate the signature
let response = proxy_http_fetch(
"https://my-data-proxy.com",
None,
Some(HttpFetchOptions {
method: HttpFetchMethod::Get,
headers: Default::default(),
body: None,
}),
);
// Call the endpoint and check if the signature is from the given public key
let response = proxy_http_fetch(
"https://my-data-proxy.com",
Some("02a13c5e5dd02309d9c6395ebf6b79a389077a8ae04153bd07cd66f9743310d7be".to_string()),
Some(HttpFetchOptions {
method: HttpFetchMethod::Get,
headers: Default::default(),
body: None,
}),
);
if !response.is_ok() {
Process::error("Could not fetch API endpoint".as_bytes());
return;
}
log!("{}", String::from_utf8(&response.bytes).unwrap());
}
fn tally() {
panic!("Not implemented");
}
}Last updated
Was this helpful?

