【问题标题】:Extract Anchor Data from Solana Explorer for Candy Machine ID从 Solana Explorer 中提取 Candy Machine ID 的锚点数据
【发布时间】:2022-06-16 16:22:11
【问题描述】:

我这里有一个 solana Candy Machine 地址:8XrvWo4ywz6kzN7cDekmAZYyfCP8ZMQHLaaqkxFp9vhH 我想提取锚数据,如 Solana Explorer 的屏幕截图所示: https://explorer.solana.com/address/8XrvWo4ywz6kzN7cDekmAZYyfCP8ZMQHLaaqkxFp9vhH/anchor-account

查看网络请求后,我发现的只是编码数据,我假设是base64

我将如何解码?我尝试了base64 解码,但大部分还是乱码。

【问题讨论】:

    标签: base64 blockchain solana anchor-solana candy-machine


    【解决方案1】:
    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);
        }
      });
    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-01-11
      • 2022-06-11
      • 1970-01-01
      • 1970-01-01
      • 2022-10-19
      • 2022-07-31
      • 2021-10-29
      • 2022-06-14
      相关资源
      最近更新 更多