← Blog

The Solana Deeds #6: An API that charges a tenth of a cent per call

HTTP 402 put to work with x402 on Solana: a paid API explained as a shop counter, a program that pays with no account, what a tenth-of-a-cent sale costs to settle, and a facilitator fault reported and fixed upstream in under three hours.

Nissan Dookeran9 min readSolanaCoding AgentsAgent Workflows

Picture a shop counter. You ask for something, and the shop hands you a slip with the price on it.

You put the money in an envelope and sign it, but you leave off the stamp. A clerk checks the envelope, stamps it and posts it. When it arrives, you get the goods.

That's a paid API call with x402. The slip is an HTTP 402 reply. The envelope is a Solana transaction. The clerk is called a facilitator, and the stamp is the network fee, which the clerk pays.

For Deed #6 we built one: an API that charges a tenth of a cent per call, and a program that pays it with no account and no API key. Deed #5 was a checkout a person pays by scanning a QR code. Here the buyer is software. It's on devnet, Solana's practice network, so every payment below is test money.

The demo is in two parts, each under three minutes: part one, the problem and the payment cycle, and part two, settling on Solana and what it costs.

Why has HTTP 402 sat unused since 1997?

Every web reply opens with a status code. 200 is OK. 404 is Not Found. 402 is Payment Required, and its whole entry in the January 1997 specification reads: "This code is reserved for future use." The current specification, from 2022, still says so.

Try selling something for a tenth of a cent. Stripe's listed card price is 2.9% plus 30 cents a transaction. The fee is 300 times the sale.

And my buyer is a program. It has no card and can't fill in a signup form. It can sign a transaction.

x402 is a protocol that gives 402 a job. Coinbase published it in May 2025. By July 2026 its site was counting about 75 million payments in 30 days, worth about 24 million US dollars, as CoinDesk reported it: an average of 32 cents. Cloudflare has been trialling per-page charges for AI crawlers since July 2025, and the reply it sends is also an HTTP 402, though with its own headers and not x402's.

What we built is the plainest case: data for sale, one call at a time.

What does the counter look like between two machines?

The x402 exchange: the client asks the API for a quote; the API answers HTTP 402 with the price, the token and who to pay; the client signs a USDC transfer on Solana and asks again with the signed payment attached; the API has a facilitator verify it and then settle it; the facilitator adds the fee payer's signature and sends it to Solana; once it is confirmed the API answers HTTP 200 OK with the data and the transaction signature.

The client asks. The server answers 402 and says what it wants: 0.001 USDC, which token, which account, which network.

The client builds a USDC transfer for that amount and signs it as the owner of the money. It leaves the fee payer's signature empty. Then it asks again, with the signed transaction attached.

The server hands that to a facilitator, which checks it pays the right amount of the right token to the right account, signs as fee payer and sends it. The server releases the data only after the facilitator says the transaction settled.

Because someone else pays the fee, the client holds USDC and no SOL at all.

The code on each side is small, since the x402 packages do the exchange. The server puts a price on one route. The client wraps fetch with a wallet and the most it may pay for one call, and refuses a higher price before it signs anything.

Did a program actually pay?

Yes, on devnet, through the public facilitator at x402.org. The call with no payment got a 402 with the price. The paid call got a 200, the data, and a line in the server's log with the payer and the transaction signature. From the 402 to the 200 took 1.97, 1.92 and 2.09 seconds in three paid calls.

The same client code runs in a browser. We added a one-screen page, and I paid it from my own Solflare wallet: ask, connect, approve in the wallet, and the data comes back with a link to the transaction.

A paying program also needs a limit. Given a budget for two calls and asked to make three, the client paid for two. On the third it read the price, saw it didn't fit what was left, and signed nothing.

Who can be the clerk, and why Solana?

x402 doesn't say what money to use. A 402 reply lists the ways the seller accepts, and the buyer picks one.

So the card companies are in. Visa, Mastercard and Stripe were among the premier members when the Linux Foundation announced the x402 Foundation in July 2026. Stripe already takes x402 payments in a preview: USDC on a blockchain, landing in your Stripe balance. Its smallest payment that way is one cent. My call costs a tenth of that.

I settled on Solana myself, for three things I could measure. The fee is flat: 5,000 lamports a signature, whatever the amount. It was quick, about two seconds. And the fee payer can be someone other than the buyer.

What does a tenth-of-a-cent sale cost to settle?

Most of the sale.

One of the payments is on Solana's explorer. Its fee was 10,001 lamports. With SOL at 72.48 US dollars on 23 November, by CoinGecko, that is 0.0725 of a cent: 72% of a tenth-of-a-cent sale.

The fee is flat, so the price I picked matters. At a cent a call the same fee is 7%.

Somebody has to cover it. Through x402.org, the hosted facilitator did. We also ran the same facilitator code inside our own server, and then the merchant's key paid the fee on every payment it collected.

The buyer's wallet can raise the fee too. My wallet's payments cost 12,000 lamports, not 10,001. On the chain, the priority fee in those transactions is higher than the one our client sets. That the wallet raised it is my reading of the transaction; Solflare hasn't confirmed it. Either way a buyer's wallet changed a fee that someone else paid, and the facilitator accepted it.

What broke?

The hosted facilitator said it accepted Solana's newer transaction format, version 1, so our client used it. Three payments went in. Each came back "pending": sent, not confirmed. None ever arrived.

The lesson I took: don't trust a pending reply. Look the transaction up on the chain. The chain said there was no transaction.

Claude traced the cause to the facilitator's own signature. Its signer came from an older version of a Solana library than version 1 needs, and the signature it added as fee payer didn't verify. Claude reproduced that offline with made-up keys.

I reported it as issue 4383 at 08:43 UTC on 23 November. The maintainers merged a fix at 11:25 UTC the same day, 2 hours and 42 minutes later.

In between, the client was held to the older format, version 0, which worked. After the fix I had that hold lifted. Since then eight of eight version 1 payments have settled through x402.org, one of them from my Solflare wallet. Eight is still few.

Which faults were ours?

Two, and in both the buyer paid and got nothing.

The first: a facilitator could take the payment, then time out and name no transaction. The buyer got a refusal. The money had moved, and nobody had a signature to look for. Now the server looks on the chain for the buyer's own signature, which is inside the proof the buyer sent, and serves if the payment is there.

The second: a payment could arrive after the server and the client had both stopped waiting. Now the server remembers a payment it couldn't see settled. When the same signed proof is sent again and its transaction is on the chain, the buyer is served.

Writing the tests for those turned up a third. The same proof could be served twice, and three requests racing with it were all served. That hole had been there since an earlier fix. The server now remembers what it has served and refuses it the second time.

Both fixes are shown in tests only, with a facilitator made to misbehave. Neither fault can be caused on devnet at will. And the memory is in the server's own process, so a restart loses it.

Why are there two videos?

I asked for two parts, each under three minutes. I recorded part one and most of part two, found part two's script flat, and had both rebuilt around a clearer split: the cycle first, then what it runs on and what it costs.

One more thing went wrong at the end. The last card of both parts gave the address of the private repository. I caught it after I had recorded and assembled both parts. Only the card's picture had to change, so nothing was re-recorded.

I narrated all 17 scenes myself in the voice booth. A synthetic voice read the drafts so I could review the words; it isn't in either video.

What's still open

One endpoint, one fixed price. The data it sells is a fixed sample. The server's memory of payments doesn't survive a restart. The page has been paid from one wallet, and it doesn't ask a wallet whether it can sign version 1. Nothing manages the fee payer's key when the server settles for itself. It runs on my laptop; there's no hosted version.

Nobody but Claude has reviewed the code.

You can check the rest yourself. The source is public as a snapshot, with 41 tests that sign, send and confirm real transactions on a local Solana runtime. With a devnet keypair holding a little SOL and devnet USDC, pnpm devnet:demo runs the whole thing: the unpaid call, an underpayment, the paid call, a replay, both ways of settling and the budget. The last run cost 25,001 lamports, and the USDC came back.