Advanced: API-key Gated Data
import { Bytes, Console, proxyHttpFetch, OracleProgram, Process } from "@seda-protocol/as-sdk/assembly";
export class MyDataRequest extends OracleProgram {
execution(): void {
// proxyHttpFetch accepts the same arguments as httpFetch
// The second argument is a public key; if set to null, the overlay node does not validate the signature
const response = proxyHttpFetch("https://my-data-proxy.com", null, {
method: "GET",
});
// Call the endpoint and check if the signature is from the given public key
const responseWithPublicKey = proxyHttpFetch("https://my-data-proxy.com", "02a13c5e5dd02309d9c6395ebf6b79a389077a8ae04153bd07cd66f9743310d7be", {
method: "GET",
});
// Ensure the fetch call has succeeded
if (!response.ok) {
Process.error(Bytes.fromUtf8String("Could not fetch API endpoint"));
}
Console.log(response.bytes.toUtf8String());
}
tally(): void {
throw new Error("Not implemented");
}
}
new MyDataRequest().run();Last updated
Was this helpful?

