For wallets and apps
Give your users a swap, keep a share of every fill
Your users ask for a price, bonded solvers compete, and the trade settles in one transaction their wallet proves. You set your own app fee and receive 30% of the protocol fee on the flow you bring.
What you get
A few calls, the whole trade
In the SDK
- quote → accept → balance or make an offer → track, or all of it in one
swap()call. The SDK checks the relay's attestation and every quote's signature before it returns anything, and checks the solver's leg before your user's wallet signs. - Limit offers: rest an all-or-nothing offer for the matcher to cross, and cancel it.
- The privacy level per request — public, shielded or compliant — and the sentence to show your user.
- Error shapes for every refusal (paused, declined, no quote, a solver that fades), so your UI can say what happened.
In your account
- Your app fee, set by you, declared in every quote and paid to your address inside each settlement.
- 30% of the protocol fee (4 bps) on every fill you bring.
- Monthly statements: attributed fills and volume, app fees received on chain, protocol fees on your flow, the share due.
- On-chain payouts of the share in USDM, each recorded with its transaction.
What it needs from the wallet
The connector calls, and which wallets have passed
The SDK uses the lowest common subset of Midnight's dApp connector API 4.x. A wallet that lacks a call still works on the paths that do not need it; its profile records which.
| Call | Used for | Required for M1 |
|---|---|---|
connect(networkId) with 'mainnet' / 'preprod', returning rdns and apiVersion | Everything | yes |
Unshielded address; shieldedAddress (coin public key and encryption public key) | Receivers | yes (unshielded for buys; shielded for sells and shielded delivery) |
Shielded and unshielded balances by raw token type; getDustBalance | Pre-checks; choosing wallet-paid vs sponsored DUST | yes |
balanceSealedTransaction(tx, {payFees: true}) covering the user's shielded inputs (buy) | solver_offer buys with the wallet's own DUST | yes |
balanceSealedTransaction(tx, {payFees: false}) | Sponsored buys (the solver pays the DUST) | yes (Gero's sponsorship path) |
balanceSealedTransaction covering an unshielded (NIGHT) deficit | solver_offer sells | for sells |
makeIntent(gives, wants, {intentId: 'random', payFees: false}) | user_offer buys and sells; limit offers | for user_offer (the operator's web page settles this way because it has no checkLeg) |
submitTransaction (returns no hash) | Submission | yes; the SDK confirms by nullifiers and commitments on chain |
| Proving through the wallet | Every signed step | yes |
The call table is from docs/m1/wallet-conformance.md, last changed 27 November 2026.
Wallet profiles
| Wallet | Solver leg, own DUST | Sponsored | User offer | Sells by solver leg | Tested |
|---|---|---|---|---|---|
Demo wallet (Midnight wallet SDK 2.0)dev.si.sdk-wallet | yes | yes | no | no | preprod, 10 Nov 2026 |
Devnet wallet (ledger-kit)dev.si.devnet-wallet | yes | yes | yes | yes | devnet, 10 Nov 2026 |
Not yet run: Gero, Lace, 1AM. A wallet without a profile gets the most conservative path and an "untested wallet" notice. Conformance is the /regression page run from the wallet on Preprod; its result sets the profile, never a hand edit. The procedure.
Try it in 20 minutes
A swap from npm install, then Preprod
Demo mode runs an in-process relay with real signatures, real checks and the production error shapes; only proofs, the chain and time are mocked. Everything that passes in demo must pass on Preprod.
Not live yet. Demo mode is the next wallet SDK release (docs/devex.md §2). Until it ships, the swap runs against the local devnet stack or, with a token from us, Preprod.
import { SwapClient, DemoWallet } from '@fondaco/wallet-sdk';
const client = new SwapClient({ mode: 'demo' }); // no relay URL, no app key
const wallet = new DemoWallet({ USDM: 1_000_000_000n }); // or a real connector in demo mode
const r = await client.swap(wallet, {
give: 'USDM', want: 'NIGHT', amount: 25_000_000n,
receiver: wallet.receiver(),
onProgress: (p) => console.log(p.stage), // reserved → made → submitted → finalized
}); Then the same code against the hosted Preprod relay, with a real wallet:
import { SwapClient } from '@fondaco/wallet-sdk';
// 'demo' is the public test app on Preprod; your own app id and key come with registration.
const client = new SwapClient({ relayUrl: 'https://preprod-relay.fondaco.network', appId: 'demo', apiKey: 'demo' });
const wallet = await window.midnight['your.wallet'].connect('preprod'); // dApp connector 4.x
const r = await client.swap(wallet, {
give: 'tsSIT', want: 'NIGHT', amount: 25_000_000n, // tsSIT: Preprod's shielded test token, in USDM's place
privacy: 'public', // or 'shielded' / 'compliant'
receiver: { unshielded: myNightAddressHex },
onProgress: (p) => console.log(p.stage),
});
console.log(r.status.state, r.status.txId); Run /regression on the Preprod app from your wallet to check every path it supports, step by step, with timings. The wallet quickstart has the expected output of each step.
Embed in five minutes
Or put the swap on your page
The snippet inserts the swap as a sized iframe. Quotes go out under Fondaco's front-end with your app as the referrer, so your flow is attributed and you receive the channel share. An app key cannot stay secret in a browser; that is why embeds attribute by referrer.
<div id="swap"></div>
<script src="https://preprod-app.fondaco.network/swap/embed.js" data-app-id="your-app" data-target="#swap"></script> The live preview loads the swap from preprod-app.fondaco.network only when you ask for it.
Revenue share, in numbers
A worked example
A wallet routes a month of swaps through Fondaco and sets its own app fee. The protocol fee is Fondaco's, inside every fill; 30% of it on your flow comes back to you.
Illustrative volume and app fee; the protocol fee and the share are the configured values
| Monthly flow your users swap | 1,000,000 USDM |
| Your app fee, your choice: 20 bps | 2,000 USDM |
| Protocol fee on that flow: 4 bps | 400 USDM |
| Your share of it: 30% | 120 USDM |
| To you, a month | 2,120 USDM |
Both fees are shielded outputs inside each settlement, in the pair's shielded token. Your app fee arrives with every fill; the share is paid monthly by the treasury, on chain, after the statement.
Test it with us on Preprod
We send you the Preprod relay, an app key, test tokens and the /regression link, run it with your build alongside you, and record your wallet's profile.
The fondaco.network mailboxes go live with the domain registration.