Inspiration
"Y a pas de monnaie !" is something you hear every day in Dakar. Across the CFA franc zone, small coins are chronically scarce. Shopkeepers can't give change, customers lose it, get a candy instead, or pay coin resellers a fee to break a bill. Senegal's central bank has called the shortage a drag on businesses and public services.
Converting change into sats has been tried before. The tools I found were custodial and one-way: the change leaves the shop, and the story ends there. I wanted change that the customer truly owns and can spend at the next stall.
What it does
Monnaie is a pair of self-custodial Bitcoin/Lightning wallets, one for the merchant and one for the customer. It covers the full life of the money, from an exchange into the shop and back out again:
- Top up (merchant): the shop owner funds the Monnaie wallet with real bitcoin from Binance, Bitfinex or any other wallet, over Lightning or the regular Bitcoin network (on-chain deposit address). This balance is the shop's change float for the day.
- Give change (merchant): at the counter, the merchant types the price and the cash received. Monnaie converts the difference from FCFA to sats and shows a single-use voucher QR code.
- Receive and keep the change (customer): the customer scans the voucher. A free wallet, Monnaie Wallet, opens right in the phone's browser, with nothing to download and no sign-up. The customer sets a PIN and the change arrives in seconds. It stays in their own wallet, and change from many purchases adds up in one balance. Customers who already have a Lightning wallet (Blink, Phoenix, Wallet of Satoshi…) can scan with it instead.
- Spend the change (customer → any merchant): the merchant app also collects payments (Collect). A customer pays any Monnaie shop with the change they hold, through a free, instant Spark transfer. Change earned at stall A buys bread at stall B. The merchant's wallet verifies every payment before showing "Paid".
- Cash out (both sides): the merchant and the customer can withdraw their bitcoin at any time, to an exchange or any wallet, over Lightning, Lightning Address or on-chain, after a preview screen that shows the amount and fee.
Both wallets are managed with the user's own PIN, and the keys never leave the merchant's device or the customer's phone.
Built for the counter: big buttons, common FCFA notes as shortcuts, printable vouchers, a daily summary of change given and payments collected, and a French / English interface switch that follows the device language.
How I built it
- Wallets: the Spark SDK (self-custodial Bitcoin L2 with Lightning interoperability). The merchant wallet runs in a Node.js server on the merchant's own device. The customer wallet runs entirely in the browser, through a Spark SDK bundle I built with esbuild, including its WebAssembly signing code.
- Deposits and withdrawals: Lightning invoices, Lightning Addresses, Spark addresses and on-chain Bitcoin. On-chain deposits are credited through Spark's static deposit addresses, and on-chain withdrawals use a cooperative exit with a fee quote and a chosen speed.
- My own LNURL-withdraw service (LUD-03): vouchers are served by Monnaie itself, with no third-party voucher platform. I implemented bech32 LNURL encoding and decoding, BOLT11 amount parsing and Lightning Address resolution, shared between server and browser. Monnaie wallets get an extra fast path that claims through a free Spark transfer instead of Lightning.
- Payment verification: when a customer pays a shop, the merchant's wallet checks the Spark transfer itself: the receiver is its own identity key, the amount is enough, the transfer is committed, and the transfer id has never been used before.
- Security by design:
- The merchant seed is encrypted at rest (scrypt + AES-256-GCM, PIN), and the customer seed is encrypted in the browser (PBKDF2-SHA256 600k + AES-GCM). The server never sees customer keys.
- Vouchers are single-use with a fixed amount, short expiry, per-voucher and daily caps, and a synchronous lock against double claims.
- A claim invoice must exactly match the voucher amount, and routing fees are capped.
- Sends go through a two-step preview → confirm screen with address and invoice validation.
- Other protections: strict CSP, SSRF guard, rate limiting, PIN lockout, a price-feed sanity check, a hot-wallet cap, separate data for demo and real mode, and a git pre-commit hook that blocks seeds and secrets.
- Demo mode: a simulated ledger with the same wallet interface, so every flow can be tried without real funds.
- Stack: Node.js, Express, vanilla JS (no framework, no third-party scripts in the page), Spark SDK, @scure/bip39, qrcode. MIT licensed.
Challenges I ran into
- Custodial vs. self-custodial. My first prototype used a hosted Lightning wallet service. It worked, but the merchant didn't own the keys and I wasn't really implementing a wallet, so I rebuilt everything around self-custody.
- On-chain doesn't fit small change. A 150 FCFA voucher is about 290 sats. That's under Bitcoin's dust limit, and on-chain fees can exceed the change itself. Change has to move off-chain, with on-chain kept for larger top-ups and withdrawals.
- Exchanges go down. While testing, an exchange's Lightning withdrawals were suspended. That's why both wallets also support regular on-chain deposits and withdrawals, which is how I funded the merchant wallet in the end.
- Running a wallet in the browser under a strict security policy. I had to bundle a large SDK with WebAssembly into one file the page could load from its own origin, with no inline scripts and no
eval. - Trusting payments. A bearer voucher can be claimed twice in a race, and a customer could claim "I paid" without paying. I had to lock vouchers synchronously and verify payments on the merchant's side.
- LNURL needs a public HTTPS endpoint. External wallets must reach the merchant's server, so a local-first app needs a tunnel for that path. Monnaie's own wallet works locally.
Accomplishments that I'm proud of
- A closed loop with real money: bitcoin comes in from an exchange, goes out as change, is held and spent again across shops, and can be cashed out, with no coins and no custodian in the middle.
- Tested end-to-end on Bitcoin mainnet with real sats: an on-chain top-up from an exchange, change vouchers claimed on a phone, and purchases paid with that change.
- Both sides are self-custodial, and onboarding a brand-new customer takes one scan and a PIN.
- My own LNURL-withdraw implementation, plus a free Spark fast path for Monnaie wallets.
- A security model I can explain line by line, including the honest trade-offs.
- Built solo within the hackathon, fully open source.
What I learned
- Simple is hard at the counter. A shopkeeper has seconds. Every extra tap or unfamiliar word costs adoption, so the UI is big, number-first and available in French and English.
- Self-custody changes where the risk sits. It moves from "the server gets hacked" to "the key is badly protected". Encryption, backups and small hot-wallet floats matter more than any feature.
- Pick the right layer for the amount: off-chain for change, on-chain for savings and large transfers.
- Be honest about trust assumptions. Spark is self-custodial but relies on at least one honest operator, and exiting tiny balances to L1 is uneconomical. Monnaie is designed for change-sized amounts, and users are told to sweep savings to cold storage.
What's next for Monnaie
- Field test with a few merchants in a Dakar market, and measure how much change is given and re-spent.
- Wolof interface and voice prompts for merchants who don't read French comfortably.
- Stable-value option: let customers hold their change in a stablecoin on Spark if they prefer to avoid volatility.
- Offline-friendly printed voucher booklets for shops with unreliable internet.
- Merchant map over Nostr, so customers can discover the shops where their change can be spent.
- Multi-device merchant accounts and a hosted, one-click deployment for non-technical shopkeepers.
Built With
- bitcoin
- css3
- esbuild
- express.js
- html5
- javascript
- lightning-network
- lnurl
- node.js
- particle
- qrcode
- web-crypto-api
- webassembly
