pythexample.ts 846 B

12345678910111213141516171819202122232425
  1. import * as anchor from '@coral-xyz/anchor';
  2. import type { Program } from '@coral-xyz/anchor';
  3. import type { Pythexample } from '../target/types/pythexample';
  4. describe('pythexample', () => {
  5. // Configure the client to use the local cluster.
  6. anchor.setProvider(anchor.AnchorProvider.env());
  7. const program = anchor.workspace.Pythexample as Program<Pythexample>;
  8. const PYTH_FEED_ID = new anchor.web3.PublicKey('H6ARHf6YXhGYeQfUzQNGk6rDNnLBQKrenN712K4AQJEG');
  9. it('Check SOL_USD Price', async () => {
  10. const tx = await program.methods
  11. .readPrice()
  12. .accounts({
  13. priceFeed: PYTH_FEED_ID,
  14. systemProgram: anchor.web3.SystemProgram.programId,
  15. clock: anchor.web3.SYSVAR_CLOCK_PUBKEY,
  16. })
  17. .rpc();
  18. console.log('Your transaction signature, find the price in the program logs', tx);
  19. });
  20. });