Back to Browse

Use with your AI agent

  1. Install — run npx skills add Kali-Decoder/Midnight-skills --skill midnight-common-errors for this skill, or npx skills add Kali-Decoder/Midnight-skills for all
  2. Prompt — copy the example prompt and paste it into Cursor, Claude Code, or Codex
  3. Build — the agent loads this skill and scaffolds your Midnight work

Common Errors

FoundationBeginnerReviewedNewUpdated 3 days agov1.0.0

Agent picks this when: Look up an error message or code and fix it

Look up a Midnight error message or code (compiler, runtime, Midnight.js, wallet, indexer, node `Custom error: N`) and get the cause, the fix, and the skill that explains it.

Good for

  • Error string or numeric code in; cause, fix, and the skill that explains it out.
  • Covers compiler, runtime, Midnight.js, wallets, indexer, node rejections, Docker, and Next.js.

Preview in agent

Suggested prompts

Look up an error message or code and fix it. Use the "midnight-common-errors" skill from MIDSKILLS. Follow Compact smart-contract best practices, wire wallet flows where needed, and explain each step as you implement. Target Midnight Preprod unless I specify otherwise.

Loaded skill midnight-common-errors

What the skill guides the agent to do:

  1. Error string or numeric code in; cause, fix, and the skill that explains it out.
  2. Covers compiler, runtime, Midnight.js, wallets, indexer, node rejections, Docker, and Next.js.

Illustrative — based on the skill's description, not recorded agent output.

Try it without installing: npx skills use Kali-Decoder/Midnight-skills@midnight-common-errors

What changed in v1.0.16

All registry changes

New skill — first published in v1.0.16 (not in v1.0.14).

On this page · 11 sections
SKILL.md

Midnight Common Errors

Error string or code in, cause plus fix out. Every row comes from a skill in this repo and links to it, so follow the link when the one-line fix is not enough.

Machine-readable source: errors.json (the same data powers the lookup_error tool in midskills-mcp).

Workflow

  1. Take the most specific part of the error: a numeric code, an error class name (EraMismatchError), or the stable text before any value (Version mismatch: compiled code expects).
  2. Search the tables below for it (or grep -i "<text>" errors.json).
  3. Apply the fix, then open the linked skill if the fix touches code you have not seen.
  4. Version-shaped errors (mismatch, ETARGET, decode, ProtocolVersion…) almost always mean the project left the tested set. Run midnight-doctor before changing code.
  5. No match? Do not guess a cause. Say the error is not in the table and report the raw message plus the versions from midnight-doctor. For a node Custom error: N, look the number up in the official Midnight docs / ledger source for your ledger version: the numbers are not stable across ledger versions.

Lookup tables

<!-- SKILLS_REGISTRY:ERRORS -->

Node rejections (1010: Invalid Transaction: Custom error: N)

ErrorCauseFixSkill
170 InvalidDustSpendProofThe wallet paying the fee had not synced every DUST event before building the fee offerWait for the paying wallet to sync, add the DUST fee offer again, then submitdust-gas-sponsorship
173 InsufficientDustForRegistrationFeeDUST registration attempted before enough DUST was generatedWait for generation before registering (waitForGeneratedDust in the Wallet SDK)dust-gas-sponsorship
196 DustDoubleSpendA stale wallet view reused DUST that was already spentResync the wallet and rebuild the transaction; do not run suites that share one wallet in paralleldust-gas-sponsorship
could not balance dustThe paying wallet's DUST does not cover fee plus overheadConfirm the wait-for-DUST step succeeded; DUST accrues over time, it does not appear at oncedust-gas-sponsorship
INSUFFICIENT_DUSTWallet not funded or not registered for DUST generationFund with (t)NIGHT and register it for DUST generationtoken-transfers

Compact compiler (static errors)

ErrorCauseFixSkill
potential witness-value disclosure must be declaredA witness-derived value reaches a ledger write, a return, or another public sink without disclose()Wrap the value in disclose() at the point it becomes public, and only if making it public is intendedtesting
parse error / Syntax error: expected ';'Syntax the pinned language version does not accept, often code written for another versionCheck pragma language_version against the toolchain in midnight-version-matrix; rewrite the constructtesting
unbound identifierUnknown name: typo, missing import CompactStandardLibrary;, or a stdlib function that does not existCheck the spelling and imports; confirm the function exists in the stdlib for your language versioncompact
return inside for loopreturn is not allowed inside a for bodyAccumulate into a variable (or fold) and return after the looptesting
recursive circuit / recursive structCircuits and structs cannot refer to themselvesUnroll into a bounded loop, or restructure the datatesting
sealed ledger writeA circuit writes to a sealed ledger field (only the constructor may)Set the field in the constructor, or drop sealedtesting
Counter assignment (= undefined type error)Counter fields cannot be assignedDo not initialise it in the constructor; use .increment(n) / .decrement(n)example-private-reserve-auction
Uint<16> compile error on timestampInteger too narrow for Unix secondsUse Uint<64> for all Unix timesexample-locker-dapp
Error: Unknown compiler version +XThat toolchain version is not installedcompact update <version> (see midnight-version-matrix), or drop the +Xmidnight-environment-setup

Contract runtime and version mismatches

ErrorCauseFixSkill
Version mismatch: compiled code expects X, runtime is YContract compiled by one toolchain, @midnight-ntwrk/compact-runtime from anotherPin the runtime from midnight-version-matrix and recompile with the matching compact compile +<toolchain>testing
Overflow on cast (e.g. 1000 as Uint<8>)Narrowing cast of a value that does not fitCheck bounds with assert before casting, or widen the typetesting
Counter underflowCounter decremented below zeroGuard with assert on the current value firsttesting
Uninitialized nested ledger valuemap.lookup(k).lookup(k2) before the inner value was insertedInsert the inner ADT first, or check membership before the lookuptesting
Merkle tree fullInsert into a tree that isFull()Pick a larger depth up front; check isFull() before insertingmidnight-security
expected instance of ChargedStateTwo copies of a WASM package (mixed @midnight-ntwrk / @midnightntwrk scopes, or duplicate runtimes), or the read object was passed instead of the decoded stateOne copy per package (npm ls); decode with read.contractState.deserialize({ v9: ContractState }).datamidnight-js
ContractMaintenanceAuthority WASM identity errorTwo different compact-runtime copies loaded (root and contract/)npm ls @midnight-ntwrk/compact-runtime; make both resolve one version, or delete contract/node_modulesexample-private-party-dapp
ProtocolVersionMismatchError / Transaction decode / mainnet rejects txBuilt with ledger-v8, Midnight.js 4, or Wallet SDK 1.x against a Ledger 9 networkMove the whole project to the Ledger 9 set in midnight-version-matrixmidnight-js

Midnight.js, ZK artifacts, and private state

ErrorCauseFixSkill
EraMismatchError: artifact-era-undeclaredZK asset sync copied only keys/ and zkir/Also serve compiler/ (contract-manifest.json, contract-info.json) next to them1am-wallet
ZkArtifactIntegrityErrorServed artifacts do not match the manifest (partial or stale sync)Re-run the asset sync after every recompile; serve all three dirs from one build1am-wallet
queryContractState(...).data is undefined / ledger() fails on the resultMidnight.js 5 returns era-tagged bytes, not a ContractStateledger(read.contractState.deserialize({ v9: ContractState }).data)midnight-js
setNetworkId is not a function / midnight-js-network-id not foundRemoved in Midnight.js 5Pass networkId in providers.config and the wallet configurationmidnight-js
setContractAddress is not a function / private state lostPrivateStateProvider is forContract(address)-scoped in 5.xUse levelPrivateStateProvider({ accountId, privateStoragePasswordProvider })midnight-js
PasswordValidationErrorPrivate-storage password too weakAt least 16 characters, 3 character classes, no long repeats or sequencesmidnight-js
CompiledContract is not exported / withVacantWitnesses type errorImported from compact-runtimeImport CompiledContract from @midnight-ntwrk/compact-jsexample-private-party-dapp
'bytes' does not exist in type Uint8ArrayBytes<32> parameters are plain Uint8Array; only UserAddress / ZswapCoinPublicKey structs are { bytes }Check the generated contract/index.d.ts for each parameter's shapecompact
Invalid character 'm' at position 0A Bech32m address string was parsed as hex or bytesDecode with wallet-sdk-address-format and pass { bytes: Uint8Array } to circuitsexample-payment-dapp
Coin public key is all zerosThe connector returns Bech32m keys; an old helper only parsed hexShieldedCoinPublicKey.codec.decode(networkId, MidnightBech32m.parse(key)).data1am-wallet
bigint type mismatch on constructor / circuit argsPassed number where the generated types want bigintWrap with BigInt(value) for every Uint<N> / Field argumentcompact
Failed to clone intentWallet SDK 1.x signing bugUpgrade to Wallet SDK 2.x; do not patchexample-counter
WalletFacade.init is not a functionOld new WalletFacade() usage or wrong packageUse the WalletFacade.init() static factory from the pinned wallet-sdk-facadeexample-counter

Wallets and the DApp Connector

ErrorCauseFixSkill
window.midnight is undefinedNo extension installed, or the page read it before async injectionPoll for a few seconds; then ask the user to install a Midnight walletreact-wallet-connector
Wrong wallet detectedSeveral Midnight extensions installedLet the user choose from Object.values(window.midnight); never hardcode one keyreact-wallet-connector
getProvingProvider() failsThe wallet cannot fetch ZK material from the dAppServe compiler/, keys/, and zkir/ from the dAppgero-wallet
balanceTx ignores your TTLThe DApp Connector takes no TTLExpected: the wallet picks the expiry1am-wallet
RP_ID_MISMATCHPasskey domain changedDelete the credential in the password manager and create it againmidnight-passport

Indexer, RPC, and networks

ErrorCauseFixSkill
410 ENDPOINT_DECOMMISSIONEDOld indexer.preprod/mainnet.midnight.network hosts (retired 9 Oct 2026)Preprod/mainnet indexer and RPC are Blockfrost (?project_id=<token>); in browsers use the wallet's endpointsmidnight-indexer
403 Blockfrost Missing/Invalid project tokenNo token, or a token for the other networkUse the per-network token with networks.preprod(token) / networks.mainnet(token)midnight-indexer
404 404 on /api/v3/graphqlOld indexer pathLocal and preview indexers are /api/v4/graphql (WS /api/v4/graphql/ws)midnight-indexer
Contract subscription only sees new actionsNo offset passed to a custom subscriptionPass { blockHeight: 0 } to replay from the startmidnight-indexer
Contract or balance missing on PreviewPreview relaunched as a new chain on 7 Nov 2026Redeploy, re-request tNIGHT, re-register DUSTmultinetwork
method not found (RPC)Method not exposed on this nodeCall rpc_methods; fall back to the official Midnight RPCankr-midnight

Toolchain, Docker, and bundlers

ErrorCauseFixSkill
compact: command not foundThe Compact binary is not on PATHOpen a new shell or source the installer's env file, then check compact --versionmidnight-environment-setup
ECONNREFUSED 127.0.0.1:6300Proof server not runningStart the pinned midnightntwrk/proof-server image on port 6300midnight-environment-setup
Port 6300 in useAnother container holds the portStop it, or map another host port (-p 6301:6300) and point the proof provider theretesting
ETARGET No matching version foundA version that is not in the tested setInstall the pins from midnight-version-matrix; never fall back to @latestmidnight-version-matrix
Wallet sync timeout (tests)Local devnet containers not healthyWait until node, indexer, and proof server are all healthy before running testshello-world
No native build was found ... classic-level (next build)Server render evaluates wallet/SDK modulesLoad the client component with dynamic(() => import(...), { ssr: false })1am-wallet
UnhandledSchemeError: node:urlBrowser bundle builds a filesystem path with node:pathUse a plain string for withCompiledFileAssets in browser code1am-wallet
WASM / top-level-await errors in Next.jsMissing webpack experimentsEnable asyncWebAssembly and topLevelAwait in next.config.mjs1am-wallet
ERR_UNSUPPORTED_DIR_IMPORTNode tried to import a directoryImport the file (or dist/index.js) explicitly; clear cachestesting
<!-- /SKILLS_REGISTRY:ERRORS -->

Adding an error

Edit errors.json (layer, optional code, match, cause, fix, skill), then run npm run sync:registry. Add only errors you have reproduced, and point skill at the skill that explains the fix.

TaskSkill
Check installed versions against the pinsmidnight-doctor/
See the pinned, tested version setmidnight-version-matrix/
Read compiler errors, the --skip-zk looptesting/

Start in 2 steps

  1. 1. Install — one skill or the full set
  2. 2. Prompt — paste the example into your agent

Install all skills (recommended)

npx skills add Kali-Decoder/Midnight-skills

One command adds every Midnight skill to Cursor, Claude Code, and similar agents.

Install this skill only

npx skills add Kali-Decoder/Midnight-skills --skill midnight-common-errors

Installs only "midnight-common-errors" into every detected agent (Cursor, Claude Code, Codex, …).

Example agent prompt

Look up an error message or code and fix it. Use the "midnight-common-errors" skill from MIDSKILLS. Follow Compact smart-contract best practices, wire wallet flows where needed, and explain each step as you implement. Target Midnight Preprod unless I specify otherwise.

Paste into Cursor, Claude Code, or Codex after installing.

Author
Tusharpamnani
Category
Foundation
Difficulty
beginner
Version
v1.0.0

Tags

ErrorsDebuggingTroubleshooting

Files included

SKILL.md
Create Social CardLive HackathonsGallery
Mock Demo
Common Errors