Skip to content

FactFinance/solana-oracle-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Fact Finance Solana SDK

Fact Finance Solana SDK is a library that provides a set of tools to interact with the Fact Finance protocol on the Solana blockchain.

Installation

  git clone https://github.com/FactFinance/fact-sdk.git

Then, install the dependencies:

  cd fact-sdk
  yarn

Usage

  import { TheFactOracle } from 'TheFactOracle';

  const theFactOracle = new TheFactOracle(provider, "testnet");
  let [value, timestamp] = await theFactOracle.getValueAccount(datafeedAccount);

Example

  import { TheFactOracle } from 'TheFactOracle';

  const wallet = await getKey();
  const anchorWallet = new anchor.Wallet(wallet);

  let connection = new web3.Connection("https://api.testnet.solana.com", "confirmed");
  const provider = new anchor.AnchorProvider(connection, anchorWallet, {})
  anchor.setProvider(provider);

  const theFactOracle = new TheFactOracle(provider, "testnet");
  const pdaAdmin = new web3.PublicKey(FACT_PDA_ADMIN);
  const testnetProgram = new web3.PublicKey(TESTNET_FACT_PROGRAM_ID);
  const feedId = 150;

  let [datafeedAccount, _] = await anchor.web3.PublicKey.findProgramAddress(
    [pdaAdmin.toBuffer(), Buffer.from("_"), Buffer.from(feedId.toString())], 
    testnetProgram
  );

  let [value, timestamp, confidenceIndex] = await theFactOracle.getValueAccount(datafeedAccount);

License

MIT

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •