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.

Groth16 Verification Errors

The following errors are defined in the Groth16Error enum and are related to zero-knowledge proof verification.

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.