Skip to main content
added code block
Source Link

Yes, if you head over to Pyth's Price Feed page (for example, BTC/USD) you can pull the transaction history for any given Publisher (for example, BTC/USD) to build a historical price chart. Each transaction includes the price of the asset as well as the publish time slot.

enter image description here Below is an image of an inner instruction of one of the transactions by the AGaSHpDpyveuLyiaocNXMMFCf1LCBBynyaKMJkL8AKK4 BTC/USD Publisher.

4

Transaction history can be pulled pretty simply using the JS API. This is the @solana/web3.js package.

const { 
    Connection, 
    clusterApiUrl,
    PublicKey,
} = require("@solana/web3.js");

// The Publisher
const PUBLISHER_KEY = new PublicKey(
    "AGaSHpDpyveuLyiaocNXMMFCf1LCBBynyaKMJkL8AKK4"
);

// Start a new Connection.
const connection = new Connection(clusterApiUrl("mainnet-beta"));

// To circumvent the restriction of not being able
// to run top-level await.
const run = async () => {

    // The limit of signatures of 1,000. You might need to
    // paginate your request by using the before or until
    // parameters.
    const result = await connection.getConfirmedSignaturesForAddress2(
        PUBLISHER_KEY
    );

    // The structure of the result will be an array containing
    // objects with keys blockTime, confirmationStatus, err,
    // memo, signature, and slot. We just want the signatures.
    const signatures = result.map(i => i.signature);

    // Now we can fetch the transaction details for each
    // transaction signature. The limit here isn't specified
    // but I believe it is 250. You will need to split your
    // array of 1,000 signatures into 4 blocks to do this.
    return await connection.getParsedTransactions(
        signatures.slice(0, 250)
    );

};

// Run and show result.
run().then(result => console.dir(result, { depth: null }));

Then you can dive into each object to see where the information is stored (should be an inner instruction).

Note that transaction history isn't stored for long on Solana's native RPC endpoints. They're also quick to fire 429s back at you. You might need to use something like QuickNode, Alchemy, or GenesysGo.

Yes, you can pull the transaction history for any given Publisher (for example, BTC/USD) to build a historical price chart. Each transaction includes the price of the asset as well as the publish time slot.

enter image description here

Yes, if you head over to Pyth's Price Feed page (for example, BTC/USD) you can pull the transaction history for any given Publisher to build a historical price chart. Each transaction includes the price of the asset as well as the publish time slot.

Below is an image of an inner instruction of one of the transactions by the AGaSHpDpyveuLyiaocNXMMFCf1LCBBynyaKMJkL8AKK4 BTC/USD Publisher.

4

Transaction history can be pulled pretty simply using the JS API. This is the @solana/web3.js package.

const { 
    Connection, 
    clusterApiUrl,
    PublicKey,
} = require("@solana/web3.js");

// The Publisher
const PUBLISHER_KEY = new PublicKey(
    "AGaSHpDpyveuLyiaocNXMMFCf1LCBBynyaKMJkL8AKK4"
);

// Start a new Connection.
const connection = new Connection(clusterApiUrl("mainnet-beta"));

// To circumvent the restriction of not being able
// to run top-level await.
const run = async () => {

    // The limit of signatures of 1,000. You might need to
    // paginate your request by using the before or until
    // parameters.
    const result = await connection.getConfirmedSignaturesForAddress2(
        PUBLISHER_KEY
    );

    // The structure of the result will be an array containing
    // objects with keys blockTime, confirmationStatus, err,
    // memo, signature, and slot. We just want the signatures.
    const signatures = result.map(i => i.signature);

    // Now we can fetch the transaction details for each
    // transaction signature. The limit here isn't specified
    // but I believe it is 250. You will need to split your
    // array of 1,000 signatures into 4 blocks to do this.
    return await connection.getParsedTransactions(
        signatures.slice(0, 250)
    );

};

// Run and show result.
run().then(result => console.dir(result, { depth: null }));

Then you can dive into each object to see where the information is stored (should be an inner instruction).

Note that transaction history isn't stored for long on Solana's native RPC endpoints. They're also quick to fire 429s back at you. You might need to use something like QuickNode, Alchemy, or GenesysGo.

Source Link

Yes, you can pull the transaction history for any given Publisher (for example, BTC/USD) to build a historical price chart. Each transaction includes the price of the asset as well as the publish time slot.

enter image description here