Reference
Program errors
Every error code, its name and what raises it.
The laplace program refuses an instruction with one of 27 errors, numbered from 6000. This page shows how a refusal reaches a caller on each surface, lists every error, and groups them by the instruction that raises them.
How an error reaches a caller
On chain
The errors are an Anchor #[error_code] enum, so each one is a custom program error whose number is 6000 plus its position in the enum. A refused transaction carries it twice:
- in the transaction error, as
{ "InstructionError": [index, { "Custom": 6015 }] }, whereindexis the instruction's position in the transaction, - in the logs, as an Anchor line that holds
Error Code: WindowOpen. Error Number: 6015.with the error's message, followed byProgram CdwvX8HQX3r89DpjZEfZ2VmtsxCCVdejrpwd5qD25iHq failed: custom program error: 0x177f, the number in hexadecimal.
A refusal fails the whole transaction: nothing the instruction did is kept.
From the SDK
Every call of @laplace/sdk that sends a transaction throws LaplaceError when it fails. For a refusal by the program, programError holds the code and the name read from the logs.
import { LaplaceError, PROGRAM_ERRORS } from '@laplace/sdk'
try {
await laplace.finalize(receipt)
} catch (e) {
if (e instanceof LaplaceError && e.programError) {
e.programError.code // 6015
e.programError.name // 'WindowOpen'
PROGRAM_ERRORS[e.programError.code]?.msg // 'The challenge window is still open'
e.stage // 'simulate'
e.logs // the transaction's log lines
}
}stageStage- Where the call failed. A refusal is
simulatewhen the simulation before signing caught it, so the wallet was never asked, andconfirmwhen the transaction landed and failed. LaplaceError gives every stage. messagestring- For a refusal:
The program refused it: <Name>. programError{ code: number; name: string }- Set when the
laplaceprogram raised the error. Anchor's own errors, below 6000, arrive here too with their Anchor names. logsstring[]- The log lines of the simulation or of the landed transaction.
signaturestring- The transaction's signature, set once it was signed: on a
confirmrefusal, the failed transaction to look up.
PROGRAM_ERRORS maps each code to { name, msg }. programErrorFromLogs(logs) is the function that reads the code and name out of a list of log lines.
From the API
The HTTP API reports a refusal by a program in its error envelope with the code CHAIN_REFUSED and status 422. programError names the program that refused, the error's name and its number:
{"error":{"code":"CHAIN_REFUSED","message":"The program refused the transaction: WindowClosed.","retryable":false,"stage":"simulation","programError":{"programId":"CdwvX8HQX3r89DpjZEfZ2VmtsxCCVdejrpwd5qD25iHq","name":"WindowClosed","number":6014}}}With the SDK's API client the same envelope is an ApiClientError: e.status is 422, e.code is 'CHAIN_REFUSED' and e.body.error.programError holds { programId, name, number }. HTTP API covers the envelope and its other codes.
The errors
| Code | Name | When |
|---|---|---|
| 6000 | Unauthorized | signer is not the account's authority or admin; register_model by anyone but the admin while registration is closed; in finalize an answerer or Operator account that is not the receipt's; in prove_step and claim_timeout against an operator's answer, a missing or wrong defender_operator, whichever side wins |
| 6001 | InvalidConfig | a basis-point value above 10,000, a non-positive answer or turn deadline, or a negative cooldown |
| 6002 | InvalidModel | slug empty, longer than 24 bytes or outside a-z0-9-; step count, state pages, chunk count, window or bond 0; input_max or output_len 0 or above 64 |
| 6003 | InsufficientFreeBond | answer, withdraw request or withdraw exceeds the free bond |
| 6004 | WithdrawNotReady | before the cooldown ends |
| 6005 | NoWithdrawal | nothing requested |
| 6006 | OfferInactive | the offer is off |
| 6007 | MintMismatch | the mint account differs from the offer's (request) or the receipt's (cancel_request, finalize) |
| 6008 | InvalidInput | input empty or longer than the model's input_max |
| 6009 | InvalidOutput | output length differs from the model's output_len (1 for both models) |
| 6010 | WrongState | the receipt or dispute is not in the state this instruction needs |
| 6011 | NotNamedOperator | answer from someone other than the operator the request named |
| 6012 | AnswerDeadlinePassed | answering after the deadline |
| 6013 | AnswerDeadlineOpen | cancelling before the deadline |
| 6014 | WindowClosed | challenging after the window |
| 6015 | WindowOpen | finalizing before the window ends |
| 6016 | SameOutput | a challenge whose output equals the answer |
| 6017 | PointCount | wrong number of points for the interval |
| 6018 | SelectOutOfRange | select beyond the sub-intervals |
| 6019 | NotYourTurn | bisect by the side not on turn |
| 6020 | TurnExpired | a turn after its deadline |
| 6021 | TurnOpen | claim_timeout before the deadline |
| 6022 | BadProof | the payload does not prove step lo against the model's roots and lo_root (a page, chunk, descriptor or path that does not hash to its root, a short or overlong payload), or the step does not execute |
| 6023 | BadStep | the payload names a step other than the dispute's lo |
| 6024 | MathOverflow | an amount overflowed |
| 6025 | SelfChallenge | the answerer challenging its own answer |
| 6026 | FeeAboveMax | request against an offer whose price is above the requester's max_fee |
By instruction
Each row is one check. The instruction's section on Program instructions gives the checks in the order they run.
| Instruction | Error | Raised when |
|---|---|---|
init_config | Unauthorized | The signer is not the program's upgrade authority. |
InvalidConfig | A basis-point value is above 10,000, answer_deadline_secs or turn_deadline_secs is 0 or less, or withdraw_cooldown_secs is below 0. | |
set_config | Unauthorized | The signer is not Config.admin. |
InvalidConfig | The same bounds as init_config. | |
register_model | Unauthorized | Config.registration_open is false and the signer is not Config.admin. |
InvalidModel | The slug is empty, longer than 24 bytes or holds a byte outside a to z, 0 to 9 and -; step_count, state_pages, chunk_count, window_secs or bond_lamports is 0; input_max or output_len is 0 or above 64. | |
request_withdraw | InsufficientFreeBond | The amount is 0 or above bond_free. |
withdraw_bond | NoWithdrawal | Nothing is marked for withdrawal. |
WithdrawNotReady | The cooldown has not ended. | |
InsufficientFreeBond | The marked amount is above bond_free, because answers have locked part of it since the request. | |
request | MintMismatch | The mint account is not the offer's mint. |
OfferInactive | The offer's active is false. | |
FeeAboveMax | The offer's price is above the request's max_fee: the operator repriced after the requester saw the price. | |
InvalidInput | The input is empty or longer than the model's input_max. | |
answer | WrongState | The receipt is not requested. |
NotNamedOperator | The signer is not the operator the receipt names. | |
AnswerDeadlinePassed | The time is after answer_deadline. | |
InvalidOutput | The output's length is not the model's output_len. | |
InsufficientFreeBond | bond_free is below the model's bond. | |
cancel_request | Unauthorized | The signer is not the receipt's requester. |
MintMismatch | The mint account is not the receipt's mint. | |
WrongState | The receipt is not requested. | |
AnswerDeadlineOpen | The time is at or before answer_deadline. | |
challenge | WrongState | The receipt is not answered, or index is not the receipt's disputes count. |
WindowClosed | The time is at or after window_ends_at. | |
SelfChallenge | The signer is the receipt's answerer. | |
InvalidOutput | The output's length is not the model's output_len. | |
SameOutput | The output equals the receipt's output. | |
PointCount | The number of points is not the number of split points of [0, step_count]. | |
bisect | WrongState | The dispute is not open. |
NotYourTurn | The signer is not the side on turn. | |
TurnExpired | The time is after the turn's deadline. | |
SelectOutOfRange | select is above the number of points stored. | |
PointCount | The number of points is not the number of split points of the selected sub-interval, or points are sent when it is one step. | |
prove_step | WrongState | The dispute is not proving. |
BadStep | The payload is shorter than 4 bytes, or its step is not the dispute's lo. | |
BadProof | The payload does not verify: a descriptor, page or chunk does not hash to its root, bytes are missing or left over, or the step does not execute. | |
Unauthorized | The defender is an operator and defender_operator is missing or is not the defender's, whichever side wins. | |
claim_timeout | WrongState | The dispute is already resolved. |
TurnOpen | The time is at or before the turn's deadline. | |
Unauthorized | The defender is an operator and defender_operator is missing or is not the defender's, whichever side wins. | |
finalize | MintMismatch | The mint account is not the receipt's mint. |
WrongState | The receipt is not answered. | |
WindowOpen | The time is before window_ends_at. | |
Unauthorized | The answerer account is not the receipt's answerer, or the answerer is an operator and operator is missing or is not the answerer's. |
MathOverflow is raised by any instruction whose addition to a balance or a time overflows, or whose subtraction from the vault or from bond_locked would go below 0. register_operator, deposit_bond and set_offer have no check of their own.
Messages
The message each error carries in the logs, and in PROGRAM_ERRORS[code].msg.
| Code | Name | Message |
|---|---|---|
| 6000 | Unauthorized | Signer is not the authority or admin |
| 6001 | InvalidConfig | Basis points above 10,000 or a non-positive deadline |
| 6002 | InvalidModel | Slug empty or too long, or a zero step count, window or bond |
| 6003 | InsufficientFreeBond | The free bond does not cover this |
| 6004 | WithdrawNotReady | The withdrawal cooldown has not ended |
| 6005 | NoWithdrawal | No withdrawal was requested |
| 6006 | OfferInactive | The offer is off |
| 6007 | MintMismatch | A token account or mint differs from the offer's |
| 6008 | InvalidInput | Input empty or longer than the model takes |
| 6009 | InvalidOutput | Output length differs from the model's |
| 6010 | WrongState | Not in the state this instruction needs |
| 6011 | NotNamedOperator | Only the operator the request named may answer |
| 6012 | AnswerDeadlinePassed | The answer deadline has passed |
| 6013 | AnswerDeadlineOpen | The answer deadline has not passed |
| 6014 | WindowClosed | The challenge window has closed |
| 6015 | WindowOpen | The challenge window is still open |
| 6016 | SameOutput | The challenge's output equals the answer |
| 6017 | PointCount | Wrong number of points for the interval |
| 6018 | SelectOutOfRange | Selected sub-interval is out of range |
| 6019 | NotYourTurn | Not this side's turn |
| 6020 | TurnExpired | The turn's deadline has passed |
| 6021 | TurnOpen | The turn's deadline has not passed |
| 6022 | BadProof | A leaf, chunk or step does not hash to its root |
| 6023 | BadStep | The proven step is not the disputed one |
| 6024 | MathOverflow | An amount overflowed |
| 6025 | SelfChallenge | The answerer cannot challenge its own answer |
| 6026 | FeeAboveMax | The offer's price is above the fee the requester allowed |
Errors below 6000
A wrong account in an instruction is refused by Anchor before the program's own checks run. These carry Anchor's numbers, and the SDK reports them in programError the same way.
| Code | Name | Raised when |
|---|---|---|
| 2001 | ConstraintHasOne | An account does not match the field that names it: the model of an offer, a receipt or a dispute's receipt. |
| 2003 | ConstraintRaw | init_config is given a program_data that is not the program's. |
| 2006 | ConstraintSeeds | An account is not at the address its seeds give: the config, the vault, the escrow authority, the signer's Operator, an offer, a receipt or a dispute. |
| 2009 | ConstraintAssociated | A token account is not the associated token account the instruction names. |
| 2012 | ConstraintAddress | fee_recipient, defender or challenger in prove_step or claim_timeout is not the address on Config or the dispute. |
| 2014 | ConstraintTokenMint | A token account holds another mint than the mint account. |
| 2015 | ConstraintTokenOwner | A token account is owned by another key than the instruction names. |
| 3012 | AccountNotInitialized | An account the instruction reads does not exist: an unregistered operator, a missing token account. |
An account that already exists where an instruction creates one (a registered slug, a registered operator, a used receipt nonce) fails in the System Program, outside these lists.
A program that reads receipts through the laplace-receipt crate raises that crate's two errors under its own program id. laplace-receipt crate lists them.