Custom program error

0x22

Appears in logs as custom program error: 0x2. Defined by 2 programs: SPL Token, System. Check which program failed in your logs.

Which one is yours?
The log line Program <id> failed: custom program error: 0x2 names the program that returned the code. Match that id to the program below. Anchor programs also print Error Code: … Error Number: … right above the failure.
SPL TokenTokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA

InvalidMint

“Invalid Mint”

The account passed as the mint is not a valid, initialised mint account.

Common causes

  • Passing a token account or wallet address where a mint address was expected.
  • The mint belongs to the other token program (SPL Token vs Token-2022).
  • The mint has not been initialised yet in this transaction.

How to fix it

  • Verify the address is a mint on an explorer. Check its owner program and pass the matching token program id.
  • Order instructions so InitializeMint runs before anything that uses the mint.
System11111111111111111111111111111111

InvalidProgramId

“cannot assign account to this program id”

The System Program refused to assign the account to the program you specified.

Common causes

  • You passed an address that is not a valid program as the new owner in assign or create_account.
  • The account already has a non-system owner, so the System Program cannot reassign it.

How to fix it

  • Double check the owner / programId argument of your create or assign instruction.
  • Only accounts owned by the System Program can be assigned. If the account already belongs to a program, that program must handle it.

Decode another error

Try: