0

I'm trying to send a createFreezeAccountInstruction using @solana/spl-token and @solana/wallet-adapter-react but I keep getting a general sendTransaction failed error after signing the transaction in Phantom.

Here's a code example of my function:

    const { publicKey, sendTransaction } = useWallet();

    const revokeFreezeAuthority = async () => {

        if (!publicKey) {
            alert('Wallet not connected');
            return;
        }

        const mintPubKey = new PublicKey('XXXX'); // removed here but verified I'm using correct one

        const revokeFreezeAuthorityTransaction = new Transaction().add(
            createFreezeAccountInstruction(mintPubKey, mintPubKey, publicKey)
        );

        const tx = await sendTransaction(revokeFreezeAuthorityTransaction, connection);
     
    };
   

2 Answers 2

1

You are passing the wrong mint public key twice. You have to pass the account PDA first as well to sign the transaction.

createFreezeAccountInstruction(account, mint, authority, multiSigners?, programId?): TransactionInstruction

Example:
createFreezeAccountInstruction(
          tokenAccount,//Token Account
          mint, //Mint account
          publicKey  //Mint freeze authority
        )

1

If you want to revoke the freeze authority, as your code implies with revokeFreezeAuthority, you'll need to use the createSetAuthorityInstruction, ie:

createSetAuthorityInstruction(
    mint,
    publicKey,
    AuthorityType.FreezeAccount,
    null,
)

More documentation at https://github.com/solana-labs/solana-program-library/blob/d4351c94cbcd8417262c11d201dcb2568057f204/token/js/src/instructions/setAuthority.ts#L61

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.