We will be undergoing planned maintenance on January 16th, 2026 at 1:00pm UTC. Please make sure to save your work.

Note: the logging is functional the midnight test net has been down for the last few hours during the time where we need it to record our demo which is why we couldn’t include that

Inspiration

Compliance frameworks (HIPAA, SOC 2, GDPR) require immutable, real‑time access logs—but traditional file or DB logs can be altered by anyone with admin rights. We wanted a drop‑in layer that adds cryptographic auditability to an existing Flask + Mongo stack with zero schema changes. Midnight’s lightweight counter smart‑contract offered the perfect on‑chain append‑only ledger.

What it does

Authenticates each API call with OAuth / JWT. Fetches the agent’s wallet_seed and contract_hex from MongoDB. Runs Midnight’s CLI to rebuild the wallet, join the contract, and increment a counter—creating an immutable audit record. Returns the requested data to the caller. Provides a /usage_count endpoint that reads the on‑chain counter, giving live usage stats.

How we built it Flask API (app1.py) with two routes: POST /access_data → logs + serves data GET /usage_count → reads counter value

JWT layer (auth/token_utils.py) using PyJWT; HS‑256 for dev, RS‑256‑ready for production.

Mongo helpers (db/agent_model.py) to store agent metadata (wallet_seed, contract_hex, roles). Blockchain bridge (midnight/cli_logger.py) that automates Midnight’s interactive CLI via pexpect (build wallet → sync → join → increment / read).

Environment‑driven config—swap Mongo local ↔ Atlas or HS‑256 ↔ RS‑256 with a single env‑var change.

Challenges we ran into

We had trouble deploying our compact file to the test net so we were stuck with just this logging function. We wanted to also have an additional data authentication layer between the user who has a seed and the database which has an associated contract

Accomplishments that we're proud of

we got pretty far and were able to make our own custom compact application which also shown in the github a lot of the code based around that is not there anymore but the core of the data security layer is included

What we learned

we learned a lot about smart contracts and zero knowledge proofs. I would still probably use Solana in the future because its what im used to but I want to eventually use midnight later on because the zero-knowledge system is quite nice

What's next for midLogs

In the future we would like to impliment the additional data security layer between the user and mongo we couldnt impliment here especially since we already have the compact file

Built With

Share this project:

Updates