Credential Gate — fail to prove to pass
midnight-credential-gate is a reusable Compact module that lets any DApp gate a circuit on a verifiable credential. The flow below runs end-to-end on Midnight preview: a swap call fails because the caller has no KYC credential, a prove_kyc circuit issues one, and the same swap call then passes. Two on-chain transactions, one Compact assertion, one deployed contract. All three steps are verifiable on the preview indexer.
Checking contract liveness…
Fail
Compact assert
swap() reverts
Caller has no credential. The Compact module aborts the circuit at
require_credential(subject, claim) before any state change.
Reverted assertion
Credential required
Layer
Compact 0.22 · deterministic, no tx submitted
Prove
prove_kyc circuit
Issue credential on chain
The issuer signs and the prove_kyc circuit
posts a credential commitment for the subject. Block landed below.
Tx hash
a7de8021…6664ecd1
Block
#467,663
Pass
swap circuit
swap() lands
Same caller, same arguments, same contract address.
The credential is now present, the gate clears, the swap circuit completes.
Tx hash
7b8d8c2d…0bafefc5
Block
#467,673
Reproduce locally
Three commands. ~30s on a warm cache.# clone, install, run the full fail to prove to pass loop
git clone https://github.com/cryptoleo79/YAMORI.git
cd YAMORI/contracts/credential-gate/deploy
npm install && npm run demo:clean
Contract metadata
Open in NightForge contract explorerEvery value above is either verifiable on the Midnight preview indexer or quoted verbatim from the source repo. The status pill polls /api/credential-gate/liveness every 30 seconds.