/midnight-skills:android-example-votingfrom midnight-skills
Generates a runnable voting/poll dApp for Midnight Network using the Kuira Android SDK with Compact smart contracts, passkey-derived identity, embedded wallet, Compose UI, and on-device ZK proving.
Ships in midnight-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
This skill generates a runnable voting dApp for Midnight Network using the Kuira Android SDK. Every snippet below is taken directly from the working starter-android codebase. If the build fails, read the Failure Modes sections — they cover the three most common things that go wrong.
Primary references:
https://kuiralabs.github.io/kuira-sdk-android/ — Kuira SDK docshttps://kuiralabs.github.io/kuira-sdk-android/api/ — Dokka API referencehttps://github.com/kuiralabs/kuira-starter-android — official starterhttps://central.sonatype.com/namespace/io.github.kuiralabs — Maven Central| Capability | How |
|---|---|
| Forge sigil | PanelBar — one biometric creates passkey-DID + wallet |
| Deploy contract | Deploy the Compact contract to Midnight |
| Create poll | Organizer-only via SHA-256 admin key match |
| Cast vote | Select one of 4 options, ZK-proved on-device |
| Close poll | Only the admin key holder can close |
| Live results | observeLedger() streams state changes reactively |
Ledger 9 status (21 Nov 2026) — NEEDS CHECK against Kuira. The contract side below is updated to the Ledger 9.1 toolchain:
voting.compactcompiles with Compact 0.36.1 (language 0.28.0) for runtime 0.21.0. The Kuira SDK is not. Its newest release is0.1.0-alpha05(Maven Central, July 2026), which predates the Ledger 9 upgrade. Kuira's embedded wallet, on-device prover and localnet are Ledger 8-era until Kuira ships a Ledger 9 build. Mainnet stopped decoding Ledger 8 transactions on 6 Nov 2026, and Preview relaunched as a new Ledger 9 chain on 7 Nov 2026. Until then, this app cannot transact on public networks, and its runtime pin must match whatever runtime the Kuira build embeds (see §9). Check the Kuira release notes before relying on it.
These are the versions from the working codebase, with the contract toolchain moved to Ledger 9. Deviating on the Gradle side causes dependency resolution failures (see §9).
| Layer | Version |
|---|---|
Kuira SDK (io.github.kuiralabs:dapp-ui) | 0.1.0-alpha04 |
| Kuira Contract plugin | 0.1.0-alpha04 |
| Kuira Localnet plugin | 0.1.0-alpha04 |
| AGP | 8.13.2 |
| Kotlin | 2.3.20 |
| KSP | 2.3.6 |
| Hilt | 2.58 |
| Compose BOM | 2026.03.01 |
| Gradle | 8.13 |
| JDK | 17 |
compileSdk / targetSdk | 36 |
minSdk | 30 |
appcompat | 1.7.0 |
activity-compose | 1.10.1 |
fragment-ktx | 1.8.5 |
hilt-navigation-compose | 1.1.0 |
security-crypto | 1.1.0-alpha07 |
@midnight-ntwrk/compact-runtime | @midnight-ntwrk/[email protected] (from references/versions.json) |
| Compact compiler | compact compile +0.36.1 (from references/versions.json) |
| Compact language pragma | pragma language_version >= 0.28.0 |
kuira-starter-android/
├── settings.gradle.kts
├── build.gradle.kts # Root (plugin declarations only)
├── gradle.properties # MUST exist — jvmargs, caching
├── gradle/
│ ├── libs.versions.toml
│ └── wrapper/
│ └── gradle-wrapper.properties # Gradle 8.13
├── local.properties # sdk.dir — NOT committed
├── contract/
│ ├── package.json
│ ├── scripts/
│ │ └── patch-voting.js
│ └── src/
│ ├── voting.compact
│ └── managed/voting/ # Compiled artifacts (gitignored)
├── app/
│ ├── build.gradle.kts
│ └── src/
│ ├── main/
│ │ ├── AndroidManifest.xml
│ │ ├── res/
│ │ │ ├── values/
│ │ │ │ ├── strings.xml
│ │ │ │ └── themes.xml
│ │ │ ├── xml/
│ │ │ │ └── network_security_config.xml
│ │ │ ├── drawable/
│ │ │ │ ├── ic_launcher_foreground.xml
│ │ │ │ └── ic_launcher_background.xml
│ │ │ └── mipmap-anydpi-v26/
│ │ │ └── ic_launcher.xml
│ │ └── java/com/kuiralabs/starter/counter/
│ │ ├── KuiraStarterApp.kt
│ │ ├── MainActivity.kt
│ │ ├── di/PasskeyConfigModule.kt
│ │ ├── data/
│ │ │ ├── VotingContract.kt
│ │ │ └── ContractAddressStore.kt
│ │ └── ui/
│ │ ├── theme/{Color,Type,Theme}.kt
│ │ ├── VotingScreen.kt
│ │ ├── VotingCard.kt
│ │ ├── VotingViewModel.kt
│ │ └── VotingUiState.kt
│ └── debug/AndroidManifest.xml # Cleartext for localnet
Warning: local.properties must exist with sdk.dir=... or the
AGP android block can't resolve compileSdk. Android Studio creates
it; in CI you must create it manually or use an env var.
java --version # JDK 17+
node --version # Node.js 18+
compact update 0.36.1 # Install Compact compiler
compact list # Verify 0.36.1 is installed (the compile script pins +0.36.1)
rpId (or use GitHub Pages)The wrapper at gradle/wrapper/gradle-wrapper.properties must specify
Gradle 8.13 (matching AGP 8.13.2):
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Full content: references/gradle-configuration.md. It covers version catalog, root/app build.gradle.kts, settings, and the Kuira SDK dependency wiring. Open it when you reach this step.
Full content: references/android-resources.md. It covers manifest, strings, themes, and other res/ files. Open it when you reach this step.
Full content: references/contract.md. It covers the voting Compact contract (create/cast/close circuits) and how it is compiled and bundled into the app. Open it when you reach this step.
Full content: references/application-di.md. It covers the Application class and dependency-injection setup. Open it when you reach this step.
Full content: references/data-layer.md. It covers repositories, wallet/identity plumbing, and reactive ledger reads via observeLedger(). Open it when you reach this step.
Full content: references/ui-layer.md. It covers every Compose screen, view model, and navigation file. Open it when you reach this step.
| Symptom | Cause | Fix |
|---|---|---|
Could not find method kuiraContract() | io.github.kuiralabs.contract plugin not applied | Check the plugin ID and version in app/build.gradle.kts |
Cannot access class 'com.midnight.kuira.*' | Kuira dep not resolved | Check mavenCentral() in settings.gradle.kts, verify kuira version in catalog |
[Dagger/MissingBinding] PasskeyConfig | No PasskeyConfigModule | Create the module (§6.2) |
OutOfMemoryError: Metaspace | Not enough JVM heap | Bump org.gradle.jvmargs to -Xmx4096m |
Configuration cache state found but cache is disabled | Changed config cache setting mid-project | Delete ~/.gradle/configuration-cache/ and rebuild |
Could not find required SDK platform API 36 | SDK platform not installed | Install Android SDK Platform 36 |
java.lang.RuntimeException: Cannot load contract JS | Asset not synced | Run ./gradlew :app:assembleDebug to trigger kuiraContract sync |
IllegalStateException: Contract not compiled at .../managed/voting | kuiraContract.validateKuiraContractSource failing | Run npm run compile:voting in contract/ |
| Symptom | Cause | Fix |
|---|---|---|
"Could not find module '@midnight-ntwrk/compact-runtime'" | Runtime version mismatch | Check contract-info.json vs package.json (§5.1) |
CircuitExecutionException: Only admin can close poll | Wrong witness value | The hardcoded ADMIN_SECRET matches or it doesn't. No recovery from a different device. |
CircuitExecutionException: Poll is closed | Already closed | Wait for next poll — no reopen circuit exists |
TypeError: optionIdx_0 is not a function | BigInt patch failed | Check patch-voting.js matches the generated JS (§5.2) |
SessionLock attach failed | Called from wrong lifecycle | Call in Application.onCreate(), not Activity.onCreate() |
WalletNotifications.shouldRequest crash on API < 33 | Runtime check not guarded | The SDK handles this internally; if it crashes, you may have minSdk < 30 |
NullPointerException on readLedger before createPoll | adminKeyHash is undefined | Handle VotingLedger.adminKeyHash being all-zeros or null in UI |
| App shows "Forge a sigil" but user already has one | SDK state reset | Clear app data and re-forge, or check logcat for SigilStateProvider errors |
| Symptom | Cause | Fix |
|---|---|---|
java.net.ConnectException: Connection refused | Localnet not running | Run mn localnet up |
javax.net.ssl.SSLHandshakeException | Cleartext blocked on localnet | Add 10.0.2.2 to network_security_config.xml (§4.3) or use debug manifest (§4.5) |
RP_ID_MISMATCH | Passkey domain changed | Delete credential in Google Password Manager, re-forge |
INSUFFICIENT_DUST | Wallet not funded | Airdrop NIGHT and register dust (§10.2) |
| Transaction pending forever | Indexer not synced | Wait for observeLedger() to emit or check indexer health |
| Symptom | Cause | Fix |
|---|---|---|
Error: Unknown compiler version +0.36.1 | compactc not installed at that version | compact update 0.36.1 |
Could not find package '@midnight-ntwrk/compact-runtime' | npm deps not installed | cd contract && npm install |
Syntax error: expected ';' | Language version mismatch | Check pragma language_version matches toolchain |
The compiler cannot find module | Import path issue | Ensure contract-info.json paths are relative |
Kotlin ↔ KSP version coupling: Kotlin 2.3.20 requires KSP
2.3.6. If you upgrade Kotlin to 2.3.21, you MUST also find and
upgrade KSP to the matching version. The KSP version format is
<kotlin-version>-<ksp-release>.
AppCompat 1.7.x requires fragment-ktx 1.8.x — mixing a newer
appcompat with an older fragment causes
NoSuchMethodError: Fragment.getParentFragmentManager().
AGP ↔ Gradle coupling: AGP 8.13 requires Gradle 8.13. If you
change the wrapper distribution URL, the buildscript classpath
will fail.
Compose BOM and compiler: The kotlin-compose plugin in Kotlin
2.0+ replaces the old composeOptions { kotlinCompilerExtensionVersion }
block. Do NOT set a compose compiler version manually — the BOM
and plugin coordinate automatically.
yourname.github.io)assetlinks.json to https://<domain>/.well-known/PASSKEY_RP_ID in PasskeyConfigModule.ktmn airdrop 1000 --wallet <addr> --network undeployed
ContractCallProgressBar
shows ZK proving progress. After success, the "You Voted" badge
appears and tallies update.PanelBar. Each
network has its own deployed contract address.# Start localnet (Docker stack)
mn localnet up
# Compile contract
cd contract && npm install && npm run compile:voting
# Install + run
cd .. && ./gradlew :app:installDebug
./gradlew :app:assembleDebug
unzip -l app/build/outputs/apk/debug/app-debug.apk | grep voting
# Expected:
# assets/runtime/voting-contract.js
# assets/keys/createPoll.verifier
# assets/keys/castVote.verifier
# assets/keys/closePoll.verifier
# assets/keys/createPoll.prover
# assets/keys/castVote.prover
# assets/keys/closePoll.prover
# assets/keys/*.bzkir (if bundleWalletKeys is enabled)
./gradlew kuiraDoctor
Catches: missing PasskeyConfig binding, unhosted assetlinks.json,
stale contract artifacts, missing assets.
When compactc, the language version, or @midnight-ntwrk/compact-runtime
updates:
compact update <new-version> and compact list to confirmengines.compactc in contract/package.json@midnight-ntwrk/compact-runtime in contract/package.json+<version> pin in compile:voting scriptscripts/patch-voting.js against newly generated JS —
variable names may have changedrm -rf src/managed/voting && npm run compile:votingcontract-info.json matches
package.json./gradlew :app:assembleDebug to trigger asset resync./gradlew kuiraDoctor| API | Purpose |
|---|---|
MidnightSdkProvider | Injected singleton providing MidnightSdk + network selection |
MidnightContract.create(config) { } | Build contract handle with name, JS, address, verifier keys, witnesses |
.deploy(onProgress) | Deploy contract, returns DeployResult (.contractAddress) |
.call(circuit, vararg args, onProgress) | Call a circuit — circuit assert failure throws CircuitExecutionException |
.ledger() | Read current on-chain state, returns typed MidnightLedger |
.observeLedger() | Reactive Flow<MidnightLedger> — emits current state then each change |
MidnightLedger.getBoolean/getString/getStringOrNull/getUint64/getBytes(n, size) | Typed ledger field accessors |
ProvingKeyManager.installCircuitKeysFromAssets() | Stage proving keys from assets for on-device proving |
PanelBar(floating = true, network, onNetworkChange) | Drop-in floating sigil + wallet pills |
WalletAppShell { } | Root wrapper — SessionLockGate + WalletOverlayHost |
ContractCallProgressBar(stage, accent) | Built-in progress for deploy/call stages |
WalletForegroundService.attach(this) | Background wallet ops survive app backgrounding |
SessionLock.attach(this) / .onUserActivity() | App-wide auto-lock + idle-timer reset |
WalletNotifications.shouldRequest(this) / PERMISSION | POST_NOTIFICATIONS gating for API 33+ |
MidnightSdk.coinPublicKey | The wallet's public key needed for write handles |
WitnessResult(null, bytes) | Witness provider returning a static byte array |
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub kali-decoder/midnight-skills --plugin midnight-skills43 skills in this plugin
/1am-walletIntegrate the 1AM wallet for dust-free contract deployment and transaction flow on Midnight Network. Use this skill whenever a user is building a Midnight Network dApp, connecting to the 1AM browser extension, deploying or calling a Compact contract, handling ZK proving, setting up providers, or asking about dust-free transaction flow. Also use it for indexer patching, private state providers, payload encryption, or any question involving window.midnight['1am']./ankr-midnightIntegrate Ankr as a Midnight Network RPC provider for testnet and mainnet. Covers creating an Ankr project, copying HTTPS/WSS endpoints with API key, wiring the node URL into midnight-js / multinetwork configs, and calling Midnight JSON-RPC methods (midnight_*, system_*, chain_*, state_*). Use when the user asks about Ankr + Midnight, Ankr.js for Midnight, Ankr RPC endpoint, or replacing public Midnight RPC with Ankr.
/compactOther plugins' skills for the same job