Error Codes
All custom errors are defined in the SandboxError enum. Anchor prepends a 6000 offset — so error index 0 = code 6000 in the runtime.
| Code | Name | Cause | Resolution |
|---|---|---|---|
| 6000 | AlreadyStaked | stake_nft called but a StakeAccount already exists for this mint + owner | Unstake first, or you are already staking this NFT |
| 6001 | NotStaked | unstake_nft or claim_rewards called but no StakeAccount found | The NFT is not staked — nothing to unstake or claim |
| 6002 | NotOwner | Signer does not match stake_account.owner or agent_account.owner | Sign with the wallet that originally staked / deployed |
| 6003 | NothingToClaim | claim_rewards called but elapsed time < 1 second, yielding 0 rewards | Wait at least 1 day for meaningful rewards to accrue |
| 6004 | NotCollectionMember | NFT's Metaplex metadata does not reference the Sandbox GHI verified collection | You are attempting to stake a non-Sandbox GHI NFT |
| 6005 | InvalidTier | NFT metadata contains an unrecognized tier attribute value | Metadata corruption — contact support with the NFT mint address |
| 6006 | AgentAlreadyDeployed | deploy_agent called but AgentAccount already exists for this mint + owner | Close the existing agent first with close_agent |
| 6007 | AgentNotStaked | deploy_agent called but NFT is not staked | Stake the NFT before deploying an agent |
| 6008 | InsufficientBudget | ghi_budget arg in deploy_agent is below the minimum (1 $GHI) | Provide at least 1_000_000 raw units (1 $GHI) |
| 6009 | BudgetExhausted | Agent's ghi_budget reached 0 — submit_task_result cannot debit | Top up or close the agent |
| 6010 | AgentInactive | submit_task_result called but agent_account.is_active == false | Agent is paused or closed — re-deploy to activate |
| 6011 | UnauthorizedExecutor | submit_task_result signed by non-authority key | This instruction is reserved for the off-chain executor |
| 6012 | VaultInsufficient | GHI vault balance too low to pay rewards | Protocol-level issue — report on Discord |
| 6013 | MathOverflow | Reward calculation overflowed u64 | Should not occur under normal operation — report if seen |
Reading Errors Client-Side
With @coral-xyz/anchor, errors surface as AnchorError objects:
try {
await program.methods.stakeNft().accounts({...}).rpc();
} catch (err) {
if (err instanceof AnchorError) {
console.log(err.error.errorCode.code); // e.g. "AlreadyStaked"
console.log(err.error.errorCode.number); // e.g. 6000
console.log(err.error.errorMessage);
}
}