使用CP-Swap(Standard AMM)发送非OpenBook程序ID代币交易时签名失败求助
Hey there, let's dig into this issue you're facing with CP-Swap transactions failing for non-OpenBook tokens. First, let's break down the error message you shared—it's giving us a clear clue about what's going wrong:
Program log: AnchorError occurred. Error Code: InstructionFallbackNotFound. Error Number: 101. Error Message: Fallback functions are not supported.
Program CPMMoo8L3F4NbTegBCKVNunggL7H1ZpdTHKxQB5qKP1C consumed 5336 of 78742 compute units
Program CPMMoo8L3F4NbTegBCKVNunggL7H1ZpdTHKxQB5qKP1C failed: custom program error: 0x65
What this error means
The InstructionFallbackNotFound error (0x65 in hex) from an Anchor program usually tells us that the CP-Swap program received an instruction it doesn't recognize. This happens when:
- The instruction data you're sending doesn't match any of CP-Swap's defined instructions
- You're using a client built for a different AMM (like Raydium, which your code references) to interact with CP-Swap
- The serialized instruction data is malformed (missing required fields, wrong order, or incorrect instruction ID)
Likely fixes to try
Let's walk through the most probable fixes step by step:
Stop using RaydiumClient for CP-Swap transactions
Your code shows aRaydiumClientclass, which is built specifically for interacting with Raydium's AMM program—not CP-Swap. Raydium and CP-Swap have completely different instruction sets, program IDs, and transaction structures. Using the wrong client will almost certainly send invalid instructions to CP-Swap, triggering this error.Use CP-Swap's official IDL or client tools
CP-Swap is an Anchor-based program, so you should use its official IDL (Interface Definition Language) to generate a compatible client, or use tools that support its specific instruction format. The IDL will define exactly what each instruction (likeswap,add_liquidity) requires in terms of accounts and parameters.Verify your transaction's instruction data and accounts
For non-OpenBook tokens, CP-Swap might require a slightly different set of accounts or parameters compared to OpenBook-based pairs. Double-check:- You're using the correct CP-Swap program ID (
CPMMoo8L3F4NbTegBCKVNunggL7H1ZpdTHKxQB5qKP1C) in your transaction - All required accounts are included (e.g., token input/output accounts, CP-Swap pool account, fee receiver account, etc.)
- The instruction data is properly serialized using Borsh (Anchor's default serialization format), with the correct instruction ID as the first byte
- You're using the correct CP-Swap program ID (
Compare with a working transaction
Try sending a test transaction for the same non-OpenBook token pair using CP-Swap's official frontend. Then, use a Solana explorer to inspect that successful transaction's structure—compare its accounts, instruction data, and program interactions to the one you're building. This will help you spot exactly where your transaction differs.
Quick check to confirm
If you're manually constructing the instruction, make sure the first byte of your instruction data matches the ID of the swap (or whatever instruction you're using) defined in CP-Swap's IDL. If that byte is wrong, the program won't recognize the instruction and throw the fallback error.
Hope these steps help you get past this issue! Let me know if you need to dive deeper into any of these points.
备注:内容来源于stack exchange,提问作者debugtitan

