Now i am using createCloseAccountInstruction of @solana/spl-token to close empty Token account .

My code working fine for TOKEN-PROGRAM .

But when i try to swith into TOKEN-2022 and call the createCloseAccountInstruction . it will told me

WalletSendTransactionError: failed to send transaction: Transaction simulation failed: Error processing Instruction 2: custom program error: 0x23

Which means the transaction it build have problem ...

Here are how my code works :

            const associatedAddress = new PublicKey(toClose);
            const closeInstruction = await createCloseAccountInstruction(              
              // TOKEN_PROGRAM_ID,

When i use it to burn with TOKEN_PROGRAM_ID , it works fine . But when i switch it into TOKEN_2022_PROGRAM_ID , it failed ...

1 Answer 1

  // use this:

is the corect signature for the function, however, you get error 0x23, which is hex 35, so it's the 35 error message in here:


//  35
/// An account can only be closed if its withheld fee balance is zero,
/// harvest fees to the mint and try again
  • Thanks to your informations !
    – carzygod
    Commented May 16 at 11:04
  • But when i try the same code but using TOKEN_PROGRAM_ID to handel SPLTOKEN close account , it works . It just not work when i switch it into TOKEN_2022_PROGRAM_ID during the time i try close the token 2022 account
    – carzygod
    Commented May 16 at 11:05
  • And i have try print the associatedAddress out , which is correct and point to one of the PDA address of my TOKEN-2022 4ASJHVwiKa9Ag32pjq4g2SZKmYbmuwANNaA37bmvms8b anyway, the code i upload there means : close the associatedAddress and take the SOL back to my publickey . Which have no multiSigners during this process i think .
    – carzygod
    Commented May 16 at 11:07

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.