Back to Knowledge Base
TroubleshootingUpdated 3 days ago

Browser DApp Gotchas

Symptom → cause → fix table for DApp Connector wallets (1AM, Lace), Next.js and Midnight.js 5 on preview, preprod and mainnet — deploy, indexer, and ZK asset errors.

gotchas.md

Midnight Browser DApp Gotchas (Ledger 9)

Shared troubleshooting for DApp Connector wallets (1AM, Lace) + Next.js + Midnight.js 5 on preview / preprod / mainnet. Checked 21 Nov 2026 against the Ledger 9.1 set in versions.json.

SymptomCauseFix
setNetworkId is not a function / midnight-js-network-id has no 5.xRemoved in Midnight.js 5Put networkId in providers.config and in the wallet configuration; see midnight-session.md
Transaction decode / ProtocolVersionMismatchError / mainnet rejects txBuilt with ledger-v8 / Midnight.js 4 / Wallet SDK 1.xMove to the Ledger 9 set: @midnightntwrk/ledger-v9 1.0.2, Midnight.js 5.0.x, Wallet SDK 2.0.1
Compact toolchain … version mismatch on loadContract compiled by 0.36.x but compact-runtime 0.16 installedPin @midnight-ntwrk/[email protected] (and recompile with compact compile +0.36.1)
EraMismatchError: artifact-era-undeclaredZK asset sync copied only keys/ + zkir/Also copy compiler/ (contract-manifest.json, contract-info.json) into public/zk/<contract>/
ZkArtifactIntegrityErrorServed artifacts don't match the manifest (partial/stale sync)Re-run the asset sync after every recompile; serve all three dirs from the same build
Circuit arg error 'bytes' does not exist in type Uint8ArrayBytes<32> params are plain Uint8Array; only UserAddress / ZswapCoinPublicKey structs are { bytes }Check the generated contract/index.d.ts for each parameter's shape
Coin public key is all zerosConnector returns keys in Bech32m, old helper only parsed hexShieldedCoinPublicKey.codec.decode(networkId, MidnightBech32m.parse(key)).data
ledger() throws expected instance of ChargedStateDecoded by a different runtime copy, or passed the read objectledger(read.contractState.deserialize({ v9: ContractState }).data) with your own compact-runtime import
queryContractState(...).data is undefinedMidnight.js 5 returns era-tagged bytes, not a ContractStateUse read.contractState.deserialize({ v9: ContractState })
Private state lost / setContractAddress is not a functionPrivateStateProvider is forContract(address)-scoped in 5.xUse levelPrivateStateProvider({ accountId, privateStoragePasswordProvider }) (IndexedDB in browsers)
PasswordValidationErrorPrivate-storage password too weak≥16 chars, 3 character classes, no long repeats/sequences
next build fails prerendering (No native build was found … classic-level)Server render evaluates wallet/SDK modulesLoad the client component with dynamic(() => import(...), { ssr: false }) from a 'use client' page
UnhandledSchemeError: node:url in the browser bundlecontract/src/index.ts builds a filesystem path with node:pathUse a plain string for withCompiledFileAssets in browser code
CompiledContract is not exportedImported from compact-runtimeImport from @midnight-ntwrk/compact-js
Indexer 410 ENDPOINT_DECOMMISSIONEDindexer.preprod/mainnet.midnight.network retired 9 Oct 2026Preprod/mainnet indexer + RPC are Blockfrost (?project_id=<token>); in browsers use the wallet's endpoints via dappConnectorNetwork(api)
Blockfrost 403 Missing/Invalid project tokenNo token, or a token for the other networkPer-network tokens (nightpreprod… / nightmainnet…); networks.preprod(token) from midnight-js-utils
Indexer 404 on /api/v3/graphql locallyOld pathLocal and preview indexers are /api/v4/graphql (WS /api/v4/graphql/ws)
Contract subscription only sees new actionsIndexer 4.4.101 semantics without an offsetMidnight.js 5 passes an explicit offset itself; custom subscriptions should pass { blockHeight: 0 } to replay
Contract / balance missing on PreviewPreview relaunched as a new chain on 7 Nov 2026Redeploy, re-request tNIGHT, re-register DUST
No DUST on Preprod after 9 Nov 2026Upgrade cleared DUST registrations not backed by cNIGHTRegister tNIGHT for DUST generation again
balanceTx ignores your TTLDApp Connector takes no TTL (connector issue #102)Expected; the wallet picks the expiry
WASM / top-level-await errorsMissing webpack experimentsNext 15: enable asyncWebAssembly + topLevelAwait in next.config.mjs (the --webpack flag is Next 16 only)
Wrong wallet detectedMultiple extensionsPrefer window.midnight['1am'], else Object.values(window.midnight)[0]

Token units: 1 NIGHT = 1_000_000 Stars. Use BigInt for amounts. DUST: cap 5 DUST per NIGHT, 10^15 Specks per DUST, ~1 week to cap, 3 h grace. Read it with state.dust.balance(new Date()) (Wallet SDK 2.x), or api.getDustBalance() through the connector.

What changed in v1.0.16

All registry changes

Updated since v1.0.14: +12 −0 lines.

Show diff
gotchas.md+12−0
@@ -1,3 +1,15 @@+---+title: Browser DApp Gotchas+description: Symptom → cause → fix table for DApp Connector wallets (1AM, Lace), Next.js and Midnight.js 5 on preview, preprod and mainnet — deploy, indexer, and ZK asset errors.+category: Troubleshooting+author: Kali-Decoder+tags:+  - Debugging+  - DApp Connector+  - Midnight.js+  - ZK assets+---+ # Midnight Browser DApp Gotchas (Ledger 9)  Shared troubleshooting for DApp Connector wallets (1AM, Lace) + Next.js + Midnight.js 5 on preview / preprod / mainnet.

Used by 7 skills

Give it to your agent

Paste the URL into your agent, or save the file into your project.

curl -fsSL -o gotchas.md https://midskills.sevryn.xyz/knowledge/gotchas/raw
Author
Kali-Decoder
Category
Troubleshooting
Last updated
Dec 1, 2026 · v1.0.16

Tags

DebuggingDApp ConnectorMidnight.jsZK assets
Create Social CardLive HackathonsGallery
Mock Demo
Browser DApp Gotchas | MIDSKILLS