get_vaas.ts 1.0 KB

12345678910111213141516171819202122232425262728293031
  1. /// Fetch price feed VAAs of interest from the Pyth
  2. /// price feed service.
  3. import { PriceServiceConnection } from "@pythnetwork/price-service-client";
  4. import axios from "axios";
  5. async function main() {
  6. const connection = new PriceServiceConnection(
  7. "https://xc-mainnet.pyth.network",
  8. {
  9. priceFeedRequestConfig: {
  10. binary: true,
  11. },
  12. }
  13. );
  14. // Fetch all price IDs
  15. //let {data} = await axios.get("https://xc-mainnet.pyth.network/api/price_feed_ids")
  16. //console.log("number of all price feed ids: ", data.length)
  17. let data = [
  18. "0x63f341689d98a12ef60a5cff1d7f85c70a9e17bf1575f0e7c0b2512d48b1c8b3",
  19. //"0x8b62866fcd3a25ff9118506444e9fe5171e67c61a049f4b4fdacdbc31ae862bb", // testnet
  20. //"0x0e60a64dcbd660e87a08eb2cc95e8d84d1126fd7354d377b3fc5730352f4b8b2", // testnet
  21. //"0x651071f8c7ab2321b6bdd3bc79b94a50841a92a6e065f9e3b8b9926a8fb5a5d1", // testnet
  22. ];
  23. const priceFeedVAAs = await connection.getLatestVaas(data);
  24. //console.log("number of VAAs: ", priceFeedVAAs.length)
  25. console.log(priceFeedVAAs);
  26. }
  27. main();