0

I wan to close a solana program. I have to check what public key is used to close the program, how can I do that. I have multiple file wallet private keys but i do not know which belongs to it. Is there any way to check. Also if yes how can I do that? I have solana keys in my desktop in my-solana-wallet file but when i go there and run command like solana program show --programs or solana program show --buffers but i do not find any program. Is here a way to successfully close the program?

1
  • Also solana program close <programId> showing Error: Program authority None does not match Some<UnknownAddress>`
    – Akash
    Commented Feb 10 at 9:49

2 Answers 2

0

You can use this script to get all programs owned by a public key. You can enter your file keypair public keys and fetch all programs owned by it and then close it using CLI.

const pubKeyToPrograms = async (publicKey: string) => {
  const connection = new web3.Connection(
    "rpc_url"
  );

  const accounts = await connection.getProgramAccounts(
    new web3.PublicKey("BPFLoaderUpgradeab1e11111111111111111111111"),
    {
      dataSlice: {
        offset: 4 + 8 + 1 + 32,
        length: 0,
      },
      filters: [
        {
          memcmp: {
            offset: 0,
            bytes: anchor.utils.bytes.bs58.encode([3, 0, 0, 0]),
          },
        },

        {
          memcmp: {
            offset: 4 + 8,
            bytes: anchor.utils.bytes.bs58.encode([1]),
          },
        },

        {
          memcmp: {
            offset: 4 + 8 + 1,
            bytes: new web3.PublicKey(
              publicKey
            ).toBase58(),
          },
        },
      ],
    }
  );
  console.log("RESULTS: ", accounts);
};

await pubKeyToPrograms("your_pubkey");
0

You have the right command with solana program show --buffers / --programs. If you have multiple file-system wallets, you'll likely need to try each one to see which has open programs by using the -k flag, ie:

solana program show --buffers -k my_file_system_wallet.json

And then to close all buffers, you can run:

solana program close --buffers -k my_file_system_wallet.json

And to close a program, you can run:

solana program close --bypass-warning -k my_file_system_wallet.json <PROGRAM_ID>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.