<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Devs of Midnight</title>
    <description>The latest articles on DEV Community by Devs of Midnight (devsofmidnight).</description>
    <link>https://dev.to/devsofmidnight</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Forganization%2Fprofile_image%2F10715%2F614fb778-bd43-4a7a-bda0-98a4ad4aed1f.png</url>
      <title>DEV Community: Devs of Midnight</title>
      <link>https://dev.to/devsofmidnight</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/devsofmidnight"/>
    <language>en</language>
    <item>
      <title>Compact을 시작하기 전 알아야 할 Midnight의 작동 방식</title>
      <dc:creator>Midnight Korea</dc:creator>
      <pubDate>Thu, 07 May 2026 05:16:24 +0000</pubDate>
      <link>https://dev.to/devsofmidnight/compacteul-sijaghagi-jeon-alaya-hal-midnightyi-jagdong-bangsig-14np</link>
      <guid>https://dev.to/devsofmidnight/compacteul-sijaghagi-jeon-alaya-hal-midnightyi-jagdong-bangsig-14np</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1mhprjlmwqjcnvjvt8id.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1mhprjlmwqjcnvjvt8id.png" alt=" " width="800" height="420"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;EVM 네트워크에서 개발해본 분이라면 익숙한 흐름이 있을 겁니다. 문법을 익히고, 스마트 컨트랙트를 작성하고, 온체인에 배포하고, 실행 비용은 가스로 지불하는 방식입니다.&lt;/p&gt;

&lt;p&gt;하지만 Midnight은 단순히 문법만 다른 플랫폼이 아닙니다. Compact은 처음 보면 어느 정도 익숙해 보이지만, 실제로는 로컬 실행, ZK 증명, 그리고 명시적 공개(explicit disclosure)를 중심에 둔 다른 실행 모델 위에서 동작합니다.&lt;/p&gt;

&lt;p&gt;이 글에서는 Midnight이 EVM과 어떻게 다른지, 왜 Compact을 단순히 “새로운 스마트 컨트랙트 언어”로만 보면 안 되는지, 그리고 환경 설정에 들어가기 전에 왜 이 차이를 먼저 이해해야 하는지 살펴봅니다.&lt;/p&gt;




&lt;h2&gt;
  
  
  익숙해 보이는 문법, 전혀 다른 실행 방식
&lt;/h2&gt;

&lt;p&gt;Compact 예제를 처음 보면 크게 낯설지 않을 수 있습니다.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpk9mbxdvpjnfa3649z2h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpk9mbxdvpjnfa3649z2h.png" alt=" " width="420" height="443"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;타입 선언이 있고, &lt;code&gt;export&lt;/code&gt;가 보이며, 전체적인 문법도 저수준 암호학 언어라기보다는 TypeScript에 가까워 보입니다.&lt;/p&gt;

&lt;p&gt;이 첫인상은 분명 진입 장벽을 낮춰줍니다. 다만 동시에 오해를 만들기도 합니다.&lt;/p&gt;

&lt;p&gt;Compact은 일부 문법이 익숙할 뿐, 실행 방식까지 익숙한 것은 아닙니다. 겉으로는 코드를 읽을 수 있어 보여도, 실제로 그 코드가 어디에서 실행되는지, 어떤 값이 공개되는지, 네트워크가 정확히 무엇을 검증하는지는 놓치기 쉽습니다.&lt;/p&gt;

&lt;p&gt;그래서 Compact을 “스마트 컨트랙트 언어가 하나 더 나왔구나” 정도로 받아들이면 곧 헷갈리게 됩니다. 문법은 읽히는데, 설계 방식은 기존 EVM 기반 개발과 다르기 때문입니다.&lt;/p&gt;

&lt;p&gt;이 글은 바로 그 지점, 즉 문법은 익숙하지만 사고방식은 달라지는 간극을 먼저 짚기 위한 가이드입니다.&lt;/p&gt;




&lt;h2&gt;
  
  
  EVM과 Midnight의 가장 큰 차이: 실행 모델
&lt;/h2&gt;

&lt;p&gt;EVM 네트워크의 실행 모델은 비교적 직관적입니다.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;사용자가 트랜잭션을 제출합니다.&lt;/li&gt;
&lt;li&gt;네트워크의 노드들이 같은 코드를 다시 실행합니다.&lt;/li&gt;
&lt;li&gt;실행 결과에 따라 상태가 바뀝니다.&lt;/li&gt;
&lt;li&gt;사용자는 실행 비용으로 가스를 지불합니다.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;즉, 실행도 온체인에서 일어나고 상태 전이도 온체인에서 처리됩니다. 네트워크는 같은 계산을 반복하고, 그 결과를 기준으로 상태를 검증합니다. 이해하기 쉬운 구조지만, 실행 과정과 상태가 기본적으로 공개되는 모델에 가깝습니다.&lt;/p&gt;

&lt;p&gt;Midnight은 다르게 동작합니다.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;사용자가 로컬에서 로직을 실행합니다.&lt;/li&gt;
&lt;li&gt;그 실행이 규칙에 맞았음을 보여주는 ZK proof를 생성합니다.&lt;/li&gt;
&lt;li&gt;공개해야 하는 결과와 transcript를 네트워크에 제출합니다.&lt;/li&gt;
&lt;li&gt;네트워크는 증명을 검증한 뒤, transcript에 포함된 공개 상태 전이만 온체인에서 실행합니다.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzuhf6odevia2xlq2qn47.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzuhf6odevia2xlq2qn47.png" alt=" " width="800" height="283"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;핵심은 여기에 있습니다.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;EVM에서는 모든 노드가 전체 로직을 다시 실행합니다.&lt;br&gt;&lt;br&gt;
Midnight에서는 사용자가 로컬에서 프라이빗 연산을 수행하고, 네트워크는 그 결과가 규칙에 맞는지를 증명으로 검증한 뒤 공개 상태 전이만 반영합니다.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;따라서 Midnight에서는 단순히 “함수를 호출한다”는 관점만으로는 부족합니다. 그 연산이 무엇을 증명하는지, 그리고 그 결과가 어떤 공개 상태 전이로 이어지는지까지 함께 봐야 합니다.&lt;/p&gt;




&lt;h2&gt;
  
  
  상태와 자산을 바라보는 방식
&lt;/h2&gt;

&lt;p&gt;EVM 개발자에게 익숙한 모델은 보통 account 모델입니다. 글로벌 상태 안에 주소별 잔액과 값이 있고, 트랜잭션이 그 값을 직접 바꾸는 방식입니다.&lt;/p&gt;

&lt;p&gt;Midnight은 출발점이 다릅니다. 핵심 자산 메커니즘은 UTXO 기반 구조를 사용하며, 이 구조는 프라이버시를 보존하는 설계와 잘 맞습니다. 잔액을 직접 수정하기보다, 기존 입력을 소비하고 새로운 출력을 만드는 방식으로 자산이 이동합니다.&lt;/p&gt;

&lt;p&gt;EVM식으로 표현하면 “Alice의 잔액에서 40을 빼고 Bob의 잔액에 40을 더한다”에 가깝습니다.&lt;/p&gt;

&lt;p&gt;반면 Midnight식으로 보면 “기존 입력 UTXO를 소비하고, Bob에게 보낼 출력 하나와 Alice의 잔돈에 해당하는 출력 하나를 새로 만든다”는 설명이 더 자연스럽습니다.&lt;/p&gt;

&lt;p&gt;다만 Midnight을 단순한 UTXO 체인으로만 이해해도 오해가 생깁니다. Midnight은 순수 UTXO 체인이 아니라 하이브리드 구조를 사용합니다. ledger token 메커니즘은 UTXO 기반이지만, Compact으로 작성한 스마트 컨트랙트의 자산과 로직은 경우에 따라 account 스타일에 가까운 패턴으로 동작할 수도 있습니다.&lt;/p&gt;

&lt;p&gt;그래서 Midnight을 이해할 때 더 적절한 표현은 “EVM의 반대”가 아닙니다.&lt;/p&gt;

&lt;p&gt;Midnight은 UTXO 기반 자산 메커니즘과, 필요할 경우 account 스타일의 스마트 컨트랙트 동작을 함께 사용하는, 프라이버시와 증명 중심의 체인에 가깝습니다.&lt;/p&gt;




&lt;h2&gt;
  
  
  Compact을 기존 스마트 컨트랙트 언어처럼 보면 안 되는 이유
&lt;/h2&gt;

&lt;p&gt;Compact을 처음 접할 때 흔히 하는 실수는, 이를 단순히 새로운 스마트 컨트랙트 문법으로만 보는 것입니다. 하지만 Compact은 문법만 새로 익힌다고 충분히 이해되는 언어가 아닙니다. 서로 다른 세 가지 맥락을 동시에 구분해야 합니다.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw1ix3nxhj6s6s37o4r0b.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw1ix3nxhj6s6s37o4r0b.png" alt=" " width="800" height="334"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;ledger&lt;/code&gt;: 온체인에 남는 공개 상태&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;circuit&lt;/code&gt;: 증명 시스템의 일부가 되는 로직&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;witness&lt;/code&gt;: 로컬에서 제공되는 프라이빗 데이터. 일회성 입력일 수도 있고, 로컬에서 유지되는 프라이빗 상태나 기록의 일부일 수도 있음&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;이 구분이 중요합니다.&lt;/p&gt;

&lt;p&gt;EVM에서는 상태 변수와 함수 호출을 중심으로 생각해도 대부분의 설계가 가능합니다. 하지만 Compact에서는 질문 자체가 달라집니다.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;이 값은 어디에서 왔는가?&lt;/li&gt;
&lt;li&gt;이 로직은 정확히 무엇을 증명하는가?&lt;/li&gt;
&lt;li&gt;이 값은 끝까지 프라이빗하게 남는가, 아니면 공개되는가?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;즉, 핵심은 새로운 문법이 아니라 공개 상태, 증명 로직, 프라이빗 데이터 사이의 경계가 새롭게 정의되어 있다는 점입니다.&lt;/p&gt;

&lt;p&gt;이 경계를 이해하지 못하면 코드는 읽을 수 있어도, 그 언어로 실제 설계를 하기는 어렵습니다.&lt;/p&gt;




&lt;h2&gt;
  
  
  &lt;code&gt;disclose()&lt;/code&gt;는 왜 필요할까
&lt;/h2&gt;

&lt;p&gt;EVM 네트워크에서는 상태와 실행 결과가 기본적으로 공개됩니다. 별도로 “이 값은 공개하겠습니다”라고 선언하지 않아도, 온체인에 올라간 정보는 자연스럽게 공개됩니다.&lt;/p&gt;

&lt;p&gt;Midnight은 반대 방향에서 출발합니다.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Midnight에서는 프라이버시가 기본값이고, 공개는 명시적인 선택입니다.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;그래서 Compact에서는 witness나 프라이빗 연산에서 나온 값을 ledger로 넘길 때 &lt;code&gt;disclose()&lt;/code&gt;를 사용합니다. 이는 단순한 헬퍼 함수가 아닙니다. 개발자가 “이 값은 공개하겠다”는 의도를 코드 안에서 명확히 드러내게 하는 장치입니다.&lt;/p&gt;

&lt;p&gt;이 설계는 다음과 같은 의미를 갖습니다.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;민감한 데이터가 실수로 노출될 가능성을 줄입니다.&lt;/li&gt;
&lt;li&gt;어떤 값이 공개되는지 개발자가 더 신중하게 판단하게 합니다.&lt;/li&gt;
&lt;li&gt;Midnight의 프라이버시 중심 모델을 언어 차원에서 드러냅니다.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;따라서 &lt;code&gt;disclose()&lt;/code&gt;를 어색한 문법 요소 정도로 보면 안 됩니다. 오히려 이 함수는 Midnight이 EVM의 “기본 공개” 모델과 얼마나 다르게 설계되어 있는지를 가장 직접적으로 보여주는 요소 중 하나입니다.&lt;/p&gt;




&lt;h2&gt;
  
  
  Midnight은 문법보다 사고방식이 먼저입니다
&lt;/h2&gt;

&lt;p&gt;여기까지 보면 핵심이 분명해집니다. Midnight을 또 하나의 EVM 계열 스택처럼 접근하면, 처음에는 익숙해 보여도 실제 개발에 들어갔을 때 금방 한계를 느낄 수 있습니다.&lt;/p&gt;

&lt;p&gt;EVM에서는 보통 다음과 같은 전제를 깔고 개발합니다.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;함수는 온체인에서 실행된다.&lt;/li&gt;
&lt;li&gt;상태는 기본적으로 공개된다.&lt;/li&gt;
&lt;li&gt;노드들은 같은 로직을 반복 실행한다.&lt;/li&gt;
&lt;li&gt;가스는 거래 가능한 토큰에서 나온다.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Midnight에서는 이 전제가 바뀝니다.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;사용자는 로컬에서 프라이빗 연산을 수행하고 증명을 생성합니다.&lt;/li&gt;
&lt;li&gt;공개는 자동이 아니라 명시적입니다.&lt;/li&gt;
&lt;li&gt;네트워크는 전체 로직을 다시 실행하지 않고, 증명을 검증한 뒤 transcript에 담긴 공개 상태 전이만 반영합니다.&lt;/li&gt;
&lt;li&gt;경제·운영 모델 역시 NIGHT와 DUST를 중심으로 다르게 설계되어 있습니다.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;결국 Midnight을 배운다는 것은 Compact 문법을 외우는 일이 아닙니다.&lt;/p&gt;

&lt;p&gt;더 정확히는, 프라이버시와 증명 생성이 기본 전제로 들어간 환경에서 스마트 컨트랙트를 어떻게 설계해야 하는지 다시 배우는 과정에 가깝습니다.&lt;/p&gt;

&lt;p&gt;이 시리즈가 DUST부터 다루는 이유도 여기에 있습니다. Midnight은 단순히 “어떻게 작성하는가”만 바꾸는 플랫폼이 아니라, “어떻게 실행되고 운영되는가”까지 함께 바꾸는 플랫폼이기 때문입니다.&lt;/p&gt;




&lt;h2&gt;
  
  
  Next Step: 환경 설정
&lt;/h2&gt;

&lt;p&gt;이 글이 의도한 대로 전달되었다면, Compact이 왜 처음에는 익숙해 보여도 실제로는 전혀 다른 방식으로 동작하는지 어느 정도 감이 잡혔을 것입니다.&lt;/p&gt;

&lt;p&gt;이제 다음 단계는 문법 비교가 아니라 실제 실행입니다.&lt;/p&gt;

&lt;p&gt;다음 가이드에서는 환경 설정과 첫 실행을 통해, 지금까지 설명한 모델 차이가 실제 개발 워크플로에서 어떻게 드러나는지 확인해보겠습니다.&lt;/p&gt;




&lt;h2&gt;
  
  
  핵심 정리
&lt;/h2&gt;

&lt;p&gt;이 글의 핵심은 다음과 같습니다.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Compact은 문법만 보면 익숙할 수 있지만, 실행 모델은 전혀 다릅니다.&lt;/li&gt;
&lt;li&gt;Midnight에서는 사용자가 로컬에서 프라이빗 연산을 수행하고 ZK proof를 생성합니다.&lt;/li&gt;
&lt;li&gt;네트워크는 전체 로직을 재실행하지 않고, 증명을 검증한 뒤 transcript에 담긴 공개 상태 전이만 실행합니다.&lt;/li&gt;
&lt;li&gt;Midnight은 UTXO 기반 자산 메커니즘과 account 스타일의 스마트 컨트랙트 동작을 함께 쓰는 하이브리드 구조입니다.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;ledger&lt;/code&gt;, &lt;code&gt;circuit&lt;/code&gt;, &lt;code&gt;witness&lt;/code&gt;의 구분은 Compact을 이해하는 핵심입니다.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;disclose()&lt;/code&gt;는 사소한 문법 요소가 아니라, 공개가 자동이 아니라는 Midnight의 원칙을 코드로 드러내는 장치입니다.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>midnight</category>
      <category>web3</category>
      <category>zk</category>
      <category>blockchain</category>
    </item>
    <item>
      <title>Midnight MCP - AI-assisted development for Compact smart contracts</title>
      <dc:creator>Idris Olubisi💡</dc:creator>
      <pubDate>Tue, 24 Feb 2026 13:03:27 +0000</pubDate>
      <link>https://dev.to/devsofmidnight/midnight-mcp-ai-assisted-development-for-compact-smart-contracts-37i</link>
      <guid>https://dev.to/devsofmidnight/midnight-mcp-ai-assisted-development-for-compact-smart-contracts-37i</guid>
      <description>&lt;p&gt;AI coding assistants like Claude, GitHub Copilot, and Cursor have transformed how developers write code. But they have a fundamental limitation: they only know what was in their training data.&lt;/p&gt;

&lt;p&gt;Compact, Midnight's smart contract language, isn't in that training data. When you ask an AI assistant to write a Compact contract, it hallucinates. It invents syntax that doesn't exist, references functions that were never defined, and produces code that fails at compile time.&lt;/p&gt;

&lt;p&gt;Midnight MCP solves this problem.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is MCP?
&lt;/h2&gt;

&lt;p&gt;The &lt;em&gt;Model Context Protocol&lt;/em&gt; (MCP) is an open standard that allows AI assistants to access external tools and data sources. Instead of relying solely on training data, an AI assistant with MCP can query live documentation, search codebases, and call APIs.&lt;/p&gt;

&lt;p&gt;Midnight MCP is an MCP server purpose-built for Midnight development. It gives AI assistants:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Indexed knowledge&lt;/strong&gt; of 102 Midnight repositories&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Real compiler validation&lt;/strong&gt; before showing you code&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Semantic search&lt;/strong&gt; across documentation and examples&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Version-aware syntax references&lt;/strong&gt; for Compact&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When you ask Claude to write a Compact contract, it queries Midnight MCP for the correct syntax, generates the code, validates it against the real compiler, and only shows you working code.&lt;/p&gt;

&lt;h2&gt;
  
  
  The problem with AI-generated Compact code
&lt;/h2&gt;

&lt;p&gt;Consider this prompt:&lt;/p&gt;

&lt;p&gt;"Write a simple counter contract in Compact"&lt;/p&gt;

&lt;p&gt;Without Midnight MCP, an AI assistant might generate:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;contract Counter {
    state count: Int = 0;

    function increment(): Void {
        count = count + 1;
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This looks plausible. It's also completely wrong:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Compact uses &lt;code&gt;ledger&lt;/code&gt; for state, not &lt;code&gt;state&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;There is no &lt;code&gt;Int&lt;/code&gt; type in Compact. It uses &lt;code&gt;Uint&amp;lt;32&amp;gt;&lt;/code&gt;, &lt;code&gt;Field&lt;/code&gt;, and other specific types.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;Void&lt;/code&gt; doesn't exist. Compact uses &lt;code&gt;[]&lt;/code&gt; for the unit type.&lt;/li&gt;
&lt;li&gt;State mutations require witness functions, not direct assignment.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The AI hallucinated a language that resembles Solidity but isn't Compact. A developer unfamiliar with Compact might spend hours debugging code that was never valid.&lt;/p&gt;

&lt;h2&gt;
  
  
  Install Midnight MCP
&lt;/h2&gt;

&lt;p&gt;Midnight MCP requires no API keys and installs in under 60 seconds. Add the appropriate configuration to your AI assistant based on the tool you use.&lt;/p&gt;

&lt;h3&gt;
  
  
  Claude Desktop
&lt;/h3&gt;

&lt;p&gt;On macOS, edit &lt;code&gt;~/Library/Application Support/Claude/claude_desktop_config.json&lt;/code&gt;. Add the following configuration to enable Midnight MCP:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"mcpServers"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"midnight"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"command"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"npx"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"args"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"-y"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"midnight-mcp@latest"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Cursor
&lt;/h3&gt;

&lt;p&gt;Create or edit &lt;code&gt;.cursor/mcp.json&lt;/code&gt; in your project root. You can also configure it globally at &lt;code&gt;~/.cursor/mcp.json&lt;/code&gt; on macOS/Linux or &lt;code&gt;%USERPROFILE%\.cursor\mcp.json&lt;/code&gt; on Windows. Add the following configuration:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"mcpServers"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"midnight"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"command"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"npx"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"args"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"-y"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"midnight-mcp@latest"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  VS Code with GitHub Copilot
&lt;/h3&gt;

&lt;p&gt;Create or edit &lt;code&gt;.vscode/mcp.json&lt;/code&gt; in your project. Add the following configuration to connect Copilot to Midnight MCP:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"servers"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"midnight"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"command"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"npx"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"args"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"-y"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"midnight-mcp@latest"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After adding the configuration, restart your AI assistant. You now have access to 29 Midnight-specific tools.&lt;/p&gt;

&lt;h2&gt;
  
  
  How Midnight MCP works
&lt;/h2&gt;

&lt;p&gt;Midnight MCP operates as a local server that connects your AI assistant to Midnight's ecosystem.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcale9bp8n6rz03heck2a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcale9bp8n6rz03heck2a.png" alt="Midnight MCP Architecture" width="800" height="377"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When you ask for a Compact contract:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The AI assistant calls &lt;code&gt;midnight-get-latest-syntax&lt;/code&gt; to retrieve current Compact syntax.&lt;/li&gt;
&lt;li&gt;It generates code using the correct patterns.&lt;/li&gt;
&lt;li&gt;It calls &lt;code&gt;midnight-compile-contract&lt;/code&gt; to validate against the real compiler.&lt;/li&gt;
&lt;li&gt;If compilation fails, it reads the error, fixes the code, and retries.&lt;/li&gt;
&lt;li&gt;You receive verified, working code.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This compile-validate-fix loop happens automatically. You never see the broken intermediate versions.&lt;/p&gt;

&lt;h2&gt;
  
  
  Real compiler integration
&lt;/h2&gt;

&lt;p&gt;Most code-generation tools rely on pattern matching and hope. Midnight MCP validates code against the actual Compact compiler hosted.&lt;/p&gt;

&lt;p&gt;The compiler catches errors that static analysis cannot, including:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Type mismatches&lt;/strong&gt;: Using &lt;code&gt;Field&lt;/code&gt; where &lt;code&gt;Uint&amp;lt;64&amp;gt;&lt;/code&gt; is expected&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Sealed field violations&lt;/strong&gt;: Attempting to access sealed state incorrectly&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Disclose rule errors&lt;/strong&gt;: Missing or malformed privacy annotations&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Unbound identifiers&lt;/strong&gt;: References to undefined variables or types&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When the compiler returns an error, the response includes the exact line number and column:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;success: false
message: "Line 12:8 - unbound identifier 'totalSupply'"
errorDetails:
  line: 12
  column: 8
  errorType: error
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The AI assistant uses this information to fix the code and try again.&lt;/p&gt;

&lt;h3&gt;
  
  
  Graceful fallback
&lt;/h3&gt;

&lt;p&gt;If the hosted compiler is unavailable, Midnight MCP falls back to static analysis. The response indicates which validation method was used:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;validationType: "compiler"           # Real compiler validation
validationType: "static-analysis-fallback"  # Compiler unavailable
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You always receive validation. The tool never fails silently.&lt;/p&gt;

&lt;h2&gt;
  
  
  Semantic search across 102 repositories
&lt;/h2&gt;

&lt;p&gt;Today, Midnight MCP indexes every non-archived repository in the Midnight ecosystem:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;All 88 repositories from &lt;code&gt;midnightntwrk&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;14 community and partner repositories, including OpenZeppelin contracts and hackathon winners.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The search is semantic, not keyword-based. For example, a prompt like "find code that handles shielded transactions" returns relevant results even if those exact words don't appear in the code.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Prompt: "How do I implement a token with transfer limits?"

midnight-search-compact returns:
- Token contract examples from midnight-examples
- Rate limiting patterns from community repos
- Relevant documentation sections
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  29+ tools for Midnight development
&lt;/h2&gt;

&lt;p&gt;Midnight MCP provides 29 tools organized by function.&lt;/p&gt;

&lt;h3&gt;
  
  
  Search tools
&lt;/h3&gt;

&lt;p&gt;Use these tools to find code, documentation, and examples across the Midnight ecosystem.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Tool&lt;/th&gt;
&lt;th&gt;Purpose&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;midnight-search-compact&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Search Compact language code across indexed repos&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;midnight-search-docs&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Search official Midnight documentation&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;midnight-search-typescript&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Search TypeScript SDK implementations&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;midnight-fetch-docs&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Fetch live documentation from docs.midnight.network&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  Analysis tools
&lt;/h3&gt;

&lt;p&gt;Use these tools to validate, analyze, and review Compact contracts.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Tool&lt;/th&gt;
&lt;th&gt;Purpose&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;midnight-compile-contract&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Validate code against the real Compact compiler&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;midnight-analyze-contract&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Run 15 static security checks&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;midnight-review-contract&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;AI-powered security review&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;midnight-extract-contract-structure&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Parse contract structure and exports&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  Generation tools
&lt;/h3&gt;

&lt;p&gt;Use these tools to create new contracts and documentation.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Tool&lt;/th&gt;
&lt;th&gt;Purpose&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;midnight-generate-contract&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Generate contracts from natural language descriptions&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;midnight-document-contract&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Generate documentation in Markdown or JSDoc format&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  Repository tools
&lt;/h3&gt;

&lt;p&gt;Use these tools to access files and syntax references from Midnight repositories.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Tool&lt;/th&gt;
&lt;th&gt;Purpose&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;midnight-get-file&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Retrieve files from any indexed Midnight repository&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;midnight-get-file-at-version&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Get file content at a specific version&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;midnight-compare-syntax&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Compare syntax between Compact versions&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;midnight-get-latest-syntax&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Current Compact syntax reference&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;midnight-get-repo-context&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Everything needed to start coding (compound tool)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;midnight-list-examples&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;List available example contracts&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  Version management tools
&lt;/h3&gt;

&lt;p&gt;Use these tools to manage upgrades and track changes between Compact versions.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Tool&lt;/th&gt;
&lt;th&gt;Purpose&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;midnight-upgrade-check&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Full upgrade analysis (compound tool)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;midnight-check-breaking-changes&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Identify breaking changes between versions&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;midnight-get-migration-guide&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Step-by-step migration instructions&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Resources and prompts
&lt;/h2&gt;

&lt;p&gt;Beyond tools, Midnight MCP provides nine built-in resources and five interactive prompts.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Resources&lt;/em&gt; are always-available references that provide quick access to syntax and examples:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;midnight://syntax/latest      Current Compact syntax
midnight://examples/counter   Counter contract example
midnight://examples/token     Token contract example
midnight://docs/compact       Compact language reference
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Prompts&lt;/em&gt; are templates for common tasks that guide you through specific workflows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;create-compact-contract      Start a new contract
debug-compact-error          Fix compilation errors
security-review              Full security audit
compare-compact-versions     Migration assistance
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Architecture
&lt;/h2&gt;

&lt;p&gt;Midnight MCP is built for reliability:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Token efficiency&lt;/strong&gt;: Outputs YAML by default (20-30% fewer tokens than JSON)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Compound tools&lt;/strong&gt;: Single calls that combine multiple operations&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Graceful degradation&lt;/strong&gt;: Falls back to cached data when services are unavailable&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Progress notifications&lt;/strong&gt;: Real-time updates during long operations&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The codebase is fully tested with 206 tests across 10 test suites.&lt;/p&gt;

&lt;h2&gt;
  
  
  What's next
&lt;/h2&gt;

&lt;p&gt;Midnight MCP is open source and actively developed. The roadmap includes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Full ZK circuit output parsing&lt;/strong&gt; from compiler results.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Contract deployment&lt;/strong&gt; directly from AI chat.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;TypeScript SDK integration&lt;/strong&gt; for automatic prover code generation.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Local devnet interaction&lt;/strong&gt; for querying balances and submitting transactions.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Learn more
&lt;/h2&gt;

&lt;p&gt;Explore the source code and contribute:&lt;/p&gt;

&lt;p&gt;→ &lt;a href="https://github.com/Olanetsoft/midnight-mcp" rel="noopener noreferrer"&gt;GitHub repository&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;→ &lt;a href="https://npmjs.com/package/midnight-mcp" rel="noopener noreferrer"&gt;npm package&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;→ &lt;a href="https://github.com/Olanetsoft/midnight-mcp/blob/main/docs/API.md" rel="noopener noreferrer"&gt;API documentation&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Midnight MCP is a community project. Contributions, issues, and feature requests are welcome.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>ai</category>
      <category>mcp</category>
      <category>programming</category>
    </item>
    <item>
      <title>Introduction to the FungibleToken contract on Midnight</title>
      <dc:creator>Claude Barde</dc:creator>
      <pubDate>Thu, 11 Sep 2025 14:35:44 +0000</pubDate>
      <link>https://dev.to/devsofmidnight/introduction-to-the-fungibletoken-contract-on-midnight-20ai</link>
      <guid>https://dev.to/devsofmidnight/introduction-to-the-fungibletoken-contract-on-midnight-20ai</guid>
      <description>&lt;h2&gt;
  
  
  &lt;strong&gt;Introduction to the FungibleToken contract on Midnight&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Midnight&lt;/strong&gt; is a privacy-first blockchain designed to bring &lt;em&gt;privacy&lt;/em&gt; to decentralized applications. It achieves this through &lt;a href="https://docs.midnight.network/develop/how-midnight-works/" rel="noopener noreferrer"&gt;zero-knowledge proofs, programmable data protection, and developer-friendly tools&lt;/a&gt; like &lt;strong&gt;Compact&lt;/strong&gt;, a TypeScript-based DSL (Domain-Specific Language) for writing privacy-aware smart contracts.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://docs.openzeppelin.com/" rel="noopener noreferrer"&gt;&lt;strong&gt;OpenZeppelin&lt;/strong&gt;&lt;/a&gt; is renowned in the Ethereum ecosystem for its battle-tested smart contract libraries, which have secured trillions in on-chain value. Recently, &lt;a href="https://midnight.network/blog/openzeppelin-joins-forces-with-midnight-to-shape-the-future-of-privacy-preserving-smart" rel="noopener noreferrer"&gt;OpenZeppelin partnered with Midnight&lt;/a&gt; to bring comparable tooling to the Compact ecosystem, adapting familiar standards like ERC-20 into privacy-preserving variants.&lt;/p&gt;

&lt;p&gt;In the Ethereum world, the &lt;strong&gt;ERC-20&lt;/strong&gt; standard defines a fungible token with public ledger functions like &lt;code&gt;balanceOf&lt;/code&gt;, &lt;code&gt;transfer&lt;/code&gt;, &lt;code&gt;approve&lt;/code&gt;, etc. It exposes transaction data transparently and lacks built-in privacy. The &lt;strong&gt;FungibleToken&lt;/strong&gt; contract on Midnight draws inspiration from this, but operates within Midnight’s zero-knowledge, selective-disclosure framework.&lt;/p&gt;

&lt;p&gt;Fungible tokens are a cornerstone of the blockchain ecosystem, representing digital assets that are interchangeable – much like traditional currency. On various blockchains, these tokens power a wide array of applications, from facilitating seamless transactions and enabling decentralized finance (DeFi) protocols to representing ownership in digital communities and driving the mechanics of in-game economies. &lt;/p&gt;

&lt;p&gt;Unlike unique non-fungible tokens (NFTs), the value of one fungible token is identical to another of the same type, making them ideal for use cases requiring divisibility and ease of exchange. Their widespread adoption underscores their importance in building liquid and interconnected digital economies.&lt;/p&gt;

&lt;p&gt;In this article, you'll learn about the core features of the contract, including how it manages ledger state variables, its key entry points and circuits for operations like minting, burning, and transferring tokens, and the essential safety and utility functions provided by the &lt;strong&gt;Utils&lt;/strong&gt; and &lt;strong&gt;Initializable&lt;/strong&gt; modules.&lt;br&gt;&lt;br&gt;
By understanding how these components fit together, you’ll gain insight into how the &lt;strong&gt;FungibleToken&lt;/strong&gt; contract balances fungibility, usability, and privacy, providing an essential building block for privacy-preserving DeFi, identity, and tokenized assets on Midnight.&lt;/p&gt;


&lt;h2&gt;
  
  
  &lt;strong&gt;Features of the FungibleToken Contract&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;The FungibleToken contract on Midnight utilizes ledger state variables to keep track of balances, allowances, total supply, name, symbol, and decimals. Its functionality is exposed through "circuits" (entry points) like &lt;code&gt;Mint&lt;/code&gt;, &lt;code&gt;Burn&lt;/code&gt;, &lt;code&gt;Transfer&lt;/code&gt;, &lt;code&gt;Approve&lt;/code&gt;, &lt;code&gt;TransferFrom&lt;/code&gt;, and &lt;code&gt;Initialize&lt;/code&gt;, all of which enforce specific zero-knowledge validated transitions and maintain the integrity of the token's state.&lt;/p&gt;
&lt;h3&gt;
  
  
  &lt;strong&gt;1. Ledger State Variables&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;In Compact, the contract defines a structured &lt;strong&gt;state&lt;/strong&gt; storing token balances and allowances—similar to ERC-20. The &lt;code&gt;_balances&lt;/code&gt; map keeps track of the users’ token balances and is updated when a transfer occurs. The &lt;code&gt;_allowances&lt;/code&gt; map keeps track of the permission given to specific users to spend tokens on behalf of another user:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="nx"&gt;ledger&lt;/span&gt; &lt;span class="nx"&gt;_balances&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;Map&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Either&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;ZswapCoinPublicKey&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;ContractAddress&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;Uint&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="mi"&gt;128&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="nx"&gt;ledger&lt;/span&gt; &lt;span class="nx"&gt;_allowances&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;Map&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Either&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;ZswapCoinPublicKey&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;ContractAddress&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;Map&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Either&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;ZswapCoinPublicKey&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;ContractAddress&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;Uint&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="mi"&gt;128&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These values live in the contract's ledger and are updated through transactions sent to the contract.&lt;/p&gt;

&lt;p&gt;There are other values in the ledger that are set when the contract is deployed:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="nx"&gt;ledger&lt;/span&gt; &lt;span class="nx"&gt;_totalSupply&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Uint&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="mi"&gt;128&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="nx"&gt;sealed&lt;/span&gt; &lt;span class="nx"&gt;ledger&lt;/span&gt; &lt;span class="nx"&gt;_name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Opaque&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;string&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="nx"&gt;sealed&lt;/span&gt; &lt;span class="nx"&gt;ledger&lt;/span&gt; &lt;span class="nx"&gt;_symbol&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Opaque&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;string&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="nx"&gt;sealed&lt;/span&gt; &lt;span class="nx"&gt;ledger&lt;/span&gt; &lt;span class="nx"&gt;_decimals&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Uint&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These values provide different information about the token managed by the contract, its total supply, its name, its symbol, and its decimal (for display).&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;2. Entry Points and Circuits&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;In Compact, entry points are defined as &lt;strong&gt;circuits&lt;/strong&gt; (akin to Solidity functions), each modelling a zero-knowledge validated transition. The difference between a circuit entry point and a circuit is that the entry point is callable via a transaction, while the non-entry point circuit is internal. Core circuits include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;code&gt;Mint&lt;/code&gt; / &lt;code&gt;Burn&lt;/code&gt;&lt;/strong&gt; (to mint new tokens or burn existing tokens).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;code&gt;Transfer&lt;/code&gt;&lt;/strong&gt;: to move tokens between addresses.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;code&gt;Approve&lt;/code&gt;&lt;/strong&gt;, &lt;strong&gt;&lt;code&gt;TransferFrom&lt;/code&gt;&lt;/strong&gt;: standard ERC-20-style delegation mechanisms.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;code&gt;Initialize&lt;/code&gt;&lt;/strong&gt;: via the &lt;strong&gt;Initializable&lt;/strong&gt; module for contract setup.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each circuit enforces necessary constraints — for example, ensuring sufficient balance, managing allowance decrements, and preserving total supply.&lt;/p&gt;

&lt;p&gt;In the next step of the contract lifecycle, the different metadata stored in the ledger of the contract are safely initialized.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Initialization &amp;amp; metadata&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;The following circuits define the essential setup and retrieval logic for the fungible token metadata and users’ balances, enforcing correct initialization.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;code&gt;initialize(name_, symbol_, decimals_)&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
One-time setup. Calls &lt;code&gt;Initializable_initialize()&lt;/code&gt;, then stores the (disclosed) name, symbol, and decimals. Every other public circuit asserts that the contract is initialized first.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;code&gt;name()&lt;/code&gt; / &lt;code&gt;symbol()&lt;/code&gt; / &lt;code&gt;decimals()&lt;/code&gt; / &lt;code&gt;totalSupply()&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Simple getters that first assert initialized, then return the sealed (read only) ledger values.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;code&gt;balanceOf(account)&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Safe map lookup that returns &lt;code&gt;0&lt;/code&gt; if the account isn’t present (to prevent contract failure if the key is absent).&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;The transfer family&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;FungibleToken&lt;/code&gt; contract's &lt;strong&gt;transfer&lt;/strong&gt; circuits manage token movement. Key circuits include: &lt;code&gt;transfer&lt;/code&gt; for safe user-initiated transfers, &lt;code&gt;_unsafeTransfer&lt;/code&gt; for internal token movement, &lt;code&gt;_transfer&lt;/code&gt; for administrative transfers, &lt;code&gt;_unsafeUncheckedTransfer&lt;/code&gt; for low-level token movement, and &lt;code&gt;_update&lt;/code&gt; as the central accounting function for all token operations.&lt;/p&gt;

&lt;p&gt;These are split into &lt;strong&gt;safe&lt;/strong&gt; and &lt;strong&gt;unsafe&lt;/strong&gt; variants because &lt;strong&gt;sending to contract addresses is currently disallowed&lt;/strong&gt; (until contract-to-contract interactions are supported). &lt;/p&gt;

&lt;p&gt;“Safe” circuits enforce that policy; “unsafe” ones let you bypass it—explicitly marked as dangerous in comments.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;code&gt;transfer(to, value)&lt;/code&gt; → &lt;code&gt;Boolean&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Safe user-initiated transfer: rejects if &lt;code&gt;to&lt;/code&gt; is a &lt;code&gt;ContractAddress&lt;/code&gt;. Internally, it just forwards to the unsafe variant after the check.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;code&gt;_unsafeTransfer(to, value)&lt;/code&gt; → &lt;code&gt;Boolean&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Owner is the caller (&lt;code&gt;left(ownPublicKey())&lt;/code&gt;). Moves value using the unchecked internal mover, then returns &lt;code&gt;true&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;code&gt;_transfer(from, to, value)&lt;/code&gt; → &lt;code&gt;[]&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Admin/extension hook that moves tokens &lt;strong&gt;from an arbitrary &lt;code&gt;from&lt;/code&gt;&lt;/strong&gt; (not necessarily the caller). Still enforces the “no contracts as &lt;code&gt;to&lt;/code&gt;” rule and then uses the same mover underneath.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;code&gt;_unsafeUncheckedTransfer(from, to, value)&lt;/code&gt; → &lt;code&gt;[]&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
The low-level mover checks that neither side is the zero/burn address and then delegates the actual accounting to &lt;code&gt;_update&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;&lt;code&gt;_update(from, to, value)&lt;/code&gt; → &lt;code&gt;[]&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Central accounting function&lt;/strong&gt; used by all mint/burn/transfer paths. It’s an internal circuit; it cannot be called via a transaction.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If &lt;code&gt;from&lt;/code&gt; is zero, the &lt;strong&gt;mint&lt;/strong&gt; circuit is called, it asserts no &lt;code&gt;uint128&lt;/code&gt; overflow, and increases &lt;code&gt;_totalSupply&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Else, it deducts from &lt;code&gt;from&lt;/code&gt; balance (or reverts on insufficient funds).&lt;/li&gt;
&lt;li&gt;If &lt;code&gt;to&lt;/code&gt; is zero, the &lt;strong&gt;burn&lt;/strong&gt; circuit is called, and it decreases &lt;code&gt;_totalSupply&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Else, it adds to &lt;code&gt;to&lt;/code&gt; balance.
This single function guarantees the invariants for every movement of value.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;The "transfer family" circuits ensure secure token movement, with "safe" variants disallowing transfers to contract addresses and "unsafe" variants providing lower-level control.&lt;br&gt;&lt;br&gt;
This leads us to explore how allowances function, enabling delegated token spending.&lt;/p&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;Allowances (approve / spend / transferFrom)&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;This section details the allowance mechanisms within the FungibleToken contract, which enable users to delegate spending permissions to other addresses. These circuits facilitate secure, approved transfers on behalf of an owner without directly exposing their private keys.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;code&gt;allowance(owner, spender)&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Read the nested &lt;code&gt;_allowances&lt;/code&gt; map, returning &lt;code&gt;0&lt;/code&gt; when keys are missing (no revert).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;code&gt;approve(spender, value)&lt;/code&gt; → &lt;code&gt;Boolean&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
The owner is the caller. Forwards to &lt;code&gt;_approve(owner, spender, value)&lt;/code&gt; and returns &lt;code&gt;true&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;code&gt;transferFrom(from, to, value)&lt;/code&gt; → &lt;code&gt;Boolean&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Safe delegated transfer: enforces the “no contract receiver” rule, then defers to &lt;code&gt;_unsafeTransferFrom&lt;/code&gt;. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;code&gt;_unsafeTransferFrom(from, to, value)&lt;/code&gt; → &lt;code&gt;Boolean&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
The spender is the caller. First spends allowance via &lt;code&gt;_spendAllowance(from, spender, value)&lt;/code&gt;, then moves value using &lt;code&gt;_unsafeUncheckedTransfer&lt;/code&gt;. Returns &lt;code&gt;true&lt;/code&gt;. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;code&gt;_approve(owner, spender, value)&lt;/code&gt; → &lt;code&gt;[]&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
It ensures that both the owner and the spender are valid, creates the owner’s entry in the map if needed, and then writes the allowance. (This mirrors OZ’s ERC-20 pattern of public &lt;code&gt;approve()&lt;/code&gt; → internal &lt;code&gt;_approve()&lt;/code&gt;.) &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;code&gt;_spendAllowance(owner, spender, value)&lt;/code&gt; → &lt;code&gt;[]&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
It deducts from the allowance unless it’s “infinite.” The implementation treats &lt;strong&gt;&lt;code&gt;MAX_UINT128&lt;/code&gt;&lt;/strong&gt; as infinite: if &lt;code&gt;currentAllowance == MAX&lt;/code&gt;, it doesn’t decrement; otherwise, it asserts &lt;code&gt;currentAllowance ≥ value&lt;/code&gt; and writes back &lt;code&gt;currentAllowance - value&lt;/code&gt;.&lt;br&gt;&lt;br&gt;
This is important because it supports “no-friction approvals” by letting apps set MAX once. &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So, we just covered how allowances let people delegate token spending—basically, giving others permission to move their tokens. Up next, we'll dive into how we create and delete tokens in the contract.&lt;/p&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;Minting and burning&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Here's how the FungibleToken contract handles making and destroying tokens. We'll dive into the &lt;code&gt;_mint&lt;/code&gt; and &lt;code&gt;_burn&lt;/code&gt; functions, showing what they do and how they link up with the main accounting system.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;code&gt;_mint(account, value)&lt;/code&gt;&lt;/strong&gt; (safe) → &lt;code&gt;[]&lt;/code&gt;&lt;br&gt;&lt;br&gt;
It forbids minting &lt;strong&gt;to&lt;/strong&gt; a contract address (same contract-to-contract restriction), then forwards to &lt;code&gt;_unsafeMint&lt;/code&gt;. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;code&gt;_unsafeMint(account, value)&lt;/code&gt;&lt;/strong&gt; → &lt;code&gt;[]&lt;/code&gt;&lt;br&gt;&lt;br&gt;
It validates the receiver’s address, then calls &lt;code&gt;_update(burnAddress(), account, value)&lt;/code&gt;—i.e., mint is modelled as a transfer &lt;strong&gt;from&lt;/strong&gt; the burn/zero address. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;code&gt;_burn(account, value)&lt;/code&gt;&lt;/strong&gt; → &lt;code&gt;[]&lt;/code&gt;&lt;br&gt;&lt;br&gt;
It validates the sender’s address, then calls &lt;code&gt;_update(account, burnAddress(), value)&lt;/code&gt;—i.e., burn is a transfer &lt;strong&gt;to&lt;/strong&gt; the burn/zero address.&lt;br&gt;&lt;br&gt;
&lt;em&gt;Note:&lt;/em&gt; The actual notion of “zero/burn” address is standardized in the Utils module; you can also see helpers like &lt;code&gt;Utils_isKeyOrAddressZero&lt;/code&gt; and &lt;code&gt;Utils_isContractAddress&lt;/code&gt;. &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Because mint and burn also route through &lt;code&gt;_update&lt;/code&gt;, &lt;strong&gt;total supply is adjusted in exactly one place,&lt;/strong&gt; and the same safety checks apply across all flows (including the &lt;code&gt;uint128&lt;/code&gt; overflow check on mint). &lt;/p&gt;

&lt;p&gt;The mint and burn circuits, by using the &lt;code&gt;_update&lt;/code&gt; function, make sure the total supply adjustments are always consistent and that all token flows get the same safety checks.&lt;br&gt;&lt;br&gt;
Now, let's dive into the extra safety and utility stuff that the &lt;code&gt;Utils&lt;/code&gt; and &lt;code&gt;Initializable&lt;/code&gt; modules bring to the table.&lt;/p&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;Safety &amp;amp; utility glue (from &lt;code&gt;Utils&lt;/code&gt; and &lt;code&gt;Initializable&lt;/code&gt;)&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;This section explores how the &lt;code&gt;Utils&lt;/code&gt; and &lt;code&gt;Initializable&lt;/code&gt; modules provide essential safeguards and helpful functionalities. These components are vital for ensuring the contract's integrity and enabling secure, well-managed operations.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Initialization guards&lt;/strong&gt;: The &lt;code&gt;Initializable_initialize&lt;/code&gt; and &lt;code&gt;Initializable_assertInitialized&lt;/code&gt; functions serve as crucial initialization guards within the &lt;code&gt;Initializable&lt;/code&gt; contract. These safeguards ensure that a contract's state is properly set up only once and that subsequent operations only proceed if the contract has been correctly initialized. Every circuit that interacts with or modifies the contract's state is designed to invoke the &lt;code&gt;assert&lt;/code&gt; function, reinforcing the integrity of the initialization process. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Address helpers&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;Utils_isContractAddress(either)&lt;/code&gt; distinguishes user keys from contract addresses.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;Utils_isKeyOrAddressZero(either)&lt;/code&gt; detects the zero/burn address used in &lt;code&gt;_update&lt;/code&gt;, &lt;code&gt;_unsafeUncheckedTransfer&lt;/code&gt;, etc.
These support the temporary “no contract receiver” policy and zero-address checks. &lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;The &lt;strong&gt;Utils&lt;/strong&gt; and &lt;strong&gt;Initializable&lt;/strong&gt; modules provide crucial safety and utility functions, ensuring the contract's proper setup and secure operation. Now, let's look at how all these different parts of the &lt;strong&gt;FungibleToken&lt;/strong&gt; contract work together.&lt;/p&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;How the pieces fit together&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;This part shows how everything in the FungibleToken contract is hooked up. Whether it's you sending tokens, someone else doing it for you, or tokens being created or destroyed, it all funnels through a few key functions and ultimately lands in the main &lt;code&gt;_update&lt;/code&gt; function to keep track of everything.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;User transfer:&lt;br&gt;&lt;br&gt;
&lt;code&gt;transfer&lt;/code&gt; → &lt;em&gt;(safe check)&lt;/em&gt; → &lt;code&gt;_unsafeTransfer&lt;/code&gt; → &lt;code&gt;_unsafeUncheckedTransfer&lt;/code&gt; → &lt;code&gt;_update&lt;/code&gt; (balances/supply) &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Delegated transfer:&lt;br&gt;&lt;br&gt;
&lt;code&gt;transferFrom&lt;/code&gt; → &lt;em&gt;(safe check)&lt;/em&gt; → &lt;code&gt;_unsafeTransferFrom&lt;/code&gt; → &lt;code&gt;_spendAllowance&lt;/code&gt; → &lt;code&gt;_unsafeUncheckedTransfer&lt;/code&gt; → &lt;code&gt;_update&lt;/code&gt; &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Mint/Burn:&lt;br&gt;&lt;br&gt;
&lt;code&gt;_mint/_unsafeMint&lt;/code&gt; or &lt;code&gt;_burn&lt;/code&gt; → &lt;code&gt;_update&lt;/code&gt; (with zero/burn address on one side) &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This section illustrates how various token operations, from user transfers to minting and burning, ultimately funnel through the central &lt;code&gt;_update&lt;/code&gt; function for consistent accounting. Now, let's summarize the key takeaways of the &lt;strong&gt;FungibleToken&lt;/strong&gt; contract on Midnight.&lt;/p&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;Conclusion&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;The &lt;strong&gt;FungibleToken&lt;/strong&gt; Compact contract on Midnight is a privacy-aware reimagining of the ERC-20 standard. It maintains the familiar token interfaces—balances, transfers, approvals—but encodes them as ZK-validated circuits within Compact, enabling private, verifiable execution. The contract’s state and logic are shielded by design, exposing only proofs rather than raw data to the blockchain. &lt;/p&gt;

&lt;p&gt;The ERC-20 standard revolutionized the crypto landscape by providing a common framework for creating and managing digital assets, fostering interoperability, and accelerating the growth of decentralized applications. For Midnight, an ERC-20-based token is crucial as it leverages this established standard while integrating ZK-privacy, offering a familiar yet enhanced experience for developers and users seeking both functionality and confidentiality.&lt;/p&gt;

&lt;p&gt;This model contrasts sharply with ERC-20 on Ethereum, where all token movements and balances are fully transparent. Here, Midnight allows selective disclosure: users and applications choose what to reveal. The &lt;strong&gt;FungibleToken&lt;/strong&gt; contract thus balances fungibility, usability, and privacy—providing an essential building block for privacy-preserving DeFi, identity, and tokenized assets on Midnight.&lt;/p&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;Links&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Delve deeper into the code, contracts, and comprehensive documentation to enhance your understanding and development skills. These resources are invaluable for building robust and innovative solutions.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;FungibleToken contract: &lt;a href="https://github.com/OpenZeppelin/compact-contracts/blob/main/contracts/fungibleToken/src/FungibleToken.compact" rel="noopener noreferrer"&gt;FungibleToken.compact on Github&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;OpenZeppelin documentation: &lt;a href="https://docs.openzeppelin.com/contracts-compact/0.0.1/fungibletoken" rel="noopener noreferrer"&gt;docs.openzeppelin.com&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;ERC20 standard: &lt;a href="https://ethereum.org/en/developers/docs/standards/tokens/erc-20/" rel="noopener noreferrer"&gt;ethereum.org&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Midnight docs: &lt;a href="https://docs.midnight.network/" rel="noopener noreferrer"&gt;Midnight Developer Documentation&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Do you have any questions?: &lt;a href="https://forum.midnight.network/" rel="noopener noreferrer"&gt;Midnight Forum&lt;/a&gt; &lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>midnight</category>
      <category>compact</category>
    </item>
    <item>
      <title>Learning Web3 from the Ground Up: Understanding Ethereum</title>
      <dc:creator>Samantha Holstine</dc:creator>
      <pubDate>Fri, 25 Jul 2025 15:09:00 +0000</pubDate>
      <link>https://dev.to/devsofmidnight/learning-web3-from-the-ground-up-understanding-ethereum-2hlb</link>
      <guid>https://dev.to/devsofmidnight/learning-web3-from-the-ground-up-understanding-ethereum-2hlb</guid>
      <description>&lt;p&gt;This past week, I started the SheFi course— a program designed to help women dive deeper into Web3 and decentralized finance. One of the first topics it covered was Ethereum: what it is, why it matters, and how it fits into the broader decentralized ecosystem.&lt;/p&gt;

&lt;p&gt;To build on what I learned there, I read two excellent overviews: &lt;a href="https://medium.com/the-coinbase-blog/a-beginners-guide-to-ethereum-46dd486ceecf" rel="noopener noreferrer"&gt;“A Beginner’s Guide to Ethereum” from Coinbase&lt;/a&gt; and &lt;a href="https://medium.com/@oneofthemanymatts/getting-up-to-speed-on-ethereum-63ed28821bbe" rel="noopener noreferrer"&gt;“Getting Up to Speed on Ethereum” by Matt&lt;/a&gt;. Both helped frame Ethereum not just as a cryptocurrency, but as a foundational platform for Web3 applications. Here’s what stood out and why Ethereum remains vital in a rapidly evolving cryptocurrency ecosystem.&lt;/p&gt;

&lt;h2&gt;
  
  
  Ethereum in a Nutshell
&lt;/h2&gt;

&lt;p&gt;Ethereum is a decentralized computing platform. Think of it like a global computer that anyone can access, but no single person or organization controls it. This is possible because Ethereum is powered by a blockchain—a network of nodes around the world that maintain and validate a shared record of activity. What makes Ethereum special is that it doesn’t just store transactions; it can also run applications. These apps are powered by smart contracts, which are programs deployed to the blockchain that execute exactly as written.&lt;/p&gt;

&lt;p&gt;The Ethereum network is designed to be open, programmable, and permissionless. That means anyone can build on it, and no one needs approval to use it. This structure has enabled Ethereum to become the foundation for a wide range of decentralized applications (dApps), including financial tools such as lending protocols and stablecoins, as well as NFT marketplaces and decentralized identity systems.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Ethereum Matters
&lt;/h2&gt;

&lt;p&gt;Ethereum matters because it transforms the internet from a read-write platform into a read-write-execute environment. That is, it enables not just the sharing of information, but also the execution of logic—without relying on centralized intermediaries. This shift opens the door to creating systems that are more transparent, resilient, and accessible.&lt;/p&gt;

&lt;p&gt;One of Ethereum’s most significant breakthroughs is that it allows developers to write and deploy their own logic onto the network through smart contracts. These contracts can define rules, manage value, and interact with other contracts—all while being trustless and tamper-proof. Once deployed, smart contracts can’t be changed or censored, which means users can interact with them without worrying about backend changes or manipulation.&lt;/p&gt;

&lt;h2&gt;
  
  
  Ether: The Fuel of the Ethereum Network
&lt;/h2&gt;

&lt;p&gt;Ether (ETH) is the native currency of Ethereum. While many people think of ETH primarily as a cryptocurrency—something you can buy, sell, or hold—its most important role as the fuel for computation. Every operation on the Ethereum network costs gas, and ETH is what you use to pay for it. This is a crucial aspect of Ethereum’s security and incentive structure, ensuring that resources are utilized responsibly and the network remains resilient to spam.&lt;/p&gt;

&lt;p&gt;When you send a transaction, deploy a smart contract, or interact with a dApp, you’re paying for the network to process that request. The more complex the operation, the more gas it consumes. Gas prices fluctuate based on network demand, and users can choose how much to pay to incentivize faster confirmation. This dynamic creates a market for block space, encouraging developers to write more efficient code.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Power of Smart Contracts
&lt;/h2&gt;

&lt;p&gt;Smart contracts are at the heart of what makes Ethereum powerful. These are self-executing programs that live on the blockchain and enforce rules automatically. You don’t need to trust a company or a person; you can trust the code. Smart contracts enable a wide range of use cases, including lending platforms like Aave, decentralized exchanges like Uniswap, and even games like Axie Infinity.&lt;/p&gt;

&lt;p&gt;Once a smart contract is deployed, it’s public and verifiable. Anyone can inspect the code, interact with it, and build on top of it. This openness fosters a culture of composability—developers can plug into existing contracts, remix them, or build entirely new systems that work together. This is why Ethereum is often referred to as a “LEGO set for financial and digital tools.”&lt;/p&gt;

&lt;h2&gt;
  
  
  Ethereum Today and Tomorrow
&lt;/h2&gt;

&lt;p&gt;Ethereum has come a long way since its launch in 2015. It’s no longer just a niche experiment; it’s the most widely used smart contract platform in the world. However, with that growth has come challenges. Network congestion and high gas fees have made it difficult for some users to interact with dApps affordably. To address these issues, Ethereum has undergone significant upgrades, most notably the transition from proof-of-work to proof-of-stake, known as “The Merge.”&lt;/p&gt;

&lt;p&gt;Proof-of-stake is a consensus mechanism that allows Ethereum to secure the network using validators who lock up ETH rather than relying on energy-intensive mining. This shift has dramatically reduced Ethereum’s energy usage and paved the way for future scaling efforts, such as sharding and rollups. Rollups are a technique for batching many transactions into a single proof, which can then be submitted to the Ethereum mainnet. This helps scale the network without sacrificing security or decentralization.&lt;/p&gt;

&lt;p&gt;The Ethereum ecosystem is also growing through layer 2 networks, which are built on top of Ethereum and handle transactions off-chain while still relying on Ethereum for settlement and security. Projects like Arbitrum, Optimism, and zkSync are working to make Ethereum faster and cheaper for everyday users.&lt;/p&gt;

&lt;h2&gt;
  
  
  How Ethereum Connects with Midnight
&lt;/h2&gt;

&lt;p&gt;While Ethereum serves as the foundational smart contract platform for much of Web3, Midnight is designed to complement and extend its capabilities—especially in terms of privacy.&lt;/p&gt;

&lt;p&gt;In practical terms, this means that developers who are comfortable with the Ethereum ecosystem —its wallets, development environments, and smart contract models—can interact with Midnight using similar patterns. For example, Midnight supports a Solidity-like programming approach through its Compact smart contract language, which compiles to verifiable circuits that enforce privacy constraints. This allows developers to build private versions of applications, such as voting systems, token transfers, and identity verification, that would typically be public on the Ethereum blockchain.&lt;/p&gt;

&lt;p&gt;Ethereum offers programmability and decentralization, but by default, all on-chain transactions are transparent. Midnight fills in the missing privacy layer. You could imagine a workflow where public assets and smart contracts live on Ethereum, but sensitive data or confidential logic is handled by Midnight—bridging the two networks for richer, privacy-preserving applications.&lt;/p&gt;

&lt;p&gt;Together, Ethereum and Midnight can be seen as complementary parts of a broader decentralized stack: Ethereum provides openness and composability, while Midnight adds selective disclosure and private computation, enabling developers to build secure and compliant applications in ways that Ethereum alone can’t.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Ethereum isn’t just a cryptocurrency—it’s a platform for building a new kind of internet. By combining programmable logic with decentralized infrastructure, Ethereum enables applications that are open, transparent, and user-owned. It’s the foundation of decentralized finance (DeFi), non-fungible tokens (NFTs), and numerous experiments in online interaction.&lt;/p&gt;

&lt;p&gt;For me, starting with SheFi and reading through these resources helped ground my understanding of what Ethereum is and why it matters. It’s not just about buying coins—it’s about reshaping how we think about trust, ownership, and value in a digital world.&lt;/p&gt;

&lt;p&gt;I’ll be back next week as I continue diving into the core building blocks of Web3. If you’re just starting out too, I highly recommend giving &lt;a href="https://medium.com/the-coinbase-blog/a-beginners-guide-to-ethereum-46dd486ceecf" rel="noopener noreferrer"&gt;Coinbase’s primer&lt;/a&gt; and &lt;a href="https://medium.com/@oneofthemanymatts/getting-up-to-speed-on-ethereum-63ed28821bbe" rel="noopener noreferrer"&gt;Matt’s breakdown&lt;/a&gt; a read.  &lt;/p&gt;

</description>
      <category>midnightnetwork</category>
      <category>web3</category>
      <category>beginners</category>
      <category>blockchain</category>
    </item>
    <item>
      <title>Learning Web3 From the Ground Up: What Are Zero-Knowledge Proofs (ZKPs)?</title>
      <dc:creator>Samantha Holstine</dc:creator>
      <pubDate>Mon, 21 Jul 2025 17:20:09 +0000</pubDate>
      <link>https://dev.to/devsofmidnight/learning-web3-from-the-ground-up-what-are-zero-knowledge-proofs-zkps-2fb3</link>
      <guid>https://dev.to/devsofmidnight/learning-web3-from-the-ground-up-what-are-zero-knowledge-proofs-zkps-2fb3</guid>
      <description>&lt;p&gt;As I continue exploring the foundations of Web3, last week I focused on &lt;a href="https://docs.midnight.network/blog/web3-intro-smart-contracts-and-compact" rel="noopener noreferrer"&gt;Smart Contracts and Compact&lt;/a&gt;—Midnight’s purpose-built smart contract language. Together, these two elements form the foundation for defining and enforcing logic in privacy-preserving applications.&lt;/p&gt;

&lt;p&gt;But logic alone isn’t enough in a decentralized system, especially when privacy is a priority. That’s where zero-knowledge proofs (ZKPs) come in.&lt;/p&gt;

&lt;p&gt;ZKPs enable the verification of a statement's truth without revealing the underlying justification. They let applications enforce smart contract rules while keeping sensitive data private—an essential capability for building systems that balance trust, utility, and confidentiality.&lt;/p&gt;

&lt;p&gt;In this post, I’ll break down what zero-knowledge proofs are, how they work, and how Midnight uses them to support privacy, compliance, and secure dApp development.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Are Zero-Knowledge Proofs?
&lt;/h2&gt;

&lt;p&gt;A zero-knowledge proof allows someone (the prover) to prove to another party (the verifier) that a specific statement is true, without revealing any additional information beyond the fact itself.&lt;/p&gt;

&lt;p&gt;Think of it like this: instead of handing over your complete ID to prove you're over 18, you could use a ZKP to prove you're above the age threshold, without disclosing your exact birthday, name, or ID number.&lt;/p&gt;

&lt;p&gt;This cryptographic technique is built on three foundational properties:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Completeness: If the statement is true, the prover can convince the verifier that it is true.
&lt;/li&gt;
&lt;li&gt;Soundness: If the statement is false, no dishonest prover can convince the verifier that it is true.
&lt;/li&gt;
&lt;li&gt;Zero-knowledge: The verifier learns nothing beyond the truth of the statement.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Interactive vs. Non-Interactive Proofs
&lt;/h2&gt;

&lt;p&gt;Early ZKPs required a back-and-forth exchange between prover and verifier—these are called interactive proofs. But in decentralized systems, interaction isn’t always feasible. That’s where non-interactive proofs come in.&lt;/p&gt;

&lt;p&gt;Non-interactive ZKPs let a prover generate a single proof that anyone can verify at any time, with no additional input. Protocols like zk-SNARKs and zk-STARKs make this possible, often using techniques like the &lt;a href="https://www.zkdocs.com/docs/zkdocs/protocol-primitives/fiat-shamir/" rel="noopener noreferrer"&gt;Fiat–Shamir heuristic&lt;/a&gt; to simulate interaction using cryptographic hashes.&lt;/p&gt;

&lt;p&gt;This makes non-interactive ZKPs ideal for blockchains, where proofs need to be public, reusable, and verifiable by anyone.&lt;/p&gt;

&lt;h2&gt;
  
  
  Types of Zero-Knowledge Proof Systems
&lt;/h2&gt;

&lt;p&gt;Different ZKP systems come with different tradeoffs in terms of size, speed, and trust requirements:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Groth16 (zk-SNARK): Very small proofs, fast verification, but requires a trusted setup per circuit.
&lt;/li&gt;
&lt;li&gt;Plonk (zk-SNARK): Slightly larger proofs, slower verification, but only needs a one-time universal setup.
&lt;/li&gt;
&lt;li&gt;Bulletproofs: No trusted setup, but proof size grows with complexity.
&lt;/li&gt;
&lt;li&gt;zk-STARKs: Transparent (no trusted setup), post-quantum secure, but with large proof sizes.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Midnight utilizes a Plonk-derived system called &lt;a href="https://electriccoin.co/blog/explaining-halo-2/" rel="noopener noreferrer"&gt;Halo 2&lt;/a&gt;, which supports recursive proofs and eliminates trusted setup in specific configurations, making it an ideal choice for privacy-preserving dApps that require both flexibility and scalability.&lt;/p&gt;

&lt;h2&gt;
  
  
  How Do ZKPs Work?
&lt;/h2&gt;

&lt;p&gt;The idea behind zero-knowledge proofs might seem almost magical: one party (the prover) can prove to another (the verifier) that a statement is true, without revealing the &lt;em&gt;why&lt;/em&gt;. But this is no sleight of hand—it’s grounded in rigorous cryptography and clever use of mathematical structures.&lt;/p&gt;

&lt;p&gt;At the heart of a ZKP is a “statement” that the prover wants to validate without revealing the underlying secret. That statement gets encoded into a circuit, which represents the logical rules or constraints that need to be satisfied. The prover then uses a special cryptographic key, known as the proving key, along with the secret input (called the witness), to generate a succinct proof. The verifier can then check this proof using a verifying key, confirming the rules were followed, without ever seeing the private input.&lt;/p&gt;

&lt;p&gt;This process makes ZKPs ideal for privacy-preserving smart contracts. In traditional systems, all data must be made public to verify that an action is legitimate. But with ZKPs, we can shift the trust model: rather than inspecting the data itself, the verifier checks a cryptographic proof that the data complies with the rules.&lt;/p&gt;

&lt;p&gt;Midnight takes this further by embedding ZKPs directly into the structure and execution of smart contracts. In Midnight, the verification key of a compiled Compact smart contract becomes the identity of that contract on-chain. When users interact with it, they’re not just calling a function—they’re submitting proof that they've complied with the logic defined by that contract, without revealing their inputs.&lt;/p&gt;

&lt;p&gt;Here's a high-level flow of how this works:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Setup: A circuit is created. A proving key and a verifying key are generated.
&lt;/li&gt;
&lt;li&gt;Proof Generation: The prover uses their secret (a witness) and the proving key to generate a cryptographic proof.
&lt;/li&gt;
&lt;li&gt;Verification: The verifier uses the verifying key and the proof to confirm the statement is true, without learning anything else.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This process ensures that the smart contract logic is executed exactly as intended, without exposing the underlying data.&lt;/p&gt;

&lt;h2&gt;
  
  
  Midnight’s Approach to ZKPs
&lt;/h2&gt;

&lt;p&gt;Midnight utilizes zero-knowledge proofs not only for theoretical privacy but also to enable real-world compliance and usability. Let’s walk through a few key elements of how ZKPs show up on the Midnight network:&lt;/p&gt;

&lt;h3&gt;
  
  
  Confidential Transactions
&lt;/h3&gt;

&lt;p&gt;Users can transfer assets on Midnight without revealing the sender, receiver, or amount. ZKPs are used to prove that a transaction is valid (i.e., no double spending, balances add up) without revealing specific details. This ensures both privacy and integrity.&lt;/p&gt;

&lt;h3&gt;
  
  
  Selective Disclosure and Compliance
&lt;/h3&gt;

&lt;p&gt;Midnight supports “shielded” and “unshielded” data modes. You can keep your transaction data private by default, but also selectively disclose specific information (via a ZKP or viewing key) to a regulator, auditor, or another authorized party.&lt;/p&gt;

&lt;p&gt;This enables use cases like “prove I’m a citizen of Country X” or “prove I’m not sanctioned” without revealing your complete identity or wallet history.&lt;/p&gt;

&lt;p&gt;For more information about selective disclosure, read my overview &lt;a href="https://docs.midnight.network/blog/web3-intro-selective-disclosure" rel="noopener noreferrer"&gt;here&lt;/a&gt;!&lt;/p&gt;

&lt;h3&gt;
  
  
  Decentralized Identity
&lt;/h3&gt;

&lt;p&gt;ZKPs are key to proving facts about identity without revealing full credentials. Midnight supports workflows like proving KYC status (“A trusted provider has verified me”) using a proof, not a document.&lt;/p&gt;

&lt;p&gt;This allows users to interact with services that require identity checks—such as exchanges or marketplaces—without exposing sensitive personal data.&lt;/p&gt;

&lt;h3&gt;
  
  
  Scalability via Recursive Proofs
&lt;/h3&gt;

&lt;p&gt;ZKPs also compress large computations into tiny proofs. That makes them ideal for batching transactions or reducing blockchain bloat. Midnight’s use of recursive proofs allows smart contracts and transactions to scale more efficiently than traditional blockchains.&lt;/p&gt;

&lt;h2&gt;
  
  
  Real-World Use Cases on Midnight
&lt;/h2&gt;

&lt;p&gt;Some examples of ZKP-powered applications on Midnight are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Voting: Prove you’re eligible to vote and that your vote was counted, without revealing your identity or your vote.
&lt;/li&gt;
&lt;li&gt;Whistleblowing: Submit a report anonymously, proving only that you’re authorized (e.g., an employee).
&lt;/li&gt;
&lt;li&gt;Private Asset Swaps: Use Midnight’s Zswap to exchange tokens confidentially without revealing terms or participants.
&lt;/li&gt;
&lt;li&gt;KYC Onboarding: Prove compliance status to a platform or dApp without exposing documents.
&lt;/li&gt;
&lt;li&gt;Tokenized Real-World Assets: Keep ownership private while maintaining auditable transfer records. These use cases show how ZKPs on Midnight turn privacy into a practical feature, not just a theoretical promise. They lay the groundwork for a future where developers can build secure, compliant, and data-protecting applications by default.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Zero-knowledge proofs bring trust to trustless systems. They make it possible to prove something is true—like compliance with laws, asset ownership, or user eligibility—without revealing any sensitive details.&lt;/p&gt;

&lt;p&gt;Midnight makes ZKPs more than theoretical. They’re deeply integrated into its smart contract architecture, transaction model, and developer tooling. Paired with the Compact language (covered in last week’s post), they create a robust foundation for building privacy-first decentralized applications.&lt;/p&gt;

&lt;p&gt;If you’re interested in learning more, check out:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://docs.midnight.network/academy/module-3" rel="noopener noreferrer"&gt;Midnight Developer Academy Module 3&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.midnight.network/learn/understanding-midnights-technology/zero-knowledge-proofs" rel="noopener noreferrer"&gt;Zero-Knowledge Proofs&lt;/a&gt; in the &lt;a href="https://docs.midnight.network/" rel="noopener noreferrer"&gt;Midnight Docs&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And if you’ve come across excellent ZKP explanations or tutorials, I’d love to hear about them—please share your favorites!&lt;/p&gt;

&lt;p&gt;See you next week as I continue to unpack the core ideas that power privacy in Web3!  &lt;/p&gt;

</description>
      <category>midnightnetwork</category>
      <category>web3</category>
      <category>beginners</category>
      <category>blockchain</category>
    </item>
    <item>
      <title>Learning Web3 from the Ground Up: Smart Contracts and the Compact Language</title>
      <dc:creator>Samantha Holstine</dc:creator>
      <pubDate>Fri, 20 Jun 2025 16:39:59 +0000</pubDate>
      <link>https://dev.to/devsofmidnight/learning-web3-from-the-ground-up-smart-contracts-and-the-compact-language-1meb</link>
      <guid>https://dev.to/devsofmidnight/learning-web3-from-the-ground-up-smart-contracts-and-the-compact-language-1meb</guid>
      <description>&lt;p&gt;As I continue my journey through the world of Web3, I’ve been digging into the building blocks that make privacy-first platforms like Midnight possible (you can catch up on previous posts in the Midnight Dev Diaries!). This week, I focused on two foundational pieces that go hand in hand: smart contracts on Midnight and the Compact language that powers them.&lt;/p&gt;

&lt;p&gt;Smart contracts aren’t new to blockchain, but Midnight’s approach is unique. Instead of executing code directly on-chain, Midnight uses smart contracts to define rules that are enforced off-chain through zero-knowledge proofs. At the center of this system is &lt;a href="https://docs.midnight.network/develop/reference/compact/lang-ref" rel="noopener noreferrer"&gt;Compact&lt;/a&gt;—a purpose-built language designed to make writing these privacy-preserving contracts both secure and practical.&lt;/p&gt;

&lt;p&gt;To better understand how this works in practice, I also worked through &lt;a href="https://docs.midnight.network/academy/module-2" rel="noopener noreferrer"&gt;Module 2 of the Midnight Developer Academy&lt;/a&gt;, which covers key concepts such as contract structure, circuit types, and the relationship between the contract and the external logic that executes it.&lt;/p&gt;

&lt;p&gt;In this post, I’ll break down what makes smart contracts on Midnight different, how Compact is structured, and how the two work together to enable provable logic without exposing sensitive data.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Is a Smart Contract on Midnight?
&lt;/h2&gt;

&lt;p&gt;At a high level, a smart contract is an autonomous program stored on the blockchain. It defines rules for interaction, checks that those rules are met, and records results—all without needing a trusted third party to enforce them.&lt;/p&gt;

&lt;p&gt;But Midnight isn’t just any blockchain. It’s a privacy-first platform built with compliance in mind, and that means its smart contracts need to do more than just run logic. They need to protect private data, enable selective disclosure, and uphold security and trust even in adversarial environments.&lt;/p&gt;

&lt;p&gt;That’s where Compact comes in—a custom domain-specific language explicitly designed to write smart contracts on Midnight.&lt;/p&gt;

&lt;p&gt;Instead of executing logic directly on-chain like many traditional smart contracts, Compact contracts define the logic to be proven, not the execution environment itself. The contract encodes the rules that must be followed, which are then used as the foundation for a zero-knowledge proof. The actual execution—like processing a transaction, generating a credential, or submitting a vote—happens externally, often in a DApp, backend service, or API.&lt;/p&gt;

&lt;p&gt;That external system runs the necessary logic and &lt;strong&gt;proves&lt;/strong&gt; it followed the contract’s rules by generating a cryptographic proof. The blockchain doesn’t need to know the details—it just verifies that the proof is valid. This separation is what makes Midnight’s model both scalable and privacy-preserving.&lt;/p&gt;

&lt;p&gt;In other words: the contract sets the rules, your app runs the logic, and the blockchain verifies the outcome, without ever seeing the sensitive inputs.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Is Compact?
&lt;/h2&gt;

&lt;p&gt;Compact is a statically typed, privacy-focused smart contract language tailored to the unique goals of the Midnight network. If you've worked with JavaScript or TypeScript before, you'll find Compact refreshingly approachable. It’s a domain-specific language (DSL) designed to define zero-knowledge proof logic using statically typed circuits that map to off-chain computations. But don’t let the simple syntax fool you—Compact is engineered for privacy-preserving computation using zero-knowledge proofs (ZKPs) under the hood. (For a more technical deep dive into compact, check out part 1 of Kevin Millikin's Compact Deep Dive &lt;a href="https://docs.midnight.network/blog/compact" rel="noopener noreferrer"&gt;here&lt;/a&gt;!)&lt;/p&gt;

&lt;p&gt;A Compact contract is made up of three core components:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Ledger&lt;/strong&gt;: The public, on-chain state of the contract.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Circuits&lt;/strong&gt;: Off-chain logic that can manipulate data, produce proofs, and interact with the ledger.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Witnesses&lt;/strong&gt;: Privately held data, only known to the entity executing the contract.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Compact also supports &lt;a href="https://docs.midnight.network/develop/reference/compact/explicit_disclosure#conclusion" rel="noopener noreferrer"&gt;explicit disclosure&lt;/a&gt;, meaning developers can define exactly what data gets revealed (and to whom). This provides fine-grained control over what is visible on-chain and what remains private, essential for use cases such as private asset transfers, age-gated access, or confidential voting.&lt;/p&gt;

&lt;h2&gt;
  
  
  Circuits and Privacy
&lt;/h2&gt;

&lt;p&gt;One of the most essential takeaways from Module 2 of the Midnight Developer Academy is how circuits work. In Compact, circuits are the functions that users or systems can call to trigger actions. But unlike Web2 APIs or EVM contract functions, these circuits don’t execute logic directly on the blockchain. Instead, they run off-chain and generate zero-knowledge proofs that the logic was followed.&lt;/p&gt;

&lt;p&gt;In practice, that means:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The contract logic is public.
&lt;/li&gt;
&lt;li&gt;The data used during execution is private.
&lt;/li&gt;
&lt;li&gt;The outcome of the logic (e.g., “the rules were followed”) is publicly verifiable using a proof.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is where Midnight’s model shows its strength—users can prove they followed the rules without revealing the exact data that triggered the result. Think “I proved I’m eligible to vote” without revealing who I am or what I voted for.&lt;/p&gt;

&lt;h2&gt;
  
  
  From Theory to Practice
&lt;/h2&gt;

&lt;p&gt;In traditional smart contract platforms, everything you do is public by default: data, logic, inputs, outputs. That’s useful for transparency, but it's not always practical, especially for sensitive use cases like health data, financial records, or identity verification.&lt;/p&gt;

&lt;p&gt;Midnight flips that default. Privacy is built in, and developers opt into disclosure only when it’s needed.&lt;/p&gt;

&lt;p&gt;Some examples of what you might build with Compact on Midnight:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A voting system where only the outcome is public.
&lt;/li&gt;
&lt;li&gt;An access control system that verifies user attributes without revealing identities.
&lt;/li&gt;
&lt;li&gt;A token transfer app that hides amounts or senders while still allowing public verification.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Smart contracts are the foundation of decentralized applications—but at Midnight, they’re built for a privacy-first future. Instead of executing every piece of logic on-chain, Midnight separates the contract's logic from its execution. With Compact, developers define the rules of a zero-knowledge proof system, enabling applications to prove facts without exposing sensitive data. It’s a practical shift toward secure, scalable, and user-protective Web3 design.&lt;/p&gt;

&lt;p&gt;At Midnight, this isn’t just a theoretical improvement—it’s core to how the platform operates. Compact smart contracts let developers write verifiable, auditable logic while keeping inputs and execution off-chain. Combined with ZKPs and shielded transactions, they create an infrastructure that supports real-world use cases without compromising on privacy or decentralization.&lt;/p&gt;

&lt;p&gt;If you're learning how to build smart contracts in Web3—or just curious how these pieces fit together—I highly recommend diving into &lt;a href="https://docs.midnight.network/academy/module-2" rel="noopener noreferrer"&gt;Module 2 of the Midnight Developer Academy&lt;/a&gt; and reviewing the &lt;a href="https://docs.midnight.network/develop/reference/compact/lang-ref" rel="noopener noreferrer"&gt;Compact Language Reference&lt;/a&gt;. These resources break down the concepts step by step and show how Midnight’s architecture turns advanced cryptography into practical developer tools.&lt;/p&gt;

&lt;p&gt;I’ll be back next week with more insights as I continue to unpack the pieces that make privacy-first systems work in the decentralized world.  &lt;/p&gt;

</description>
      <category>midnightnetwork</category>
      <category>blockchain</category>
      <category>web3</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Learning Web3 From the Ground Up: Understanding Selective Disclosure</title>
      <dc:creator>Samantha Holstine</dc:creator>
      <pubDate>Fri, 13 Jun 2025 20:44:47 +0000</pubDate>
      <link>https://dev.to/devsofmidnight/learning-web3-from-the-ground-up-understanding-selective-disclosure-4n7</link>
      <guid>https://dev.to/devsofmidnight/learning-web3-from-the-ground-up-understanding-selective-disclosure-4n7</guid>
      <description>&lt;p&gt;As I delve deeper into the world of Web3, I've been working my way through foundational concepts to have a better understanding of the industry (check out my last five posts on the &lt;a href="https://docs.midnight.network/blog" rel="noopener noreferrer"&gt;Midnight Dev Diaries&lt;/a&gt;!). This week, I dove into one of the most practical and privacy-focused ideas I’ve encountered so far: &lt;strong&gt;selective disclosure&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Selective disclosure is more than just a technical feature—it’s the working expression of a broader idea known as &lt;strong&gt;rational privacy&lt;/strong&gt;. It allows individuals to prove or reveal only what’s necessary in a given interaction, keeping everything else private. In an ecosystem where trust must be earned without a central authority, this ability to protect personal data while still meeting legal or operational requirements is critical.&lt;/p&gt;

&lt;p&gt;This post examines how selective disclosure operates, its benefits, and how platforms like Midnight are implementing it through privacy-first smart contracts.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Is Selective Disclosure?
&lt;/h2&gt;

&lt;p&gt;In the Web3 world, privacy doesn’t mean keeping everything secret—it means sharing only what’s necessary. &lt;a href="https://www.identity.com/what-is-selective-disclosure/" rel="noopener noreferrer"&gt;&lt;strong&gt;Selective disclosure&lt;/strong&gt;&lt;/a&gt; is a privacy-preserving technique that enables individuals to disclose specific information for a given interaction while keeping all other personal data confidential.&lt;/p&gt;

&lt;p&gt;This approach is a practical expression of a broader concept known as &lt;a href="https://midnight.network/blog/midnight-at-consensus-2025-building-the-future-of-rational-privacy" rel="noopener noreferrer"&gt;&lt;strong&gt;rational privacy&lt;/strong&gt;&lt;/a&gt;. Rational privacy is the idea that privacy shouldn’t be absolute or all-or-nothing—it should be contextual. It recognizes that in many real-world scenarios, users want to share &lt;em&gt;some&lt;/em&gt; data to gain access to services or meet legal obligations, but they shouldn't be forced to give up all privacy and security in the process. It’s about striking a balance between personal control, usability, and regulatory compliance.&lt;/p&gt;

&lt;p&gt;Selective disclosure is the technical implementation of rational privacy. It gives users and developers the cryptographic tools to protect sensitive information by default, while still enabling the right level of transparency when it’s required. This makes it especially relevant for public blockchain networks, where data is immutable and visible by design.&lt;/p&gt;

&lt;p&gt;A typical example of selective disclosure in action is the use of Verifiable Credentials (VCs). VCs allow users to prove attributes—like age, residency, or educational background—without revealing the entire credential. This aligns with the principles of data minimization and privacy by design, ensuring individuals remain in control of their information.&lt;/p&gt;

&lt;p&gt;This balance between usability and privacy is what makes selective disclosure so powerful—and so relevant for real-world blockchain applications. But beyond the technical implementation, it's worth asking: what are the practical benefits of using selective disclosure in the first place?&lt;/p&gt;

&lt;h2&gt;
  
  
  Benefits of Selective Disclosure
&lt;/h2&gt;

&lt;p&gt;When integrated thoughtfully, selective disclosure brings both technical and human-centric advantages to decentralized systems. It enables individuals and organizations to meet privacy expectations and compliance standards without sacrificing functionality. Implementing selective disclosure offers several advantages:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Enhanced Privacy&lt;/strong&gt;: Selective disclosure enables users to share only the data necessary for a specific interaction, rather than disclosing full credentials or identity documents. This dramatically reduces the surface area for privacy breaches and surveillance. Whether you’re accessing a service, submitting a form, or interacting with a smart contract, your unnecessary personal data stays out of view.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Data Minimization and Compliance&lt;/strong&gt;: This principle, core to privacy laws such as GDPR and HIPAA, requires that only the minimum amount of personal data necessary for a task is collected or processed. Selective disclosure naturally enforces this, making it easier for developers and organizations to design privacy-respecting systems by default.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;User Empowerment and Control&lt;/strong&gt;: In traditional systems, users often hand over their entire dataset for one small verification (e.g., uploading an entire ID just to prove their age). Selective disclosure flips that dynamic, giving users the power to control what they share, when, and with whom. This supports a more user-centric data model, where individuals become the custodians of their credentials.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Reduced Risk of Data Misuse&lt;/strong&gt;: The less information that’s exposed, the lower the risk of that data being lost, stolen, or misused. Selective disclosure reduces the need for centralized data storage (e.g., big ID databases), limiting attack vectors for fraud and identity theft. Even if a transaction or credential presentation is intercepted, only the minimum disclosed attribute is visible, keeping the rest safe.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Lower Liability and Operational Overhead for Businesses:&lt;/strong&gt; Many organizations would prefer not to collect or store sensitive user data due to the associated risks, regulatory requirements, and administrative burdens. Selective disclosure offers a path forward, enabling users to demonstrate eligibility or compliance without requiring businesses to retain or manage that data. This can reduce costs, simplify operations, and improve overall data security posture.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;While selective disclosure introduces a powerful model for user-centric privacy, it also comes with its own set of technical and usability challenges. Understanding these limitations is essential for builders and organizations aiming to adopt it responsibly.&lt;/p&gt;

&lt;h2&gt;
  
  
  Potential Drawbacks
&lt;/h2&gt;

&lt;p&gt;While selective disclosure strengthens privacy and control, implementing it in real-world systems isn’t always straightforward. Here are some of the common challenges:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Complexity in Implementation&lt;/strong&gt;: Selective disclosure relies on advanced cryptographic techniques, often zero-knowledge proofs or similar privacy-preserving protocols. These require careful design, precise execution, and deep security expertise. For developers new to Web3 or cryptography, like myself, the learning curve can be steep, and mistakes in implementation could compromise the intended privacy protections.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Verification Difficulties&lt;/strong&gt;: When only a fragment of a credential or statement is revealed, verifying its authenticity can become more complicated. Systems must be designed to ensure that partial disclosures can be trusted without needing access to the complete original data. This often requires additional metadata or proofs to be included, which can increase the overall complexity of the system and potentially slow down the verification process.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Interoperability Challenges&lt;/strong&gt;: Not all decentralized identity systems follow the same formats or standards. As a result, credentials issued by one platform may not be easily verifiable on another, especially when using advanced features like selective disclosure. Without widely adopted protocols and infrastructure, cross-platform compatibility can be limited, reducing the broader utility of selectively disclosed data.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;While these challenges are real, they’re not insurmountable. Much of the current work in privacy-preserving blockchain development, including projects like Midnight, focuses on making selective disclosure more practical, developer-friendly, and interoperable across various ecosystems.&lt;/p&gt;

&lt;h2&gt;
  
  
  Use Cases of Selective Disclosure
&lt;/h2&gt;

&lt;p&gt;Selective disclosure has powerful, real-world applications wherever individuals or organizations need to prove something without oversharing. It’s beneficial in systems that handle sensitive data but also require compliance, trust, and transparency. Here are a few domains where it shines:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Digital Identity Verification&lt;/strong&gt;: Imagine proving you're over 18 to access a service—without uploading your driver's license or disclosing your full birthdate and address. Selective disclosure lets you present only the relevant fact (e.g., “over 18”) as a verifiable statement, not the whole credential.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Financial Transactions&lt;/strong&gt;: Financial platforms often need to confirm identity or transaction legitimacy (for KYC/AML compliance), but users shouldn’t have to share their entire financial history or wallet activity. Selective disclosure enables sharing only what’s legally necessary—no more, no less.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Healthcare&lt;/strong&gt;: Patients may need to prove their vaccination status or medical eligibility without disclosing their entire health record. Selective disclosure lets them share only the required attribute (e.g., “vaccinated for X”) while keeping the rest private.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Access Control&lt;/strong&gt;: Whether entering a venue or accessing online services, users may be granted or denied access based on attributes like membership, role, or credentials. Selective disclosure can enforce this access logic without revealing unnecessary identifying information.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Selective Disclosure in the Midnight Network
&lt;/h3&gt;

&lt;p&gt;At Midnight, selective disclosure isn’t just a privacy feature—it’s a core design principle grounded in rational privacy. Rational privacy recognizes that while sensitive data must be protected, real-world applications also require controlled visibility for regulatory, legal, or operational reasons.&lt;/p&gt;

&lt;p&gt;Take financial transactions, for example. A decentralized financial platform built on Midnight may want to keep user balances, transfers, and transaction histories private. However, under anti-money laundering (AML) or know-your-customer (KYC) regulations, certain information may need to be revealed—but only to authorized parties, and only under specific legal conditions.&lt;/p&gt;

&lt;p&gt;This is where selective disclosure and zero-knowledge proofs come together. Using Midnight's Compact smart contract language, developers can build logic that proves a transaction is valid (e.g., below a certain threshold, or compliant with regulatory filters) without revealing the full transaction details. Meanwhile, if a regulatory audit is triggered, users or auditors could selectively disclose the required pieces of information—nothing more.&lt;/p&gt;

&lt;p&gt;In this way, Midnight enables builders to create applications that respect individual privacy &lt;em&gt;and&lt;/em&gt; comply with regulatory requirements. It’s a practical application of selective disclosure that mirrors how real-world trust operates: share only what’s needed, only when it’s needed, and only with the right people.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Selective disclosure offers a flexible and powerful approach to privacy—one that meets people where they are, allowing them to control their information. It enables individuals to share just enough information to satisfy requirements, without exposing more than necessary. Whether you're verifying an identity, proving a credential, or complying with financial regulations, selective disclosure makes privacy practical and effective.&lt;/p&gt;

&lt;p&gt;At Midnight, this concept becomes more than theoretical. It’s embedded into the platform’s architecture through Compact smart contracts and zero-knowledge proofs, allowing builders to create systems that balance user protection with real-world needs. It’s rational privacy in action.&lt;/p&gt;

&lt;p&gt;If you're exploring how to build for privacy in Web3—or just learning how these systems work—I encourage you to check out the &lt;a href="https://docs.midnight.network/" rel="noopener noreferrer"&gt;Midnight docs&lt;/a&gt; and &lt;a href="https://docs.midnight.network/academy" rel="noopener noreferrer"&gt;Academy&lt;/a&gt; for more examples and technical insight, as well as a detailed list of further reading about selective disclosure below:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://www.identity.com/what-is-selective-disclosure/" rel="noopener noreferrer"&gt;What Is Selective Disclosure? – Identity.com&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.dock.io/post/selective-disclosure" rel="noopener noreferrer"&gt;Selective Disclosure Guide – Dock.io&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://frostbrowntodd.com/a-refresher-on-selective-disclosure-and-anti-fraud-rules/" rel="noopener noreferrer"&gt;A Refresher on Selective Disclosure and Anti-Fraud Rules – Frost Brown Todd&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.midnight.network/academy/module-3" rel="noopener noreferrer"&gt;Midnight Academy Module 3 – Midnight Docs&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.midnight.network/develop/reference/compact/explicit_disclosure" rel="noopener noreferrer"&gt;Explicit Disclosure Reference – Midnight Docs&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.midnight.network/learn/introduction/use-cases/digital-assets" rel="noopener noreferrer"&gt;Digital Assets Use Cases – Midnight Docs&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And, as always, if you’ve come across any great learning resources on privacy or identity in Web3, I’d love to see them—drop a comment or reply with your favorites!&lt;/p&gt;

&lt;p&gt;I'll be back next week with more insights as I continue unpacking the key building blocks that make decentralized systems work.  &lt;/p&gt;

</description>
      <category>midnightnetwork</category>
      <category>web3</category>
      <category>blockchain</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Learning Web3 from the Ground Up - Unpacking Merkle Trees and DAOs</title>
      <dc:creator>Samantha Holstine</dc:creator>
      <pubDate>Fri, 06 Jun 2025 19:04:08 +0000</pubDate>
      <link>https://dev.to/devsofmidnight/learning-web3-from-the-ground-up-unpacking-merkle-trees-and-daos-57c9</link>
      <guid>https://dev.to/devsofmidnight/learning-web3-from-the-ground-up-unpacking-merkle-trees-and-daos-57c9</guid>
      <description>&lt;p&gt;As I continue my Web3 learning journey, I've mostly been working through &lt;a href="https://cardanofoundation.org/academy" rel="noopener noreferrer"&gt;Cardano Academy&lt;/a&gt; and &lt;a href="https://docs.midnight.network/academy/" rel="noopener noreferrer"&gt;Midnight Academy&lt;/a&gt; and documenting my findings in the &lt;a href="https://docs.midnight.network/blog" rel="noopener noreferrer"&gt;Midnight Dev Diaries&lt;/a&gt;. But this week, I decided to branch out and explore a broader range of beginner-friendly resources across the ecosystem. That led me to two foundational concepts that kept coming up: Merkle Trees and Decentralized Autonomous Organizations (DAOs).&lt;/p&gt;

&lt;p&gt;These two topics sit at the heart of blockchain's promise—ensuring transparency, verifying data integrity, and enabling decentralized governance. I've broken down the key takeaways below, and if you're curious to go deeper, check out the list of helpful resources I've included at the end.&lt;/p&gt;

&lt;h2&gt;
  
  
  Merkle Trees: Ensuring Data Integrity
&lt;/h2&gt;

&lt;p&gt;A Merkle Tree, also known as a hash tree, is a data structure that enables efficient and secure verification of large data sets. At its core, it is a special kind of &lt;a href="https://www.geeksforgeeks.org/binary-tree-data-structure/" rel="noopener noreferrer"&gt;binary tree&lt;/a&gt;—a structure many Web2 developers will recognize. In a binary tree, each node has at most two children. What makes Merkle Trees different is that instead of storing values directly, they store hashes. These hashes represent data blocks and provide a compact, tamper-evident summary of all the data in the tree.&lt;/p&gt;

&lt;p&gt;Merkle Trees are crucial in blockchain because they allow a large set of data (like thousands of transactions) to be verified efficiently and securely. Instead of needing to check every transaction, you only need a small subset of hashes (called a Merkle proof) to confirm that a transaction is part of a block.&lt;/p&gt;

&lt;p&gt;Here's a simplified breakdown of how a Merkle Tree is built:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Start with data blocks (like transactions in a block).
&lt;/li&gt;
&lt;li&gt;Each data block is hashed individually. These hashes become the leaf nodes.
&lt;/li&gt;
&lt;li&gt;Pairs of leaf hashes are then hashed together to form the next level of the tree.
&lt;/li&gt;
&lt;li&gt;This process continues, combining hashes pairwise and moving up the tree until you're left with a single root hash, often called the Merkle Root.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In short, each leaf node contains the hash of a data block, each non-leaf node contains the hash of its child nodes, and the root hash represents the entire data set. Any change to any single data block will change its hash, which then cascades up the tree, altering the Merkle Root. This property is crucial for blockchain systems, where data immutability and integrity are paramount.&lt;/p&gt;

&lt;p&gt;In practice, Merkle Trees are used in:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Blockchain Transactions: Ensuring that transactions within a block are untampered.
&lt;/li&gt;
&lt;li&gt;Proof of Reserves: Cryptocurrency exchanges use Merkle Trees to prove they hold sufficient assets to cover user deposits without revealing individual account balances.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  DAOs: Redefining Organizational Governance
&lt;/h2&gt;

&lt;p&gt;Decentralized Autonomous Organizations (DAOs) are organizations governed by smart contracts on a blockchain, eliminating the need for centralized leadership. They replace traditional top-down leadership with transparent, community-driven governance, all enforced through code—specifically, smart contracts.&lt;/p&gt;

&lt;p&gt;In a DAO, rules and operations are programmed upfront and stored on-chain. That means anyone can inspect how decisions are made, how funds are allocated, and how proposals are handled. Everything is transparent and auditable by default. Instead of a single CEO or board, decisions are made collectively by the community. Token holders can vote on proposals, and the outcome reflects the weight of their stake in the project. This collective decision-making process is what makes DAOs decentralized by design. And because those rules are enforced automatically by smart contracts, DAOs can operate autonomously without relying on manual intervention or centralized gatekeepers. Once a proposal passes, the smart contract executes the decision just as it was coded—no waiting for someone to push a button.&lt;/p&gt;

&lt;p&gt;However, DAOs also face challenges, including:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Security Risks: Vulnerabilities in smart contracts can be exploited.
&lt;/li&gt;
&lt;li&gt;Governance Issues: Low voter participation and token concentration can lead to centralization.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;DAOs have been utilized in various domains, such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Investment Funds: Pooling resources to invest in projects collectively.
&lt;/li&gt;
&lt;li&gt;Charitable Organizations: Deciding on fund allocation through member voting.
&lt;/li&gt;
&lt;li&gt;Protocol Governance: Managing and updating blockchain protocols.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  How DAO Voting Works (The Simple Version)
&lt;/h3&gt;

&lt;p&gt;Most DAOs use token-based voting to reach decisions:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Members hold a governance token, which gives them the right to vote.
&lt;/li&gt;
&lt;li&gt;A proposal is submitted (for example, "Fund a new development project").
&lt;/li&gt;
&lt;li&gt;Token holders vote for or against the proposal.
&lt;/li&gt;
&lt;li&gt;If a certain threshold is reached (like a quorum or majority), the proposal is accepted and automatically executed by smart contracts.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Beyond on-chain voting, many DAOs utilize off-chain governance platforms, such as Snapshot (widely used for token-weighted voting), Aragon Voice, Tally (commonly paired with Governor contracts), or Coordinape (used for decentralized grants and peer voting). These tools offer flexibility, reduce gas costs, and enable more experimental governance setups.&lt;/p&gt;

&lt;p&gt;The more tokens you hold, the more voting power you wield. This is similar to how shareholders vote in corporations, but the process is entirely on-chain, without intermediaries.&lt;/p&gt;

&lt;p&gt;Some DAOs use &lt;a href="https://blog.colony.io/what-is-quadratic-voting-a-guide-to-dao-decision-making/" rel="noopener noreferrer"&gt;quadratic voting&lt;/a&gt; or other mechanisms to prevent whales (large holders) from dominating the process, but the core idea remains the same: the community drives the roadmap.&lt;/p&gt;

&lt;h2&gt;
  
  
  Interplay Between Merkle Trees and DAOs
&lt;/h2&gt;

&lt;p&gt;While Merkle Trees and DAOs serve different purposes in the blockchain world—one focused on data integrity, the other on governance—they complement each other in powerful ways. Together, DAOs can remain secure, transparent, and efficient even as they scale.&lt;/p&gt;

&lt;p&gt;For example, instead of storing a complete list of eligible voters, a DAO can publish a Merkle Root representing that list. Individual voters then submit a short cryptographic proof (a Merkle proof) to confirm they're included. This keeps voting lightweight, private, and verifiable. The same method can be used to verify grant recipients or airdrop eligibility—ensuring integrity while saving space and gas costs.&lt;/p&gt;

&lt;p&gt;Merkle Trees also act as a bridge between off-chain and on-chain activity. Whether it's tracking voting done through Snapshot or verifying community identities, these proofs give DAOs a scalable way to maintain trust and transparency—even as they grow.&lt;/p&gt;

&lt;p&gt;Merkle Trees provide DAOs with the cryptographic foundation to scale governance without sacrificing transparency or efficiency. Whether it's verifying voter eligibility, proving fund distribution, or bridging off-chain data to on-chain actions, Merkle Trees help DAOs maintain trust and accountability as they grow. It's a powerful example of how foundational blockchain structures support and enhance decentralized decision-making.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Together, Merkle Trees and DAOs demonstrate how blockchain technology strikes a balance between technical efficiency and community empowerment. Merkle Trees ensure that large sets of data—like transactions, votes, or recipient lists, can be verified quickly and securely. At the same time, DAOs introduce a way for communities to govern decentralized projects in a transparent and fair manner. When combined, they offer a practical solution for scaling trust without sacrificing decentralization. Whether you're verifying a vote, distributing funds, or proving membership, these tools help build the infrastructure that makes Web3 more than just a technological shift—it becomes a new model for how people coordinate, decide, and build together.&lt;/p&gt;

&lt;p&gt;Exploring beyond the Cardano and Midnight Academies for the first time in this journey provided me with a broader understanding of how these technologies are explained and applied across the space. If you're learning along with me or want to dig deeper into any of the topics covered, here are some of the materials I found especially helpful:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://www.youtube.com/watch?v=3AcQyTs_Es4" rel="noopener noreferrer"&gt;Video: Merkle Trees Explained – Simply Explained&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.geeksforgeeks.org/introduction-to-merkle-tree/" rel="noopener noreferrer"&gt;Introduction to Merkle Trees – Geeks for Geeks&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://limechain.tech/blog/what-are-daos" rel="noopener noreferrer"&gt;What Are DAOs – LimeChain Blog&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://academy.moralis.io/blog/blockchain-transparency-exploring-merkle-trees-and-proof-of-reserves" rel="noopener noreferrer"&gt;Blockchain Transparency: Merkle Trees &amp;amp; Proof of Reserves – Moralis&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.bitpanda.com/academy/en/lessons/everything-you-need-to-know-about-merkle-trees/" rel="noopener noreferrer"&gt;Everything You Need to Know About Merkle Trees – Bitpanda Academy&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.chainalysis.com/blog/introduction-to-decentralized-autonomous-organizations-daos/" rel="noopener noreferrer"&gt;Introduction to DAOs – Chainalysis&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And if you’ve come across other great resources while learning Web3 basics, I’d love to hear them—drop a comment or reply with your favorites! You can also check out the &lt;a href="https://docs.midnight.network" rel="noopener noreferrer"&gt;Midnight docs&lt;/a&gt; for more technical deep dives and real-world use cases.&lt;/p&gt;

&lt;p&gt;Stay tuned for next week's exploration into other core components of the decentralized world. &lt;/p&gt;

</description>
      <category>midnightnetwork</category>
      <category>blockchain</category>
      <category>web3</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Learning Web3 from the Ground Up - A Quick History of Blockchain and Why Tokens Matter</title>
      <dc:creator>Samantha Holstine</dc:creator>
      <pubDate>Mon, 02 Jun 2025 15:38:55 +0000</pubDate>
      <link>https://dev.to/devsofmidnight/learning-web3-from-the-ground-up-a-quick-history-of-blockchain-and-why-tokens-matter-3ja4</link>
      <guid>https://dev.to/devsofmidnight/learning-web3-from-the-ground-up-a-quick-history-of-blockchain-and-why-tokens-matter-3ja4</guid>
      <description>&lt;p&gt;I’m still in the early stages of my Web3 learning journey (see my previous posts on the &lt;a href="https://docs.midnight.network/blog" rel="noopener noreferrer"&gt;Midnight Dev Diaries&lt;/a&gt;!), and each week unveils new insights and "aha" moments for me. This week, I delved deeper into the Intro to Blockchain section of &lt;a href="https://academy.cardanofoundation.org/" rel="noopener noreferrer"&gt;Cardano Academy&lt;/a&gt;, along with &lt;a href="https://docs.midnight.network/academy/module-1" rel="noopener noreferrer"&gt;Module 1 of the Midnight Developer Academy&lt;/a&gt;. Rather than just focusing on the technical aspects and step-by-step guides, I shifted my attention to understanding the evolution of blockchain platforms over time, particularly the journey from Bitcoin to more advanced systems like Midnight. This exploration also led me to reflect on the crucial role that tokens play in the functionality and sustainability of decentralized systems. Tokens aren't just mere digital assets; they serve as the economic backbone that incentivizes participation and secures the network. In this post, I want to share two significant topics that helped clarify my understanding this week:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;How blockchain platforms have progressed from Bitcoin to Midnight
&lt;/li&gt;
&lt;li&gt;How tokens keep decentralized systems running through economic incentives&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Let's jump in!&lt;/p&gt;

&lt;h2&gt;
  
  
  The Evolution of Blockchain Platforms
&lt;/h2&gt;

&lt;p&gt;When I first heard about blockchain, I mostly associated it with Bitcoin. However, after diving into more educational content, it became clear that this space has undergone multiple waves of innovation, each building on the last. Here's how we got from the first Bitcoin transaction to the emergence of privacy-focused blockchains like Midnight.&lt;/p&gt;

&lt;h3&gt;
  
  
  Bitcoin (2009): A New Way to Move Money
&lt;/h3&gt;

&lt;p&gt;Blockchain began with Bitcoin, launched in 2009 by the pseudonymous Satoshi Nakamoto. It introduced the idea of a decentralized, peer-to-peer payment network where anyone could send money without relying on banks or intermediaries. Transactions were validated through &lt;strong&gt;proof-of-work&lt;/strong&gt; and recorded on a public ledger that anyone could inspect—but no one could alter.&lt;/p&gt;

&lt;p&gt;This was revolutionary. Bitcoin proved that decentralized digital money was possible—and, in 2010, someone even traded 10,000 BTC for two pizzas. That transaction is now famous for being the first real-world use of Bitcoin and the most expensive pizza ever bought.&lt;/p&gt;

&lt;p&gt;Still, Bitcoin was narrowly focused: it could securely transfer value but not much else.&lt;/p&gt;

&lt;h3&gt;
  
  
  Ethereum (2015): The Rise of Programmable Blockchains
&lt;/h3&gt;

&lt;p&gt;Ethereum took the core idea of blockchain and expanded it into something far more flexible. It introduced &lt;strong&gt;smart contracts&lt;/strong&gt;—self-executing programs that live on the blockchain and run when certain conditions are met. This turned Ethereum into what its creators called a "world computer": a decentralized platform for building applications that couldn't be shut down or censored.&lt;/p&gt;

&lt;p&gt;Ethereum is guided by six key principles:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Atomicity&lt;/strong&gt;: All or nothing execution &lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Synchrony&lt;/strong&gt;: Consistent state across nodes&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Provenance&lt;/strong&gt;: Trackable origins&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Permanence&lt;/strong&gt;: Durable data storage&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Immortality&lt;/strong&gt;: Apps that can't be turned off
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Immutability&lt;/strong&gt;: Data that can't be changed once written&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These principles laid the groundwork for DeFi, NFTs, and DAOs, giving rise to an entire ecosystem of decentralized applications. However, this flexibility came with trade-offs, especially around scalability and high transaction fees.&lt;/p&gt;

&lt;h3&gt;
  
  
  Third-Generation Platforms: Cardano and Beyond
&lt;/h3&gt;

&lt;p&gt;Enter the third generation of blockchains. These platforms aim to solve the Blockchain Trilemma: how to balance scalability, security, and decentralization—without sacrificing any of them.&lt;/p&gt;

&lt;p&gt;Cardano, launched in 2017, is one of the most notable examples. It uses &lt;strong&gt;proof-of-stake&lt;/strong&gt; to reduce energy consumption and improve efficiency. But what stood out most to me is that it was built from the ground up with formal research and peer-reviewed design—a very different approach from its predecessors.&lt;/p&gt;

&lt;p&gt;Cardano also addresses security at the protocol level. Unlike Ethereum, where new tokens are created via smart contracts (which can introduce vulnerabilities), tokens on Cardano are treated as &lt;strong&gt;native assets&lt;/strong&gt;. This means they inherit the same security guarantees as the platform's native currency, ADA, and don't require a custom contract to be created or maintained.&lt;/p&gt;

&lt;p&gt;Other improvements include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Layer 2 scaling solutions like Hydra
&lt;/li&gt;
&lt;li&gt;Support for sidechains to improve interoperability
&lt;/li&gt;
&lt;li&gt;A focus on sustainability by reducing resource consumption through staking is also needed&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Midnight: The Privacy Layer of the Future
&lt;/h3&gt;

&lt;p&gt;Midnight represents a new phase in blockchain evolution focused on privacy and regulatory compliance.&lt;/p&gt;

&lt;p&gt;It uses tools like &lt;a href="https://docs.midnight.network/learn/understanding-midnights-technology/zero-knowledge-proofs" rel="noopener noreferrer"&gt;zero-knowledge proofs&lt;/a&gt; to allow data to remain private on a public blockchain. At the same time, it supports selective disclosure, meaning users can prove compliance (for example, with regulations or audits) without revealing everything. In other words, Midnight blends the decentralization and transparency of blockchain with the privacy needed for real-world use cases—whether it's secure communication, confidential data sharing, or regulated financial applications.&lt;/p&gt;

&lt;h2&gt;
  
  
  Tokenomics 101: Why Tokens Are More Than Just Coins
&lt;/h2&gt;

&lt;p&gt;Once I understood how blockchains evolved, the next big question was: How do they keep running without a central company in charge? The answer lies in tokenomics, the economic design behind each network.&lt;/p&gt;

&lt;h3&gt;
  
  
  Tokens as Utility
&lt;/h3&gt;

&lt;p&gt;Every blockchain has a native token—Bitcoin has BTC, Ethereum has ETH, Cardano has ADA. But tokens aren't just money. Tokens are &lt;strong&gt;used&lt;/strong&gt; to pay transaction fees, deploy contracts, access network features, and more.&lt;/p&gt;

&lt;p&gt;This creates a built-in incentive system. If using the network requires tokens, and the network is valuable, then tokens have value too.&lt;/p&gt;

&lt;h3&gt;
  
  
  Tokens as Incentives
&lt;/h3&gt;

&lt;p&gt;Blockchain networks need participants to validate transactions, secure the network, and maintain consensus. In return, they reward those participants with tokens.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Miners earn BTC for adding blocks to the Bitcoin chain.
&lt;/li&gt;
&lt;li&gt;Validators earn ADA in Cardano's proof-of-stake system to secure the network.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These rewards are often inflationary, meaning new tokens are regularly minted and distributed. However, that inflation funds the network's infrastructure.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Tokens as Governance Tools&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Some tokens also allow holders to vote on decisions. In DAO-style systems, governance tokens let users decide protocol upgrades, fee structures, or treasury spending. This turns token holders into active stakeholders, not just passive investors.&lt;/p&gt;

&lt;h3&gt;
  
  
  Inflationary vs. Deflationary Models
&lt;/h3&gt;

&lt;p&gt;The way a token's supply is designed can shape behavior:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Inflationary models (e.g., Polkadot) continually mint new tokens to incentivize active participation.
&lt;/li&gt;
&lt;li&gt;Deflationary models (e.g., Bitcoin) cap the total supply or burn tokens to reduce circulation.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each model has trade-offs: Inflation can reward contributors but reduce long-term value, while deflation can increase scarcity but discourage spending.&lt;/p&gt;

&lt;p&gt;Many modern projects use hybrid models. For example, Ethereum burns a portion of transaction fees to offset inflation while still issuing new tokens to validators.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Understanding where blockchain originated and how tokens drive these systems provided me with a much clearer view of the ecosystem I'm entering. It's not just about code or decentralization for its sake. It's about designing systems where people are economically motivated to do the right thing. And just like the technology itself, the economics behind blockchains are still evolving.&lt;/p&gt;

&lt;p&gt;If you're learning Web3 too or just curious how all the pieces fit together, be sure to take a look at the &lt;a href="https://docs.midnight.network/" rel="noopener noreferrer"&gt;Midnight docs&lt;/a&gt;, &lt;a href="https://docs.midnight.network/blog" rel="noopener noreferrer"&gt;Dev Diaries&lt;/a&gt;, and the newly published modules in the &lt;a href="https://docs.midnight.network/academy/module-1" rel="noopener noreferrer"&gt;Midnight Developer Academy&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;More foundational concepts are coming next week—stay tuned!  &lt;/p&gt;

</description>
      <category>midnightnetwork</category>
      <category>web3</category>
      <category>beginners</category>
      <category>blockchain</category>
    </item>
    <item>
      <title>Learning Web3 from the Ground Up: Encryption &amp; Practical Byzantine Fault Tolerance</title>
      <dc:creator>Samantha Holstine</dc:creator>
      <pubDate>Wed, 21 May 2025 14:17:57 +0000</pubDate>
      <link>https://dev.to/devsofmidnight/learning-web3-from-the-ground-up-encryption-practical-byzantine-fault-tolerance-12io</link>
      <guid>https://dev.to/devsofmidnight/learning-web3-from-the-ground-up-encryption-practical-byzantine-fault-tolerance-12io</guid>
      <description>&lt;p&gt;I'm still in the early stages of learning about Web3 (see my last two blog posts &lt;a href="https://docs.midnight.network/blog/web3-intro" rel="noopener noreferrer"&gt;here&lt;/a&gt; and &lt;a href="https://docs.midnight.network/blog/web3-intro-hashing-and-digital-signatures" rel="noopener noreferrer"&gt;here&lt;/a&gt;!), and the deeper I go, the more I realize that the real magic of blockchain isn't just in the code—it's in the cryptography that secures data and the consensus algorithms that coordinate it. As I continue learning, two concepts stood out this week: public key encryption and Practical Byzantine Fault Tolerance (PBFT).&lt;/p&gt;

&lt;p&gt;These may sound intimidating, but they’re the backbone of how blockchains protect data and reach agreement without a central authority. I explored them through &lt;a href="https://academy.cardanofoundation.org/" rel="noopener noreferrer"&gt;Cardano Academy's&lt;/a&gt; Intro to Blockchain series, which continues to be a great entry point for breaking down these core concepts.&lt;br&gt;&lt;br&gt;
Here's what I learned—and how these two building blocks shape the infrastructure behind modern blockchain networks.&lt;/p&gt;

&lt;h2&gt;
  
  
  Public Key Encryption – Sending Secrets Without Sharing Keys
&lt;/h2&gt;

&lt;p&gt;Encryption is the backbone of blockchain security. It allows us to send private messages, verify identities, and keep data safe—even across open, decentralized networks like the internet or blockchain itself. This is especially important in Web3, where blockchains are public by default—anyone can view the data, participate in the network, or run a node. At Midnight, encryption plays a key role in protecting sensitive data while still allowing it to live on a public chain. From shielded transactions to selective disclosure, Midnight builds on the principles of public key cryptography to enable privacy without sacrificing decentralization.&lt;/p&gt;

&lt;p&gt;At a high level, encryption is just the process of turning readable data (called cleartext) into gibberish (ciphertext) so that only the right person can turn it back. But how do we do that without first sharing a secret key?&lt;/p&gt;

&lt;h3&gt;
  
  
  The Two Types of Encryption
&lt;/h3&gt;

&lt;p&gt;There are two main types of encryption:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Symmetric encryption&lt;/strong&gt;: The same key is used to encrypt and decrypt the message. It's fast, but you need to share that key first, which can be tricky to do securely.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Asymmetric encryption (also known as public key encryption)&lt;/strong&gt;: Uses a key pair—one public and one private. What one key encrypts, the other can decrypt. If you encrypt something with a public key, only the matching private key can unlock it and vice versa. They’re mathematically linked, but guessing one from the other is nearly impossible.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The key difference? In symmetric encryption, both people share one secret key. In asymmetric encryption, no shared secret is needed, just a matching key pair.&lt;/p&gt;

&lt;h3&gt;
  
  
  A Simple Analogy
&lt;/h3&gt;

&lt;p&gt;Think of symmetric encryption like a shared locker: you and your friend have the same key. Anyone with that key can open the locker. The hard part? Making sure only the two of you have a copy. On the other hand, asymmetric encryption is more like giving everyone a padlock with your name on it (your public key). Anyone can lock a box and send it to you, but only you, holding the matching private key, can open it.&lt;/p&gt;

&lt;h3&gt;
  
  
  How It's Used in Blockchain
&lt;/h3&gt;

&lt;p&gt;When Alice wants to send Bob a secure message:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Bob shares his public key.
&lt;/li&gt;
&lt;li&gt;Alice encrypts her message using Bob's public key.
&lt;/li&gt;
&lt;li&gt;Bob receives and decrypts the encrypted message using his private key.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Even if someone intercepts the message, it’s unreadable without Bob’s private key. Thanks to the math behind elliptic curves and RSA, it would take more time than the universe has existed to reverse-engineer a private key from a public one with today’s computers.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why Not Just Use Public Key Encryption for Everything?
&lt;/h3&gt;

&lt;p&gt;Public key encryption is powerful but computationally heavy. That's why, in practice, most secure systems (like HTTPS) use a hybrid model:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The client and server use public key encryption to securely exchange a temporary session key.
&lt;/li&gt;
&lt;li&gt;From then on, they use symmetric encryption with that shared key to communicate quickly and securely.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This is the same approach blockchains often use for performance and scalability—combining the strengths of both methods.&lt;/p&gt;




&lt;h2&gt;
  
  
  Practical Byzantine Fault Tolerance – How Blockchains Reach Consensus
&lt;/h2&gt;

&lt;p&gt;Now that we've covered encryption, let's move to something that puzzled me at first: How do blockchains reach consensus without a central decision-maker? That's where consensus algorithms come in. This week, I learned about one of the earliest and most influential: Practical Byzantine Fault Tolerance, or PBFT.&lt;/p&gt;

&lt;h3&gt;
  
  
  First, a Quick Refresher on Consensus
&lt;/h3&gt;

&lt;p&gt;Consensus is how distributed systems agree on a single truth, even if some participants are slow, offline, or actively trying to cause problems. It's what lets a decentralized ledger agree on who owns what, and it's essential for any blockchain to function.&lt;/p&gt;

&lt;p&gt;The "Byzantine" part comes from a famous thought experiment called the Byzantine Generals Problem, in which generals need to coordinate an attack but can't trust their messengers. In blockchain terms, nodes must agree on a block, even if some are lying or malfunctioning.&lt;/p&gt;

&lt;h3&gt;
  
  
  What Makes PBFT "Practical"?
&lt;/h3&gt;

&lt;p&gt;PBFT is designed to work in weakly synchronous systems—systems where messages might be delayed, but not indefinitely. It assumes that at most one-third of nodes can be faulty and uses cryptographic signatures to authenticate all messages. That means messages might be delayed, but will eventually arrive, unlike in totally unreliable (asynchronous) systems.&lt;/p&gt;

&lt;p&gt;PBFT has a built-in process called view change, which automatically replaces a faulty primary when enough nodes detect issues. Here's how it works in broad strokes:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;A client (like a user submitting a transaction) sends a request to a primary node.
&lt;/li&gt;
&lt;li&gt;That primary broadcasts the request to other replica nodes.
&lt;/li&gt;
&lt;li&gt;Each replica processes the request and responds.
&lt;/li&gt;
&lt;li&gt;The client waits for enough matching replies (2/3 + 1) to confirm the result.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Suppose the primary node is unresponsive or sends conflicting messages. In that case, replicas can vote to replace it and elect a new primary. This makes PBFT fault-tolerant and adaptive, critical for blockchains operating in the real world.&lt;/p&gt;

&lt;h3&gt;
  
  
  Real-World Analogy
&lt;/h3&gt;

&lt;p&gt;Imagine you're on a group project. One person (the "primary") shares the final version of the project. Everyone else ("replicas") reviews it. If enough people agree it's correct, you submit it. But if someone thinks the leader messed up, they can flag it—and if enough people agree, the group picks a new leader.&lt;/p&gt;

&lt;p&gt;PBFT formalizes this process with message signatures, vote thresholds, and fault limits.&lt;/p&gt;

&lt;h3&gt;
  
  
  Where PBFT Shines—and Where It Doesn't
&lt;/h3&gt;

&lt;p&gt;PBFT excels in small, permissioned networks where all participants are known and vetted, such as enterprise or consortium blockchains. It offers fast and deterministic finality with fewer probabilistic assumptions than models like proof-of-work or proof-of-stake.&lt;/p&gt;

&lt;p&gt;But there are trade-offs:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It doesn't scale well to hundreds or thousands of nodes—it's communication-heavy.
&lt;/li&gt;
&lt;li&gt;Nodes must know about each other ahead of time.
&lt;/li&gt;
&lt;li&gt;It's less decentralized and potentially vulnerable to Sybil attacks if new nodes aren't vetted carefully.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That's why PBFT-inspired models are often combined with other mechanisms, like rotating leadership or staking systems, to improve scalability and resilience.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Encryption and consensus might sound like deep technical topics (and they are), but at their core, they solve very human problems: How can we keep secrets? And how can we agree on what's true when no one is in charge? Here's a quick overview of both concepts, what they solve, and what they're used for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Public Key Encryption&lt;/strong&gt;: Secure communication over open networks. Used in Wallets, HTTPS, block signing&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;PBFT&lt;/strong&gt;: Reaching agreement in the face of faulty/lying nodes. Used in permissioned blockchains, early crypto projects&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Learning about these two areas gave me a clearer view of the building blocks behind secure, decentralized systems like Cardano—and why consensus and cryptography are so tightly intertwined in Web3.&lt;/p&gt;

&lt;p&gt;All of the material in this post comes from &lt;a href="https://academy.cardanofoundation.org/" rel="noopener noreferrer"&gt;Cardano Academy&lt;/a&gt;, which continues to be a fantastic first stop in my Web3 learning journey. I'll be adding more resources over time and sharing what I learn along the way. If you're also getting started, check out the Academy, do some digging on your own, and browse through the &lt;a href="https://docs.midnight.network/" rel="noopener noreferrer"&gt;Midnight docs&lt;/a&gt; and &lt;a href="https://docs.midnight.network/blog" rel="noopener noreferrer"&gt;Dev Diaries&lt;/a&gt; if you want a glimpse of how these ideas show up in practice.&lt;/p&gt;

&lt;p&gt;If you're learning along with me, which concepts have been most challenging to wrap your head around? Drop a comment. I’d love to swap resources! More foundational concepts are coming soon!  &lt;/p&gt;

</description>
      <category>midnightnetwork</category>
      <category>web3</category>
      <category>beginners</category>
      <category>blockchain</category>
    </item>
    <item>
      <title>Learning Web3 from the Ground Up: Hash Functions &amp; Digital Signatures</title>
      <dc:creator>Samantha Holstine</dc:creator>
      <pubDate>Wed, 07 May 2025 14:27:30 +0000</pubDate>
      <link>https://dev.to/devsofmidnight/learning-web3-from-the-ground-up-hash-functions-digital-signatures-3i53</link>
      <guid>https://dev.to/devsofmidnight/learning-web3-from-the-ground-up-hash-functions-digital-signatures-3i53</guid>
      <description>&lt;p&gt;I'm still at the beginning of my &lt;a href="https://docs.midnight.network/blog/web3-intro" rel="noopener noreferrer"&gt;Web3 journey&lt;/a&gt;, and already it’s clear: before you can build the future, you have to understand the foundations. This week, I focused on two key cryptographic building blocks: hash functions and digital signatures.&lt;/p&gt;

&lt;p&gt;These concepts might initially sound intimidating, but they're at the core of blockchain, ensuring data integrity, authenticity, and security. I learned about them through the "Intro to Blockchain" section of the &lt;a href="https://academy.cardanofoundation.org/" rel="noopener noreferrer"&gt;Cardano Academy&lt;/a&gt;—a fantastic first stop on my learning journey. Here's a breakdown of what I took away.&lt;/p&gt;

&lt;h2&gt;
  
  
  Hash Functions – The Digital Fingerprints of Blockchain
&lt;/h2&gt;

&lt;p&gt;Hash functions are everywhere in a blockchain—they link blocks, verify data, and secure transactions. Think of a hash function as a digital fingerprint: it takes an input of any size and produces a fixed-length string (called a &lt;strong&gt;hash digest&lt;/strong&gt;) that uniquely represents that input.&lt;/p&gt;

&lt;h3&gt;
  
  
  Key Properties of Cryptographic Hash Functions
&lt;/h3&gt;

&lt;p&gt;To be helpful in a blockchain or cryptographic setting, hash functions must possess several specific properties that ensure their security and reliability. Some of the most important properties include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;One-way&lt;/strong&gt;: You can go from input to hash, but not vice versa.  &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Deterministic&lt;/strong&gt;: The same input will always produce the same output.  &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Avalanche Effect&lt;/strong&gt;: A tiny input change causes a massive output change.  &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Preimage Resistance&lt;/strong&gt;: You can't guess the input just by looking at the hash.  &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Collision Resistance&lt;/strong&gt;: It's nearly impossible to find two different inputs that give the same hash.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These properties are critical for ensuring that once data is recorded—like a transaction—it can't be altered without detection.&lt;/p&gt;

&lt;h3&gt;
  
  
  Real-World Use Cases
&lt;/h3&gt;

&lt;p&gt;Hash functions aren’t just theoretical—they’re used all the time in real-world systems to keep data secure. Here are a few practical ways they show up:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Password storage&lt;/strong&gt;: Systems store hashes, not the actual passwords.  &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Data integrity&lt;/strong&gt;: Hashes are used to check if data has been altered.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Blockchain linking&lt;/strong&gt;: Every block contains the previous block's hash—alter one, and the whole chain breaks.&lt;/p&gt;

&lt;p&gt;Popular hash functions include SHA-256 (used by Bitcoin), SHA-3, and RIPEMD-160. Some older algorithms, such as MD5 and SHA-1, are now considered insecure due to collision vulnerabilities.&lt;/p&gt;

&lt;h2&gt;
  
  
  Digital Signatures – Proving Who Sent What (and That It Wasn't Changed)
&lt;/h2&gt;

&lt;p&gt;If hash functions are about verifying data &lt;em&gt;hasn't changed&lt;/em&gt;, digital signatures go a step further by proving &lt;strong&gt;who sent the data&lt;/strong&gt;. This gives us &lt;strong&gt;authenticity&lt;/strong&gt; and &lt;strong&gt;non-repudiation&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  How They Work (In a Nutshell)
&lt;/h3&gt;

&lt;p&gt;The digital signature process cleverly combines hashing and encryption to guarantee both authenticity and integrity. Here's a high-level overview of how it works: &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Signing&lt;/strong&gt;: The sender hashes the original message and encrypts that hash using their private key, creating the &lt;strong&gt;digital signature&lt;/strong&gt;.  &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Verifying&lt;/strong&gt;: The recipient uses the sender's public key to decrypt the signature and then checks if the result matches the hash of the received message.  &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If the hashes match, the message is verified. If not, it's been tampered with.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Now, let’s make this less abstract. Think of it like sending a secure email using &lt;a href="https://www.varonis.com/blog/pgp-encryption" rel="noopener noreferrer"&gt;PGP (Pretty Good Privacy)&lt;/a&gt;:&lt;br&gt;&lt;br&gt;
When you send an encrypted email using PGP, your email client uses your private key to sign the message. Anyone who receives it can use your public key to confirm it was really you who sent it, and that the content hasn’t been changed in transit. The same principles apply to digital signatures on the blockchain: the sender signs a message or transaction, and anyone with the public key can verify it. While the tools and context differ, the underlying idea remains familiar: use cryptographic keys to establish trust without relying on a centralized authority.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why This Matters
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Only the private key can create a valid signature.  &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Anyone can use the public key to verify it.  &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If someone tampers with the message, the signature will fail verification.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Types of Digital Signature Algorithms
&lt;/h3&gt;

&lt;p&gt;Different blockchains and cryptographic systems utilize various signature algorithms, depending on their specific security and performance requirements. A few notable examples are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;RSA&lt;/strong&gt;: Based on the difficulty of factoring large numbers.  &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;DSA&lt;/strong&gt;: Based on the discrete log problem.  &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;ECDSA&lt;/strong&gt;: A more efficient elliptic curve version used by Bitcoin.  &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Ed25519&lt;/strong&gt;: The one used by Cardano, known for its speed, security, and small key sizes.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Wallets: Where the Magic Happens
&lt;/h3&gt;

&lt;p&gt;Most of us don’t interact directly with private keys or raw cryptographic operations. Wallets make it manageable by handling keys and signing transactions securely in the background.&lt;/p&gt;

&lt;p&gt;There are two main types of wallets:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Custodial wallets&lt;/strong&gt;: A third party, such as an exchange, manages your keys.  &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Non-custodial wallets&lt;/strong&gt;: You control your own keys—more responsibility, but more control.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Wallets also fall into two categories: hot (online) and cold (offline) storage. Hardware wallets, such as Ledger or Trezor, are considered cold storage because they keep your keys offline. Cold wallets are generally preferred for long-term or high-value holdings due to their increased security.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Hash functions and digital signatures are like the grammar and punctuation of blockchain. They quietly enable much of what makes the ecosystem secure and trustless. Learning about them provided a clearer understanding of how blockchains, such as Cardano, and tools like Midnight operate under the hood.&lt;/p&gt;

&lt;p&gt;I highly recommend checking out &lt;a href="https://academy.cardanofoundation.org/" rel="noopener noreferrer"&gt;Cardano Academy&lt;/a&gt;. It's approachable and well-structured. I also suggest doing your own research and diving into the Midnight documentation and Dev Diaries for more technical depth. Be sure to check out &lt;a href="https://docs.midnight.network/blog/web3-intro" rel="noopener noreferrer"&gt;last week’s blog post&lt;/a&gt; on blockchain fundamentals.&lt;/p&gt;

&lt;p&gt;If you're learning Web3 with me, I'd love to hear what's helped you, what's tripped you up, and what topics you'd like to see explored next. More foundational concepts to come next week!  &lt;/p&gt;

</description>
      <category>midnightnetwork</category>
      <category>beginners</category>
      <category>web3</category>
      <category>blockchain</category>
    </item>
    <item>
      <title>Learning Web3 from the Ground Up: A Beginner's Journey into Blockchain</title>
      <dc:creator>Samantha Holstine</dc:creator>
      <pubDate>Thu, 24 Apr 2025 19:58:23 +0000</pubDate>
      <link>https://dev.to/devsofmidnight/learning-web3-from-the-ground-up-a-beginners-journey-into-blockchain-58al</link>
      <guid>https://dev.to/devsofmidnight/learning-web3-from-the-ground-up-a-beginners-journey-into-blockchain-58al</guid>
      <description>&lt;p&gt;Joining the Midnight team as a Developer Relations Engineer has been an exciting transition, but also an eye-opening one. While I anticipated a learning curve stepping into the Web3 space, I didn't expect just how fundamentally different it would be from my experiences in Web2. Web3 isn't simply a new tech stack—it's a shift in how we think about data, trust, and ownership. &lt;/p&gt;

&lt;p&gt;As I began onboarding with Midnight, I quickly realized that to fully understand the value and capabilities of the platform, I first needed to ground myself in the core principles of blockchain and decentralized technologies. I started learning the basics with &lt;a href="https://academy.cardanofoundation.org/" rel="noopener noreferrer"&gt;Cardano Academy&lt;/a&gt; as a first pass, and it has been a great resource for getting up to speed on the foundations of Web3.&lt;/p&gt;

&lt;p&gt;So, if you're also new to Web3 or blockchain and feeling a bit overwhelmed, you're not alone. And if you're a seasoned pro, consider this a little refresher on some foundational topics I’ve started diving into. Here are the core concepts I've been exploring this week as I embark on my journey into the world of decentralized technology.&lt;/p&gt;

&lt;h1&gt;
  
  
  Core Concepts of Blockchain
&lt;/h1&gt;

&lt;h2&gt;
  
  
  Decentralization
&lt;/h2&gt;

&lt;p&gt;At its heart, blockchain is about decentralization. Instead of relying on a single authority, such as a bank or server, blockchain distributes control across a network of independent nodes. This makes the system more resilient—there is no single point of failure—and ensures that no single entity can unilaterally change the rules.&lt;/p&gt;

&lt;p&gt;Decentralization also lays the groundwork for trustless systems, where participants can interact and transact without needing to trust a central authority.&lt;/p&gt;

&lt;h2&gt;
  
  
  Consensus Algorithms
&lt;/h2&gt;

&lt;p&gt;But how do all these independent nodes agree on what's true? That's where consensus algorithms come in. They enable a decentralized network to reach a consensus, even when some nodes are offline or acting maliciously.&lt;/p&gt;

&lt;p&gt;This idea actually solves a famous problem in distributed systems known as the Byzantine Generals Problem—how to coordinate among parties that can't fully trust each other. Different blockchains address this issue in various ways, which we'll explore shortly.&lt;/p&gt;

&lt;h2&gt;
  
  
  Blockchain Structure
&lt;/h2&gt;

&lt;p&gt;The term "blockchain" is literal: it's a chain of blocks, each containing data. Every block links to the previous one using a cryptographic hash. This structure makes the data immutable—once it's recorded, you can't change it without altering every block that came after it, which is extremely difficult.&lt;/p&gt;

&lt;p&gt;This immutability, combined with transparency, is what gives blockchain its auditability and security.&lt;/p&gt;

&lt;h1&gt;
  
  
  Consensus Mechanisms
&lt;/h1&gt;

&lt;p&gt;Now that we've discussed consensus in theory, here's a breakdown of how it works in practice. Different blockchains employ various mechanisms to achieve consensus, each with its strengths, trade-offs, and specific use cases.&lt;/p&gt;

&lt;h2&gt;
  
  
  Proof of Work (PoW)
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;What it uses&lt;/strong&gt;: Computational power.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;How it works&lt;/strong&gt;: Miners compete to solve complex math problems. The first one to solve one gets to add the next block to the chain.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Pros&lt;/strong&gt;: Secure and well-tested (used by Bitcoin).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cons&lt;/strong&gt;: Extremely energy-intensive and not very scalable.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Proof of Stake (PoS)
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;What it uses&lt;/strong&gt;: Stake in the network (native tokens).
How it works**: Validators are chosen to create new blocks based on how much they've staked.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Pros&lt;/strong&gt;: Much more energy-efficient than PoW, faster transactions.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cons&lt;/strong&gt;: Can raise concerns around wealth concentration and governance.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Practical Byzantine Fault Tolerance (PBFT)
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;What it uses&lt;/strong&gt;: Agreement among a known group of nodes.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;How it works&lt;/strong&gt;: Nodes exchange messages to confirm transactions, even if some are faulty.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Pros&lt;/strong&gt;: Fast finality, great for permissioned blockchains.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cons&lt;/strong&gt;: It doesn't scale well for large public networks. 
It is often used in smaller, permissioned networks because it requires many messages between nodes to agree, which makes it impractical for large public blockchains.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Other Consensus Models
&lt;/h2&gt;

&lt;p&gt;Numerous niche, experimental, and hybrid models are available. Here are a few that caught my attention:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Proof of Authority (PoA)&lt;/strong&gt;: Uses validator identity/reputation and is typically used in permissioned chains.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Proof of Activity (PoAc)&lt;/strong&gt;: A hybrid  of PoW and PoS where miners start the process, and validators stake to complete it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Proof of Burn/Capacity/Contribution&lt;/strong&gt;: Novel methods using resources, effort, or behavior.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Proof of Elapsed Time (PoET&lt;/strong&gt;): Uses secure hardware to ensure fairness.&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;This is just the beginning of my journey, but already, I can see how powerful and complex this space is. Understanding blockchain and consensus mechanisms is like learning the grammar of a new language. It's the foundation for understanding platforms like Midnight and the kinds of problems it's designed to solve.&lt;/p&gt;

&lt;p&gt;So far, everything I’ve shared has come from one resource: &lt;a href="https://academy.cardanofoundation.org/" rel="noopener noreferrer"&gt;Cardano Academy&lt;/a&gt;. It’s been a helpful starting point, but it’s just that – a starting point. I plan to explore many more resources to continue building my knowledge, and I recommend that you do the same. Cardano Academy is a great place to start, but supplementing it with your own research and delving into the Midnight &lt;a href="https://docs.midnight.network/" rel="noopener noreferrer"&gt;documentation&lt;/a&gt; and &lt;a href="https://docs.midnight.network/blog" rel="noopener noreferrer"&gt;Dev Diaries&lt;/a&gt; can provide a much more well-rounded understanding of Web3.  &lt;/p&gt;

&lt;p&gt;If you're also diving into Web3 for the first time, I hope this helped give you some structure to start your learning. And if you're already immersed in the space, I'd love to hear what helped you connect the dots when you were starting out—please drop a comment or share your favorite learning resources with me!&lt;/p&gt;

&lt;p&gt;More concepts to come as I dig deeper into Midnight and the wider Web3 world – and I’ll be sharing additional resources along the way as I continue learning. Stay tuned!&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>web3</category>
      <category>blockchain</category>
      <category>midnightnetwork</category>
    </item>
  </channel>
</rss>
