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 }] }, where index is 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 by Program 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.

TypeScript
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 simulate when the simulation before signing caught it, so the wallet was never asked, and confirm when 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 laplace program 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 confirm refusal, 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:

JSON
{"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

CodeNameWhen
6000Unauthorizedsigner 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
6001InvalidConfiga basis-point value above 10,000, a non-positive answer or turn deadline, or a negative cooldown
6002InvalidModelslug 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
6003InsufficientFreeBondanswer, withdraw request or withdraw exceeds the free bond
6004WithdrawNotReadybefore the cooldown ends
6005NoWithdrawalnothing requested
6006OfferInactivethe offer is off
6007MintMismatchthe mint account differs from the offer's (request) or the receipt's (cancel_request, finalize)
6008InvalidInputinput empty or longer than the model's input_max
6009InvalidOutputoutput length differs from the model's output_len (1 for both models)
6010WrongStatethe receipt or dispute is not in the state this instruction needs
6011NotNamedOperatoranswer from someone other than the operator the request named
6012AnswerDeadlinePassedanswering after the deadline
6013AnswerDeadlineOpencancelling before the deadline
6014WindowClosedchallenging after the window
6015WindowOpenfinalizing before the window ends
6016SameOutputa challenge whose output equals the answer
6017PointCountwrong number of points for the interval
6018SelectOutOfRangeselect beyond the sub-intervals
6019NotYourTurnbisect by the side not on turn
6020TurnExpireda turn after its deadline
6021TurnOpenclaim_timeout before the deadline
6022BadProofthe 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
6023BadStepthe payload names a step other than the dispute's lo
6024MathOverflowan amount overflowed
6025SelfChallengethe answerer challenging its own answer
6026FeeAboveMaxrequest 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.

InstructionErrorRaised when
init_configUnauthorizedThe signer is not the program's upgrade authority.
InvalidConfigA 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_configUnauthorizedThe signer is not Config.admin.
InvalidConfigThe same bounds as init_config.
register_modelUnauthorizedConfig.registration_open is false and the signer is not Config.admin.
InvalidModelThe 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_withdrawInsufficientFreeBondThe amount is 0 or above bond_free.
withdraw_bondNoWithdrawalNothing is marked for withdrawal.
WithdrawNotReadyThe cooldown has not ended.
InsufficientFreeBondThe marked amount is above bond_free, because answers have locked part of it since the request.
requestMintMismatchThe mint account is not the offer's mint.
OfferInactiveThe offer's active is false.
FeeAboveMaxThe offer's price is above the request's max_fee: the operator repriced after the requester saw the price.
InvalidInputThe input is empty or longer than the model's input_max.
answerWrongStateThe receipt is not requested.
NotNamedOperatorThe signer is not the operator the receipt names.
AnswerDeadlinePassedThe time is after answer_deadline.
InvalidOutputThe output's length is not the model's output_len.
InsufficientFreeBondbond_free is below the model's bond.
cancel_requestUnauthorizedThe signer is not the receipt's requester.
MintMismatchThe mint account is not the receipt's mint.
WrongStateThe receipt is not requested.
AnswerDeadlineOpenThe time is at or before answer_deadline.
challengeWrongStateThe receipt is not answered, or index is not the receipt's disputes count.
WindowClosedThe time is at or after window_ends_at.
SelfChallengeThe signer is the receipt's answerer.
InvalidOutputThe output's length is not the model's output_len.
SameOutputThe output equals the receipt's output.
PointCountThe number of points is not the number of split points of [0, step_count].
bisectWrongStateThe dispute is not open.
NotYourTurnThe signer is not the side on turn.
TurnExpiredThe time is after the turn's deadline.
SelectOutOfRangeselect is above the number of points stored.
PointCountThe 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_stepWrongStateThe dispute is not proving.
BadStepThe payload is shorter than 4 bytes, or its step is not the dispute's lo.
BadProofThe 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.
UnauthorizedThe defender is an operator and defender_operator is missing or is not the defender's, whichever side wins.
claim_timeoutWrongStateThe dispute is already resolved.
TurnOpenThe time is at or before the turn's deadline.
UnauthorizedThe defender is an operator and defender_operator is missing or is not the defender's, whichever side wins.
finalizeMintMismatchThe mint account is not the receipt's mint.
WrongStateThe receipt is not answered.
WindowOpenThe time is before window_ends_at.
UnauthorizedThe 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.

CodeNameMessage
6000UnauthorizedSigner is not the authority or admin
6001InvalidConfigBasis points above 10,000 or a non-positive deadline
6002InvalidModelSlug empty or too long, or a zero step count, window or bond
6003InsufficientFreeBondThe free bond does not cover this
6004WithdrawNotReadyThe withdrawal cooldown has not ended
6005NoWithdrawalNo withdrawal was requested
6006OfferInactiveThe offer is off
6007MintMismatchA token account or mint differs from the offer's
6008InvalidInputInput empty or longer than the model takes
6009InvalidOutputOutput length differs from the model's
6010WrongStateNot in the state this instruction needs
6011NotNamedOperatorOnly the operator the request named may answer
6012AnswerDeadlinePassedThe answer deadline has passed
6013AnswerDeadlineOpenThe answer deadline has not passed
6014WindowClosedThe challenge window has closed
6015WindowOpenThe challenge window is still open
6016SameOutputThe challenge's output equals the answer
6017PointCountWrong number of points for the interval
6018SelectOutOfRangeSelected sub-interval is out of range
6019NotYourTurnNot this side's turn
6020TurnExpiredThe turn's deadline has passed
6021TurnOpenThe turn's deadline has not passed
6022BadProofA leaf, chunk or step does not hash to its root
6023BadStepThe proven step is not the disputed one
6024MathOverflowAn amount overflowed
6025SelfChallengeThe answerer cannot challenge its own answer
6026FeeAboveMaxThe 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.

CodeNameRaised when
2001ConstraintHasOneAn account does not match the field that names it: the model of an offer, a receipt or a dispute's receipt.
2003ConstraintRawinit_config is given a program_data that is not the program's.
2006ConstraintSeedsAn 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.
2009ConstraintAssociatedA token account is not the associated token account the instruction names.
2012ConstraintAddressfee_recipient, defender or challenger in prove_step or claim_timeout is not the address on Config or the dispute.
2014ConstraintTokenMintA token account holds another mint than the mint account.
2015ConstraintTokenOwnerA token account is owned by another key than the instruction names.
3012AccountNotInitializedAn 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.