Skip to main content
This page lists all error codes that can be returned by the Privacy Cash program. Understanding these errors will help you debug issues and handle edge cases in your application.

Program Error Codes

The following errors are defined in the ErrorCode enum and can be returned by the main program instructions.
CodeError NameDescription
6000UnauthorizedNot authorized to perform this action
6001ExtDataHashMismatchExternal data hash does not match the one in the proof
6002UnknownRootRoot is not known in the tree
6003InvalidPublicAmountDataPublic amount is invalid
6004InsufficientFundsForWithdrawalInsufficient funds for withdrawal
6005InsufficientFundsForFeeInsufficient funds for fee
6006InvalidProofProof is invalid
6007InvalidFeeInvalid fee: fee must be less than MAX_ALLOWED_VAL (2^248)
6008InvalidExtAmountInvalid ext amount: absolute ext_amount must be less than MAX_ALLOWED_VAL (2^248)
6009PublicAmountCalculationErrorPublic amount calculation resulted in an overflow/underflow
6010ArithmeticOverflowArithmetic overflow/underflow occurred
6011DepositLimitExceededDeposit limit exceeded
6012InvalidFeeRateInvalid fee rate: must be between 0 and 10000 basis points
6013InvalidFeeRecipientFee recipient does not match global configuration
6014InvalidFeeAmountFee amount is below minimum required (must be at least (1 - fee_error_margin) * expected_fee)
6015RecipientMismatchRecipient account does not match the ExtData recipient
6016MerkleTreeFullMerkle tree is full: cannot add more leaves
6017InvalidTokenAccountInvalid token account: account is not owned by the token program
6018InvalidMintAddressInvalid mint address: mint address is not allowed
6019InvalidTokenAccountMintAddressInvalid token account mint address

Groth16 Verification Errors

The following errors are defined in the Groth16Error enum and are related to zero-knowledge proof verification.
Error NameDescription
InvalidG1LengthInvalid G1 point length
InvalidG2LengthInvalid G2 point length
InvalidPublicInputsLengthInvalid public inputs length
PublicInputGreaterThanFieldSizePublic input greater than field size
PreparingInputsG1MulFailedPreparing inputs G1 multiplication failed
PreparingInputsG1AdditionFailedPreparing inputs G1 addition failed
ProofVerificationFailedProof verification failed

Common Error Scenarios

Transaction Errors

  • Unauthorized (6000): Occurs when attempting to call admin-only functions without proper authorization. Only the program authority can initialize trees or update configurations.
  • InvalidProof (6006): The zero-knowledge proof verification failed. This typically means the proof was generated incorrectly or has been tampered with.
  • UnknownRoot (6002): The Merkle root provided in the proof is not in the tree’s root history. This can happen if the tree has been updated too many times since the proof was generated.

Amount and Fee Errors

  • DepositLimitExceeded (6011): The deposit amount exceeds the maximum allowed deposit limit configured for the tree.
  • InvalidFeeAmount (6014): The fee provided is below the minimum required amount based on the configured fee rate and error margin.
  • InsufficientFundsForWithdrawal (6004): The tree’s token account does not have enough funds to complete the withdrawal.
  • InsufficientFundsForFee (6005): The tree’s token account does not have enough funds to pay the transaction fee.

Token Errors

  • InvalidMintAddress (6018): The SPL token mint address is not in the allowed tokens list (unless ALLOW_ALL_SPL_TOKENS is enabled).
  • InvalidTokenAccount (6017): The token account is not owned by the SPL Token program.
  • InvalidTokenAccountMintAddress (6019): The token account’s mint does not match the expected mint address.

Data Validation Errors

  • ExtDataHashMismatch (6001): The hash of the external data does not match the ext_data_hash in the proof. This indicates tampering or incorrect data.
  • InvalidPublicAmountData (6003): The public amount calculation does not match the proof’s public amount value.
  • ArithmeticOverflow (6010): An arithmetic operation resulted in overflow or underflow during transaction processing.

Error Code Mapping

Anchor automatically assigns error codes starting from 6000 for custom program errors. The error codes are sequential based on the order they appear in the ErrorCode enum. When an error occurs, the program will return the error code along with the error message. You can use these codes to implement proper error handling in your client application.

Build docs developers (and LLMs) love