Skip to main content
intent-solver is the open-source reference solver (MIT). One deployment serves every route: Lightning, onchain, and asset exchange. It receives quote requests over a Nostr relay and fills the swaps that users fund. Every connection it makes is outbound, so it needs no open ports. This page uses release v0.7.1. Wallets need @arkade-os/swap 0.1.11 or later to get an asset quote from it. The solver.example.json file and the runbook describe every setting. To move a solver from .env, see Migrate from Environment Variables.

Before You Start

  • Node.js 22.6 or later (up to 26), and pnpm 10 or later
  • The emulatorUrl value: the solver refuses to start without it. Emulator Endpoints lists the URL for each network
  • Docker with Compose, if you run the solver in a container
The solver spends its inventory unattended. Start with small amounts, and back up the mnemonic and the database directory. Run one process per mnemonic: two processes on the same mnemonic can spend the same coins.

Install

Clone the release and build it:
Every setting on this page goes in one JSON document, solver.json, in this directory. The solver reads the file that SOLVER_CONFIG names:
On a platform that only lets you set environment variables, put the whole document in SOLVER_CONFIG_JSON instead. Set exactly one of the two. The document is strict: the solver refuses to start on an unknown key or a wrong type, and names its path. Never commit solver.json: it holds the mnemonic. Once you create it, run chmod 600 solver.json, so that only its owner can read it. With Docker Compose, that owner must be the container’s node user, UID 1000: run sudo chown 1000:1000 solver.json too.

Configure

This configuration runs the smallest solver. It connects to Arkade, takes quote requests from a Nostr relay, and fills asset swaps from its Arkade wallet. It needs no LND node, because a Lightning or onchain route runs only when you add it. Start from this document and set only the fields this page names: a copy of solver.example.json also sets fields that this page leaves at their defaults on purpose. To test on mutinynet, a Bitcoin test network, use the Mutinynet tab.
  • $schema lets an editor check and complete your document.
  • network selects the Bitcoin network. The solver refuses to start when the operator reports another network.
  • name names the solver on its card. Without it, the solver cannot publish the card or bid on published requests, and it logs an error every 30 seconds.
  • relay.url is the Nostr relay where wallets send quote requests. Use a wss:// URL, or ws:// for a local test relay.
  • admin.port serves the admin console at http://127.0.0.1:8788.
  • offers.quoteValiditySeconds sets how long a quote stays valid, from 5 to 900 seconds, with a default of 30. The wallet must fund the swap, and the solver must fill it, before the quote expires. On mutinynet that can take up to 100 seconds, so the Mutinynet tab sets 300. Elsewhere, raise it only as far as your swaps need, because the solver carries the price risk of a quote until it expires.
The admin console has no authentication: anything that can reach the port can move money. It listens on loopback only unless you set admin.host. The solver keeps its Arkade wallet and its swap database in .data, and storage.dir moves them. Back up this directory often. If the database row of a funded swap is lost, the solver can no longer claim or refund that swap.

Start the Solver

pnpm cli rebuilds before it runs, so build output comes first, and the solver then runs in the foreground. In production, run it under a supervisor that restarts it, such as systemd with Restart=always, and set SOLVER_CONFIG there to the full path of the file.

Check That It Runs

When the solver connects to the relay, it logs a line like this one. The key at the end is the solver’s public key, which its card lists as discovery_pubkey.
With Docker Compose, docker compose ps also reports the container as healthy while the relay connection is up. To fund the solver, open Wallet in the admin console, then Details under Arkade, and copy the Address. Send BTC, and each asset you sell, to that address.

Choose Routes

Every route charges nothing until you set a fee. Restart the solver after you change solver.json, and test each route with small amounts before you add production inventory. On mainnet, each Lightning or onchain swap is between 500 and 50,000 sats by default. limits.maxSwapSats, and the minSats and maxSats of each route, replace this range in either direction. Because the solver pays before it collects, the largest swap you allow bounds what one failed swap can cost you. limits.maxExposedSats bounds the total in flight, and defaults to three times limits.maxSwapSats. Releases up to v0.6.0 kept every limit inside the default range. If one of yours is outside it, the solver lists it in a warning at startup, because it now applies as set. A Lightning or onchain route runs only when corridors names it: To turn a route off and keep its settings, set enabled to the JSON boolean false. The solver refuses a field the route cannot use, such as feeCapSats on a Lightning route. The snippets below show only the keys they change. Merge them into your solver.json: the solver refuses a key that appears twice in one object.

Assets

Asset exchange swaps BTC for an asset, with both sides settling through Arkade. The solver serves each market over RFQ: a wallet asks for a quote over your relay, and the solver answers with a signed quote. Each market is a row in the admin console.
  1. Open the console at http://127.0.0.1:8788, go to Pricing, and select Add market.
  2. Paste the 68-character asset id in Asset. BTC is the other side of every market. The console looks up the ticker that the issuer set, and uses it as the market’s symbol. If it finds none, or another market already uses it, type a Symbol such as USDT.
  3. Confirm the decimals with the issuer. The console looks them up too, but nothing checks them, and a wrong value misprices every swap by a power of ten. If it finds none, set Decimals yourself.
  4. Set Fee, your spread in basis points.
  5. Leave the client pays it checked under Carrier (see Carrier sats).
  6. Set Price feed to a URL that returns the price of one BTC in the asset. The console reads it when you leave the box, and shows the price it found. For a feed other than Binance or CoinGecko, also set JSON path, a JSON pointer to the price in the feed’s reply.
  7. Set the Limits of each direction, in whole units of what the wallet receives: the asset when the wallet gives BTC, and BTC when it gives the asset. A direction without a min and a max is closed.
  8. Type an amount in the preview to see what a wallet would be quoted.
  9. Select Keep in draft, then Apply. The console fetches the feed before it stores the row.
The market is live as soon as you apply it: the solver quotes it on the next request, with no restart and no change to solver.json. Edit or remove it from the same page. Fills pay out of the solver’s Arkade wallet. Hold the asset for wallets that buy it, and BTC for wallets that sell it.

Carrier sats

An asset never moves alone: it rides on a small BTC output, the carrier, worth the operator’s dust amount. The Carrier line of the market form shows the amount and who pays it:
  • With the client pays it checked, which is the default, the quote nets the carrier out of whichever side supplies it, and states it as carrier_sats.
  • With it unchecked, the solver pays the carrier out of its margin on every asset it sends.
  • follow the deployment default, under Advanced, follows price the RFQ carrier in the Deployment limits & carrier default panel of Pricing, which is off until you check it.
Keep the box checked unless your spread covers the carrier. The spread covers it only on swaps larger than the carrier divided by your fee rate. With a 330-sat carrier and a fee of 50 basis points, each swap that pays out an asset loses money below 66,000 sats, and the console preview shows the loss.

Lightning

Pay via Lightning pays Lightning invoices for wallets, and Receive via Lightning accepts Lightning payments for them. Lightning needs an LND node. Connect LND first, then add the routes. Add only one to serve one direction. This example charges 0.30% on each payment and each receive:
solver.json
A send adds the fee on top of the invoice amount, and a receive takes the fee out of what the solver pays into Arkade. To add a fixed charge per swap, set feeFlatSats on the route. The solver card carries the flat fee as fee_flat, so a Lightning route with a flat fee still publishes a card. Bids on published Lightning send requests carry it too. On mainnet, Receive via Lightning runs only with rails.lightning.receiveAcceptUnilateralGap set to true. Without it, the solver refuses every receive quote with recourse_window_unservable. The setting accepts a bounded risk. Suppose the operator is unavailable or censors for longer than its unilateral exit delay. If the deadline of the incoming Lightning payment has also passed, a user can take both sides of a swap. The maxSats of this route bounds that loss per swap, and on mainnet the solver refuses to start without it. Set it to the most you accept to lose on one swap, such as 20000:
solver.json
Fund both directions:
  • Sends pay the invoice from the channels of LND, so LND needs outbound liquidity.
  • Receives take the payment into LND, so LND needs inbound liquidity. The solver then pays the user from its Arkade wallet.

Onchain

Pay via Bitcoin pays Bitcoin addresses for wallets. Pay via Bitcoin needs an LND node, even without Lightning. The solver pays out of the onchain wallet of LND, so fund that wallet. Connect LND first, then add the route. It also needs an Esplora REST API. LND cannot report who spent an HTLC, or whether the solver’s own transaction reached the chain. Without rails.onchain.esploraUrl, an onchain swap cannot advance. Every fill broadcasts an onchain transaction, so set a fee that covers the miner fee. A send pays it to fund the onchain HTLC. These are example values:
solver.json
  • feeBps is the spread, in basis points.
  • feeFlatSats is a fixed charge per swap.
  • feeCapSats turns on live pricing: the solver charges the transaction size times a sampled fee rate, up to the cap. The flat charge then applies only when no fee estimate is available.
  • feeMinSats sets the least a fill costs. The solver refuses to start if you set it without the cap.

Test a Swap on Mutinynet

You can test the asset markets end to end on mutinynet before you fund a solver on mainnet. A test wallet issues two test assets, funds the solver, and then swaps BTC and an asset in both directions. The examples call the assets USD₮ and EUR₮, and use @arkade-os/sdk 0.5.14 and @arkade-os/swap 0.1.16. You need:
  • A solver running with the Mutinynet tab of Configure
  • Node.js 22.13 or later, which the SDK requires
  • About 100,000 sats of test BTC on mutinynet: 55,000 for the solver, and the rest for the test wallet

Create a Test Wallet

The test wallet needs a mnemonic of its own, apart from the solver’s. Generate one in the intent-solver directory:
In a second terminal, create a folder for the wallet next to the intent-solver directory, and install the SDK and the swap client. The swap client reaches the solver’s relay through nostr-tools, and the SDK listens for events through eventsource:
Export the mnemonic as ARKADE_MNEMONIC, then save this file in the folder. Every later script imports the wallet from it, and you run each one with node <file>:
wallet.mjs
This script prints the wallet’s address and balance:
address.mjs
Send test BTC to that address from another Arkade wallet on mutinynet. If you have none, send from the mutinynet faucet to the wallet’s boarding address, then board, as Boarding & Offboarding shows.

Issue Two Test Assets

This script issues 1,000 units of each asset, at 6 decimals. Skip it if you already hold the assets you want to list.
issue.mjs
It prints the id of each asset, 68 hex characters long. Export the two ids as USDT_ID and EURT_ID, because the scripts below read them. Issue Assets explains issuance.

Fund the Solver

The solver pays out of its own wallet, so it needs BTC for wallets that sell an asset, and each asset for wallets that buy it. Copy its address from the console, as Check That It Runs shows, and export it as SOLVER_ADDRESS. This script sends it 55,000 sats and 500 units of each asset:
fund-solver.mjs
Each asset payment also sends 330 sats, because an asset rides on its carrier. The Wallet page of the console then shows the BTC, and lists both assets under Details.

Open the Markets

Open one market for each asset, as Assets describes. A market pairs BTC with one asset, so two assets need two rows. These values work for a test, and the other fields keep their defaults: The console reads the symbols USDT and EURT, and the 6 decimals, from the metadata of the assets. With these limits, a wallet can buy 1.00 to 100.00 of an asset, and sell an asset for 1,000 to 50,000 sats. Once you apply both rows, the Overview page lists each market as served by rfq and trading.

Pin the Solver Card

The swap client finds a solver’s markets on its card. Until you publish the card, give it to the client directly: in the intent-solver directory, print the card into the test wallet’s folder.
The command works while the solver runs. Because a pinned card is a copy that nothing updates, print it again after you change a market. Get Discovered shows how to publish the card instead.

Swap BTC and an Asset

This file adds the swap client to the wallet, with the pinned card:
client.mjs
The next script sells 5.00 USD₮ for BTC, then waits until the solver fills the swap:
swap.mjs
To buy an asset with BTC, swap give and take, and set amount in sats. The quote then takes the asset’s 330-sat carrier out of those sats. The client refuses maxFee on any swap whose two sides are different assets, BTC included, because the solver’s own price feed sets the fee. To check the price before you fund, call quote instead of exchange, compare quote.take.amount with a price you trust, then call accept (Exchange Assets). On mutinynet, a swap can take up to two minutes from the quote to filled. The Activity page of the console lists each swap and its state.

Check a Swap That Did Not Fill

The solver never fills a deposit after its quote expires. The swap’s row in the console then reads refused, with the reason not filled: quote_expired. One minute after the quote expires, the swap client cancels the swap by itself, which returns the deposit, and the script prints cancelled. To take the deposit back sooner, stop the script and run this one from the test wallet’s folder:
cancel.mjs
It prints no open swap if the client has already cancelled the swap. Then raise offers.quoteValiditySeconds in solver.json, and restart the solver. A quote that the wallet never funded also reads refused, with the reason quote expired before the deposit was observed. In that case no money moved, and nothing needs fixing.

Get Discovered

A running solver does not make you findable. Wallets learn about you from a solver card: hand it out privately, publish your own registry, list in the public one, or publish the card on Nostr.

Get Discovered

Generate your solver card and choose how wallets find you.

Arkade Intents Protocol

The index of the focused Intents reference pages.

Appendix: Connect LND

The Lightning and onchain routes both run through one LND node. Asset exchange never uses it, so set this up only when you add one of those routes.
solver.json
socket is the gRPC address of LND. For the certificate and the macaroon, set either the file path (certPath, macaroonPath) or the file content as base64 (cert, macaroon). The solver refuses to start if you set both forms of one. With Docker Compose, the container cannot read files on the host. Set cert and macaroon as base64 instead of the path forms, and set socket to an address the container can reach. Restart the solver, then run the status check. It prints the LND and Arkade balances, the Arkade address, and the swap limits, then exits. It fails on a solver without LND.

Appendix: Migrate from Environment Variables

Releases up to v0.4.0 read their settings from .env. The JSON configuration reads no setting from the environment, and refuses to start while any old variable is still set, naming it. HOST and PORT are ignored with a log line instead: set http.host and http.port.
  1. Drain onchain receives. If your solver serves the onchain:BTC->arkade:BTC route, let the old version finish every swap on it first. Version v0.5.0 removed the route, so later versions cannot finish its swaps, and the solver refuses to start while one is still in flight.
  2. Update your checkout to the version this page uses:
  3. Export the document. Build the new version, then run it once under your old environment, with your existing data directory, so the export can read the stored asset markets. The output holds every secret from .env, so keep the file private.
    The solver checks the export with the same loader that reads it at startup, so a value the document cannot hold fails now, by path.
  4. Remove every old variable from .env, the Compose file, and your platform settings. Point SOLVER_CONFIG at solver.json, or put the whole document in SOLVER_CONFIG_JSON. The Compose file sets SOLVER_CONFIG for you.
  5. Restart the solver. A variable you missed stops it at startup, before anything moves. To roll back, run the old version with the old environment: neither version starts with the other’s configuration.
Asset market directions are now named by leg, such as arkade:BTC->USDA and USDA->arkade:BTC, instead of ASSET_<SYMBOL>_BUY_ENABLED and ASSET_<SYMBOL>_SELL_ENABLED. Overrides you made in the admin console carry over unchanged. Revert to config file, in the console, resets the console or one market to the document after showing every change.