MidKnight

Inspiration

Our inspiration came from the biggest challenge in any new developer ecosystem: the learning curve. For a privacy-focused platform like Midnight, this curve is even steeper because security is paramount. We wanted to build a tool that we, as developers, would want to use—something that lowers the barrier to entry and acts as an AI "pair programmer" to help write secure and efficient code from day one.

What it does

MidKnight is a command-line tool that serves as an AI assistant for Midnight developers. It currently has two main features:

  • Midnight Starter Kit: A simple command that instantly downloads and sets up the official starter kit in a new project directory, getting developers ready to code in seconds.
  • AI Code Analyser: A powerful security scanner that takes a smart contract file as input, sends the code to Google's Gemini API, and returns a detailed, markdown-formatted report highlighting potential security vulnerabilities, privacy leaks, and violations of best practices.

How we built it

MidKnight is built entirely in Python and structured into a clean, modular architecture.

  • Backend & CLI: We used standard Python libraries like pathlib and subprocess to manage the file system and external commands (like git).
  • AI Integration: The core of our Code Analyser is powered by the google-generativeai library, which connects to the Gemini 1.5 Flash model.
  • Prompt Engineering: We crafted a specific, role-based prompt to instruct the Gemini model to act as a "Midnight security expert" and provide its analysis in a consistently structured format.
  • Configuration Management: User data, such as their name and API key, is securely stored in a JSON file within a hidden .midknight directory in the user's home folder, providing a persistent and personalized experience.

Challenges we ran into

Our biggest challenge was prompt engineering. Getting an AI to return a consistently high-quality and well-formatted security audit required significant trial and error. We had to refine our instructions to be highly specific about the AI's persona, its focus areas (security, privacy, logic), and the final output format (Markdown).
We also decided to refactor our initial single-file script into a modular, multi-file application mid-hackathon, which was a challenge but ultimately led to a much cleaner and more scalable codebase.

Accomplishments that we're proud of

We are incredibly proud of the quality of the analysis our Code Analyser provides. Seeing the AI correctly identify subtle bugs and potential vulnerabilities in a Midnight smart contract was a huge “wow” moment, and it validated our idea that AI can truly enhance security on a privacy-focused blockchain. We’re also proud of how polished and professional the command-line interface feels — from the personalized setup to the colorized ASCII logo — which makes the tool approachable for developers just stepping into the Midnight ecosystem. Finally, we take pride in having built something that not only works technically, but also genuinely lowers the barrier for developers to start building secure and private applications on Midnight.

What we learned

We learned a great deal about the Midnight blockchain and its unique approach to privacy-first development. Working with a platform where confidentiality is built into the core forced us to rethink how smart contracts are designed and analyzed. We also saw firsthand the challenges new developers face when onboarding into a privacy-focused ecosystem, which reinforced our belief that tools like MidKnight can play a key role in lowering the barrier to entry. Finally, we learned how powerful AI can be when tailored specifically to Midnight’s security and privacy requirements, enabling more useful and context-aware code analysis.

What’s next for MidKnight

Next, we plan to expand MidKnight’s capabilities to align even more closely with the Midnight developer workflow. Our immediate goal is to implement the Code Runner & Fixer, allowing developers not only to detect errors but also to apply AI-suggested fixes automatically. We also want to package MidKnight as a VS Code extension to make it accessible directly in the IDE and add an interactive chat mode for asking questions about the Midnight platform. In the long term, our vision is for MidKnight to become the go-to AI companion for developers building on Midnight — helping them write secure, private, and robust applications faster and with more confidence.

Built With

Share this project:

Updates