<?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>Forem: Giovanni</title>
    <description>The latest articles on Forem by Giovanni (@giovanni_c7781d55fcf2362c).</description>
    <link>https://forem.com/giovanni_c7781d55fcf2362c</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.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2653169%2F7ce1eb0d-aa4b-435b-ab2a-7f8f9b215cc1.jpg</url>
      <title>Forem: Giovanni</title>
      <link>https://forem.com/giovanni_c7781d55fcf2362c</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/giovanni_c7781d55fcf2362c"/>
    <language>en</language>
    <item>
      <title>How to Run and Test Your Midnight DApps</title>
      <dc:creator>Giovanni</dc:creator>
      <pubDate>Tue, 23 Dec 2025 17:58:31 +0000</pubDate>
      <link>https://forem.com/giovanni_c7781d55fcf2362c/how-to-run-and-test-your-midnight-dapps-19an</link>
      <guid>https://forem.com/giovanni_c7781d55fcf2362c/how-to-run-and-test-your-midnight-dapps-19an</guid>
      <description>&lt;p&gt;From DUST to tDUST: How to Run and Test Your Midnight DApps&lt;br&gt;
Midnight’s decentralized application (DApp) platform introduces an elegant but straightforward token model — DUST fuels everything. Whether you’re deploying smart contracts or executing transactions, you’ll need a bit of DUST in your wallet to make things run.&lt;br&gt;
But before you start thinking about tokenomics and gas fees, there’s good news: you don’t need real tokens to build and experiment. On the Midnight testnet, you’ll work with tDUST — a free, developer-friendly version of DUST designed for testing and learning.&lt;br&gt;
Why You Need DUST&lt;br&gt;
Every DApp interaction on the Midnight production network consumes DUST. This mechanism keeps the system efficient, secure, and fair. Developers who want to simulate that behavior locally can use tDUST on the testnet — the same way ETH and GoerliETH work on Ethereum networks.&lt;br&gt;
How to Get Free tDUST&lt;br&gt;
Here’s the quick start for developers setting up their Midnight testnet environment:&lt;br&gt;
Set up your wallet.&lt;br&gt;
Open your Lace wallet and copy your receiving address. Midnight uses the Bech32m format by default.&lt;br&gt;
Check your address format.&lt;br&gt;
While the testnet faucet currently supports both Bech32m and legacy HEX formats, the latter will be deprecated soon — so stick to Bech32m.&lt;br&gt;
Visit the Midnight Faucet.&lt;br&gt;
Go to the official Midnight Testnet Faucet. Paste your wallet address into the field.&lt;br&gt;
Request test tokens.&lt;br&gt;
Click “Request Tokens” and wait a few seconds. You should see a confirmation like this:&lt;br&gt;
text&lt;br&gt;
Transaction submitted. ID: 1644b988ac71dc6bd6...&lt;/p&gt;

&lt;p&gt;You’ll instantly receive 1,000 tDUST in your wallet.&lt;br&gt;
And that’s it — you’re now ready to deploy, test, and refine your Midnight DApps without spending a single real token.&lt;br&gt;
Next Steps&lt;br&gt;
Explore the Midnight docs for DApp deployment guides.&lt;br&gt;
Join the Midnight developer community for updates and faucet availability.&lt;br&gt;
When you’re ready, move from tDUST to real DUST on mainnet to go live.&lt;/p&gt;

</description>
      <category>testing</category>
      <category>tutorial</category>
      <category>web3</category>
    </item>
    <item>
      <title>Building a Midnight App with ViteJS</title>
      <dc:creator>Giovanni</dc:creator>
      <pubDate>Wed, 17 Dec 2025 15:39:11 +0000</pubDate>
      <link>https://forem.com/giovanni_c7781d55fcf2362c/building-a-private-split-app-1bna</link>
      <guid>https://forem.com/giovanni_c7781d55fcf2362c/building-a-private-split-app-1bna</guid>
      <description>&lt;p&gt;Midnight is a privacy‑first L1 where you write Compact smart contracts that compile to ZK circuits and then interact with them from a TypeScript app using generated artifacts and a local proof server.  Below is a blog‑style tutorial showing how to scaffold a Midnight DApp frontend with Vite, connect it to a simple Compact contract, and get new users from zero to “first private tx” on Testnet‑02. &lt;/p&gt;




&lt;h2&gt;
  
  
  What is Midnight and why Vite
&lt;/h2&gt;

&lt;p&gt;Midnight is a blockchain focused on selective disclosure: users can prove facts about their data (compliance, thresholds, membership) without revealing the underlying sensitive information.  This is achieved via Compact, a domain‑specific language that compiles to zero‑knowledge circuits and enforces privacy by default. &lt;/p&gt;

&lt;p&gt;For onboarding web developers, Vite offers a fast dev server, first‑class TypeScript support, and a familiar React/Vue/Svelte ecosystem, making it a natural fit for Midnight’s TypeScript‑first tooling and generated APIs. &lt;/p&gt;




&lt;h2&gt;
  
  
  Prerequisites and environment
&lt;/h2&gt;

&lt;p&gt;Before writing any code, new users need both a Midnight wallet and a local dev setup.  The basic checklist is:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Google Chrome for the Lace Midnight Preview wallet.
&lt;/li&gt;
&lt;li&gt;Node.js 20.x or higher (NVM is recommended for managing versions).
&lt;/li&gt;
&lt;li&gt;Docker Desktop for running the local proof server used to generate ZK proofs.
&lt;/li&gt;
&lt;li&gt;A code editor like VS Code, ideally with the Compact extension installed.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To get a wallet and test funds:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Install the Lace Midnight Preview Chrome extension from the Web Store and pin it.
&lt;/li&gt;
&lt;li&gt;Create a new wallet, set a strong password, and safely back up the seed phrase offline.
&lt;/li&gt;
&lt;li&gt;Copy your address and request tDUST from the official testnet faucet; the wallet should soon show a non‑zero tDUST balance.
&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  Installing Compact and the proof server
&lt;/h2&gt;

&lt;p&gt;Compact is the smart contract language for Midnight; you will compile &lt;code&gt;.compact&lt;/code&gt; files into ZK circuits and TypeScript bindings.  To install the CLI, run the official installer script:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl &lt;span class="nt"&gt;--proto&lt;/span&gt; &lt;span class="s1"&gt;'=https'&lt;/span&gt; &lt;span class="nt"&gt;--tlsv1&lt;/span&gt;.2 &lt;span class="nt"&gt;-LsSf&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  https://github.com/midnightntwrk/compact/releases/download/compact-v0.2.0/compact-installer.sh &lt;span class="se"&gt;\&lt;/span&gt;
  | sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After installation, ensure the binary is on your &lt;code&gt;PATH&lt;/code&gt; and verify it works:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;compact &lt;span class="nt"&gt;--version&lt;/span&gt;   &lt;span class="c"&gt;# prints Compact version&lt;/span&gt;
which compact       &lt;span class="c"&gt;# prints installation path&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Both commands should succeed to confirm your environment is ready to compile contracts. &lt;/p&gt;

&lt;p&gt;For local proof generation, Midnight uses a proof server that runs inside Docker.  Start it with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker run &lt;span class="nt"&gt;-p&lt;/span&gt; 6300:6300 midnightnetwork/proof-server &lt;span class="nt"&gt;--&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="s1"&gt;'midnight-proof-server --network testnet'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The container logs should indicate the server is listening on &lt;code&gt;http://localhost:6300&lt;/code&gt;; in Lace’s settings under Midnight network, you can optionally point it to the local server (&lt;code&gt;Local (http://localhost:6300)&lt;/code&gt;) so wallet‑side proofs also run against your machine. &lt;/p&gt;




&lt;h2&gt;
  
  
  Writing a minimal Compact contract
&lt;/h2&gt;

&lt;p&gt;To keep the first tutorial approachable, define a simple “Hello Midnight” contract that stores a single string on‑chain.  In a fresh folder (the contract side, separate from the Vite UI for clarity), create the required structure:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;mkdir &lt;/span&gt;my-mn-app
&lt;span class="nb"&gt;cd &lt;/span&gt;my-mn-app
npm init &lt;span class="nt"&gt;-y&lt;/span&gt;

&lt;span class="nb"&gt;mkdir &lt;/span&gt;src contracts
&lt;span class="nb"&gt;touch &lt;/span&gt;contracts/hello-world.compact
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;At the top of &lt;code&gt;hello-world.compact&lt;/code&gt;, pin the Compact language version to guard against breaking changes in future minor releases:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pragma language_version 0.17;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next, define the ledger section, which declares the on‑chain state schema.  Use &lt;code&gt;Opaque&amp;lt;"string"&amp;gt;&lt;/code&gt; to store a variable‑length string while keeping it privacy‑aware:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export ledger message: Opaque&amp;lt;"string"&amp;gt;;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Finally, add a circuit called &lt;code&gt;storeMessage&lt;/code&gt; that accepts a private string input and writes it into the ledger, explicitly disclosing it so it becomes visible on the public state:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export circuit storeMessage(customMessage: Opaque&amp;lt;"string"&amp;gt;): [] {
  message = disclose(customMessage);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Putting it all together, the full &lt;code&gt;hello-world.compact&lt;/code&gt; file is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pragma language_version 0.17;

export ledger message: Opaque&amp;lt;"string"&amp;gt;;

export circuit storeMessage(customMessage: Opaque&amp;lt;"string"&amp;gt;): [] {
  message = disclose(customMessage);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;disclose&lt;/code&gt; is required because Compact treats user inputs as private by default; only explicitly disclosed values leak to the public ledger, embodying Midnight’s “privacy‑first” design. &lt;/p&gt;




&lt;h2&gt;
  
  
  Compiling to ZK circuits and artifacts
&lt;/h2&gt;

&lt;p&gt;From the project root, compile the contract with Compact:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;compact compile contracts/hello-world.compact contracts/managed/hello-world
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This generates a &lt;code&gt;contracts/managed/hello-world&lt;/code&gt; folder containing: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;contract/&lt;/code&gt; – compiled contract JSON artifacts for deployment and frontend integration.
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;keys/&lt;/code&gt; – proving and verification keys used for generating and validating ZK proofs.
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;zkir/&lt;/code&gt; – the Zero‑Knowledge Intermediate Representation bridging Compact to the ZK backend.
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;compiler/&lt;/code&gt; – intermediate artifacts created during compilation.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These outputs are what your Vite app will ultimately use (directly or via Midnight’s SDK) to construct transactions, generate proofs via the proof server, and talk to the Midnight testnet. &lt;/p&gt;




&lt;h2&gt;
  
  
  Scaffolding a Vite + TypeScript frontend
&lt;/h2&gt;

&lt;p&gt;With the contract compiled, you can now spin up a Vite app that will serve as the DApp’s UI layer.  From a suitable directory (sibling to or inside your repo, depending on your preferred layout), run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm create vite@latest midnight-hello-vite &lt;span class="nt"&gt;--&lt;/span&gt; &lt;span class="nt"&gt;--template&lt;/span&gt; react-ts
&lt;span class="nb"&gt;cd &lt;/span&gt;midnight-hello-vite
npm &lt;span class="nb"&gt;install&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This creates a React + TypeScript project with a hot‑reloading dev server.  For other ecosystems, you can swap &lt;code&gt;react-ts&lt;/code&gt; for &lt;code&gt;vue-ts&lt;/code&gt;, &lt;code&gt;svelte-ts&lt;/code&gt;, or &lt;code&gt;vanilla-ts&lt;/code&gt; while keeping the Midnight integration story the same. &lt;/p&gt;

&lt;p&gt;To connect the Vite app to your contract artifacts, either copy the &lt;code&gt;contracts/managed/hello-world&lt;/code&gt; folder into the frontend repo (for example under &lt;code&gt;src/contracts&lt;/code&gt;) or expose it via a workspace/monorepo setup if you want a more production‑ready layout.  The important part is that your UI code can import the compiled contract metadata and keys.&lt;/p&gt;




&lt;h2&gt;
  
  
  Wiring Midnight logic into the Vite app
&lt;/h2&gt;

&lt;p&gt;At a high level, the Vite app will need to: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Detect and connect to the user’s Lace Midnight Preview wallet in Chrome.
&lt;/li&gt;
&lt;li&gt;Load the compiled contract JSON from &lt;code&gt;contracts/managed/hello-world/contract&lt;/code&gt;.
&lt;/li&gt;
&lt;li&gt;Use the Midnight client APIs to create a transaction that calls &lt;code&gt;storeMessage&lt;/code&gt;, feeding in the user’s string input.
&lt;/li&gt;
&lt;li&gt;Send the transaction to the testnet, letting the proof server handle ZK proof generation.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A tutorial‑friendly React flow in &lt;code&gt;App.tsx&lt;/code&gt; might:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Render a “Connect Lace” button that triggers wallet API discovery in the browser.
&lt;/li&gt;
&lt;li&gt;Show an input field for the message and a “Store message” button.
&lt;/li&gt;
&lt;li&gt;On submit, construct a Midnight transaction invoking the &lt;code&gt;storeMessage&lt;/code&gt; circuit, sign it via the wallet, and broadcast it.
&lt;/li&gt;
&lt;li&gt;Optionally query and display the latest &lt;code&gt;message&lt;/code&gt; from the contract ledger to prove the write succeeded.
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Although the exact JavaScript client bindings are documented elsewhere in the Midnight API reference, the key idea for onboarding is to present this as “just another TypeScript SDK” backed by artifacts generated from Compact, not a black‑box cryptography stack. &lt;/p&gt;




&lt;h2&gt;
  
  
  Onboarding tips for new Midnight users
&lt;/h2&gt;

&lt;p&gt;To make the Vite tutorial an effective onboarding piece into the Midnight ecosystem, emphasize a few narrative points: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Midnight treats privacy as the default; disclosure is explicit, as seen in the &lt;code&gt;disclose(customMessage)&lt;/code&gt; call.
&lt;/li&gt;
&lt;li&gt;The same tooling flow scales from a toy &lt;code&gt;hello-world&lt;/code&gt; contract to real selective‑disclosure apps (compliance attestations, private credentials, etc.).
&lt;/li&gt;
&lt;li&gt;Lace + proof server + Compact + Vite is a complete vertical stack: wallet, proofs, contracts, and UI all working together on Testnet‑02.
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>webdev</category>
    </item>
  </channel>
</rss>
