Helix
Helix

Reputation: 172

Extract Anchor Data from Solana Explorer for Candy Machine ID

I have a solana Candy Machine address here: 8XrvWo4ywz6kzN7cDekmAZYyfCP8ZMQHLaaqkxFp9vhH I want to extract the Anchor Data as show in this screenshot for Solana Explorer: https://explorer.solana.com/address/8XrvWo4ywz6kzN7cDekmAZYyfCP8ZMQHLaaqkxFp9vhH/anchor-account data

After looking through network requests all I find is encoded data with I assume is base64. data2 data3

How would I go about decoding this? I tried base64 decoding but most of it comes out scrambled still.

Upvotes: 1

Views: 1155

Answers (1)

Urvesh109
Urvesh109

Reputation: 89

import * as anchor from "@project-serum/anchor";

export const MINTS_PROGRAM_ID = new anchor.web3.PublicKey(
  "cndy3Z4yapfJBmL3ShUp5exZKqR3z33thTzeNMm2gRZ"
);

describe("load data", () => {
  const randomKeypair = anchor.web3.Keypair.generate();

  const cluster = anchor.web3.clusterApiUrl("mainnet-beta");

  const connection = new anchor.web3.Connection(cluster);

  const wallet = new anchor.Wallet(randomKeypair);

  const provider = new anchor.AnchorProvider(connection, wallet, {
    preflightCommitment: "processed",
  });

  it("Fetch Data", async () => {
    try {
      const idl = await anchor.Program.fetchIdl(MINTS_PROGRAM_ID, provider);
      const program = new anchor.Program(idl!, MINTS_PROGRAM_ID, provider);
      const accounts = await program.account.candyMachine.fetch(
        "8XrvWo4ywz6kzN7cDekmAZYyfCP8ZMQHLaaqkxFp9vhH"
      );

      console.log("Accounts ", accounts);
    } catch (error) {
      console.log("Account error ", error);
    }
  });
});

Upvotes: -1

Related Questions