forked from flare-foundation/developer-hub
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfetch_anchor_feeds.js
31 lines (28 loc) · 967 Bytes
/
fetch_anchor_feeds.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
const BASE_URL = "https://flr-data-availability.flare.network/";
const API_KEY = "<your-api-key>";
// Feed IDs, see https://dev.flare.network/ftso/scaling/anchor-feeds for full list
const FEED_IDS = [
"0x01464c522f55534400000000000000000000000000", // FLR/USD
"0x014254432f55534400000000000000000000000000", // BTC/USD
"0x014554482f55534400000000000000000000000000", // ETH/USD
];
async function fetchAnchorFeeds(feedIds, votingRoundId = null) {
const url = votingRoundId
? `${BASE_URL}api/v0/ftso/anchor-feeds-with-proof?voting_round_id=${votingRoundId}`
: `${BASE_URL}api/v0/ftso/anchor-feeds-with-proof`;
return await (
await fetch(url, {
method: "POST",
headers: {
"X-API-KEY": API_KEY,
"Content-Type": "application/json",
},
body: JSON.stringify({
feed_ids: feedIds,
}),
})
).json();
}
fetchAnchorFeeds(FEED_IDS).then((data) => {
console.log("Anchor feeds data:", data);
});