🌌 Inspiration In the Midnight Network, all transaction fees are paid using a special resource called DUST. However, new users start with 0 DUST and cannot pay for fees to make their first transaction. This is a major hurdle for onboarding new people—often called the "cold-start" problem.
We built DustRegen Relayer to solve this. It is a system that allows developers to pay gas fees for their users behind the scenes using their own NIGHT tokens. This makes the dApp feel completely "gasless" and easy to use, while the users still keep full control of their private keys.
🛠️ How We Built It We built the project as a clean, type-safe TypeScript Monorepo with three core parts:
Compact Smart Contract: A simple counter contract used to test and verify our gasless interactions.
Sponsor Backend (Express API): A secure server that holds a Sponsor Wallet using LevelDB to save private state data. When a user sends an unsigned transaction, our backend injects the required DUST fees using the Midnight SDK and returns the balanced transaction to the user.
Interactive Terminal TUI: A beautiful terminal interface with easy menus, colors, and loading spinners. It runs a full 6-step simulation—creating an empty wallet, making a contract call, getting sponsored DUST, signing, and submitting to the PreProd network.
⚡ Challenges We Faced UTXO Collisions: When multiple users asked for sponsorship at the exact same time, the server tried to spend the same DUST coin, causing transactions to fail. We solved this by adding a sequential queue (FIFO Mutex) to process requests one by one.
DUST Change Leakage: In initial tests, the unspent DUST change was sent to the user's wallet instead of returning to the sponsor. We fixed this by manually routing the change output back to the sponsor's key.
Private State Loss: On Midnight, if the server's local LevelDB database is deleted, the private wallet history and keys are lost forever. We solved this by using persistent Docker volumes to safely back up our database.
🎓 What We Learned Predictable Costs: Decoupling NIGHT (holding value) and DUST (used for gas) is a game-changer. It allows developers to easily plan their budget without worrying about market price spikes.
Local ZK Proofs: We learned that Midnight runs Zero-Knowledge proofs locally on client machines in milliseconds, which is extremely fast and private.
Frictionless Web3: We proved that with a good backend relayer, we can hide complex cryptography and make blockchain applications feel as simple as normal Web2 apps.
Log in or sign up for Devpost to join the conversation.