Skip to content
Kuska

Kuska

Pay on delivery, without anyone paying upfront

Created on 13th September 2026

•

Kuska

Kuska

Pay on delivery, without anyone paying upfront

The problem Kuska solves

In B2B and social commerce across Bolivia and other emerging markets, every sale starts with a standoff: the supplier wants to be paid first, and the buyer doesn't want to pay for goods that haven't arrived. Today that gap is covered in one of three ways, all bad:

  • Prepayment by bank transfer or informal USDT over WhatsApp. The buyer carries all the risk and has no recourse if the goods never show up.
  • Cash on delivery. Riders carry cash, sellers wait days to reconcile it, and it only works face to face.
  • Credit between people who already trust each other. New suppliers and new customers are locked out.

Kuska is on-chain escrow for pay-on-delivery commerce, built on HSK Chain.

  1. The buyer pays in a digital dollar. The funds go into a smart-contract escrow, not to the seller and not to us.
  2. The rider marks the delivery and shows a QR code. The QR carries only an order reference, never the amount, so a rider can't forge a different amount.
  3. The buyer scans and confirms. The escrow releases the payment to the seller instantly, with a verifiable receipt on HSK Chain.

It protects both sides, not just the buyer:

  • Nothing was ever delivered → after the delivery deadline, anyone can trigger a full refund to the buyer.
  • Delivered, but the buyer never confirms → after a dispute window, the seller gets paid.
  • Something went wrong → the buyer opens a dispute inside the window, and an arbiter resolves it. The arbiter is centralized in this version, and we say so.

Built for people who don't know what a wallet is:

  • No seed phrase and no gas. The buyer only signs: an EIP-2612 permit plus an EIP-712 authorization that binds seller, amount and deadline.
  • A relayer pays the HSK gas. The relayer holds no privileges: every action is authorized by a user signature and every contract function is permissionless. If our server disappears, users can still release, dispute or refund on their own.
  • Plain language in the app: "custody", "confirm", "receipt code". No blockchain jargon.

Who uses it: wholesalers and distributors selling to small shops, marketplace and social-commerce sellers, and any two businesses that don't know each other yet.

Why HSK Chain: it positions itself as a compliance-first chain for PayFi and stablecoins, which is exactly the rail B2B settlement needs. Kuska targets USDC.e on HSK Chain mainnet (Circle's FiatTokenV2_2, which supports gasless permit). The contract is token-agnostic: the same escrow runs with USDC.e or with our permit-enabled test token.

Live on HSK Chain mainnet (chain 177). The public app runs on mainnet, and all three contracts are source-verified on hsk.blockscout.com:

  • Demo, running on mainnet: https://kuska-beta.vercel.app
  • Escrow KuskaEscrow used by the live app, bound to our permit-enabled test token: 0x955e09d2D14431f491F8E80A4db3CE82A2b3Dba1 · MockUSD: 0x1dfAC4096b94Ed6d892223573d289B8165695dB0
  • Escrow KuskaEscrow bound to USDC.e, the production configuration, ready for its first real payment: 0xD11f19dC37a98b5008f7Ad60A93D93fd92cab644
  • Two full gasless deals confirmed on mainnet: deposit → seller-signed delivery claim → buyer release, with buyer and seller holding 0 HSK. Release txs 0xd21141acb8daf9466a6a32ab2c43476ebf29c86021fefad93cef5a77a34b2355 and 0xf1e41b9eea2500dffde4eb8479da31b8d7ab981581f443ec648f5d7f810dd4b4, the second one end to end through the public app.
  • The dollar in the live app is mUSD, our own test token, and it has no real value. That is deliberate and we say it out loud: people can try the whole flow on mainnet without risking funds. It is also forced by the market — there is no usable on-chain USDC.e liquidity on HSK mainnet today (the only WHSK/USDC.e pool holds 0.000001 USDC.e), and the liquid USDT has no EIP-2612 permit, which the gasless flow needs.
  • Source, with every address and tx hash: https://github.com/JoseluisLarrazabal/kuska

Also deployed on HSK Chain testnet (chain 133), which we use for development and for time-based scenarios: escrow 0x5dE999B6360494dd704369190bB8d49cc5e5328d, MockUSD 0x64D9707dFf7e9c49B36b5025A70177eFe624793A.

Roadmap:

  • the first real USDC.e payment through the mainnet escrow;
  • seller onboarding gated by HashKey's on-chain KYC SBT;
  • EIP-3009 receiveWithAuthorization deposits;
  • multisig or decentralized arbitration and milestone releases;
  • delivery history as collateral for receivables financing (RWA);
  • off-ramp to local currency.

En español: custodia contra entrega en HSK Chain. El comprador paga en dólar digital a una custodia on-chain, el repartidor registra la entrega y muestra un QR, el comprador lo escanea y el vendedor cobra al instante. Si nunca se entregó, el comprador recupera su plata; si se entregó y el comprador no responde, el vendedor cobra tras la ventana; si hay problema, decide un árbitro. Sin semilla ni gas para el comprador, y el servidor no tiene privilegios: si desaparece, la plata sigue recuperable. La app pública ya corre en HSK Chain mainnet, con los contratos verificados y deals completos sin gas confirmados on-chain. El dólar de la demo es un token de prueba, sin valor real, a propósito: así cualquiera prueba el flujo en mainnet sin arriesgar plata.

Challenges we ran into

Not every stablecoin on HSK Chain can be moved gaslessly

  • The bridged USDT on HSK Chain is a standard OP-Stack mintable token without EIP-2612 permit. The buyer would need HSK for gas just to approve.
  • We read the verified contracts on Blockscout and found that USDC.e is Circle's FiatTokenV2_2, which does support permit.
  • We designed the escrow around permit-based deposits and built our test token to match that interface.

Our first escrow design protected the buyer but exposed the seller

  • A simple "refund after deadline" lets a buyer receive the goods, never confirm, and take the money back.
  • We redesigned the state machine: the seller records a signed delivery claim; a dispute window opens; silence releases to the seller; refunds are only possible if no delivery attempt was ever recorded.
  • Foundry tests cover exact boundary timestamps and race conditions (claim vs. refund, dispute vs. release).

A permit signature alone doesn't bind the deal

  • An ERC-20 permit only says "this spender may take X tokens". It doesn't say for which order, which seller or which deadline, so a malicious relayer could redirect it.
  • We added a separate EIP-712 DepositAuthorization(orderRef, seller, amount, deliveryDeadline) that the contract verifies. Each action has its own typehash, so a signature for one action can never be replayed as another.

The phone camera opens a different browser

  • Scanning a QR with the native camera opens the default browser. That browser may not hold the buyer's local signing key.
  • We added three equivalent paths: an in-app QR scanner in the same session; the QR URL for the native camera; and a "Confirm delivery" button that appears as soon as the chain shows the delivery was claimed.
  • Buyer actions are only offered when the local account is the on-chain buyer, and the order page never silently creates a new account. A device that is not the buyer is told where to open the order instead.

Gas and nonces in a serverless relayer

  • Concurrent serverless invocations can reuse a nonce, and the testnet faucet gives only 0.1 HSK per address per day.
  • The relayer verifies every signature off-chain, simulates the call, and only then sends, waits for the receipt and retries on nonce errors.
  • Invalid or replayed requests never cost gas.

Demonstrating time-based rules on a real chain

  • Refunds and dispute windows depend on time passing, and there is no time travel on a public network.
  • Our testnet deployment uses a 90-second dispute window, and a demo panel arms a normal deal and a 2-minute-deadline deal with one click each, so both the release and the refund paths can be executed and recorded end to end.
  • The mainnet deployment keeps the real 24-hour window, so the live demo shows the release path, and the refund path is shown with recorded captures from testnet rather than faked on stage.

A relayer that could pay gas twice

  • Our first retry logic detected nonce errors by matching /nonce/i against the error message.
  • viem pretty-prints the request arguments, including nonce, into every write error's message, so every failed write looked like a nonce error. The relayer could have broadcast a second transaction.
  • We now classify errors by viem error type, walking the cause chain, never by message text. We also added an in-process mutex around the nonce read and send. Cross-instance locking is documented as an open limitation.

Never losing a buyer's money in the UI

  • A deposit can land on-chain even when the HTTP response fails: a platform timeout, an RPC timeout after broadcast, or a dropped connection. Our first version dropped the order reference on any error, so funds could sit in escrow with no link to open them, and a retry funded a second order.
  • We inverted the logic. The app now assumes a transaction may have been sent, unless the relayer's error code proves it was rejected before writeContract (invalid request, invalid signature, failed simulation, misconfiguration). We checked each of those codes against the relayer's control flow.

Time-based rules that didn't update on screen

  • The dispute window was never actually read from the contract: react-query v5 treats initialData with staleTime: Infinity as fresh and never calls the fetcher.
  • Deadline-dependent buttons ("request refund", "release after window") only re-rendered when polled data changed, so they never appeared without a reload.
  • We added a ticking clock hook and pure, tested timing functions that mirror the contract's exact boundary comparisons. We verified in a real browser that "request refund" appears on its own the second the deadline passes.

Two devices, one demo seller

  • Every device generates a random burner key, so no seller device could ever match the demo seller address the pre-staged deals point to.
  • Embedding the key in the bundle would publish it. Instead, the operator imports it by hand on the seller device.
  • Our first import silently overwrote the previous key. Now previous keys go to a bounded, restorable history, and the app asks for confirmation before replacing an identity that holds orders or funds.

A deployment that returned 404 on every route

  • Our first Vercel config used legacy builds from the repo root. We reproduced the failure with a local vercel build: the static output landed under a web/ prefix, and the functions kept a .ts suffix. Neither route matched.
  • We moved to zero-config with the project rooted at web/, plus a single SPA rewrite that explicitly excludes /api. That keeps the QR deep link /pedido/<ref> working on refresh.

Serverless functions that passed every local check and still failed in production

  • Type-checking, tests and the build were green, yet /api/* returned 500: Vercel transpiles each function without bundling, and Node's ESM loader rejects relative imports without a file extension. Our bundler-based toolchain resolved them silently.
  • We reproduced it locally by transpiling without a bundler and importing under plain Node ESM, added .js extensions across the function import graph, and added a test that walks that graph and fails on any extensionless import.
  • The next deploy loaded but hung until timeout (504): a default-exported (Request) => Response handler is treated as the legacy (req, res) signature, so the returned response was ignored. We switched to named GET/POST exports, with a test that forbids a default export.

Source verification blocked by the explorer, twice

  • First wall: the gateway in front of the HSK testnet Blockscout caps request bodies at ~102 KB (HTTP 413); our flattened sources are 129–143 KB. We stripped comments with a string-literal-safe pass (52–62 KB), confirmed the stripped sources still compile to identical runtime bytecode, and the explorer accepted the submission.
  • Second wall: verification still never completed. The testnet Blockscout's allowed evm_version list stops at cancun, and our contracts are compiled for prague. Any unlisted value is silently replaced, so no accepted setting can reproduce the deployed bytecode. Sourcify, the fallback, currently can't reach chain 133 (its registered RPC has an unresolved API-key placeholder).
  • The mainnet Blockscout does offer prague, so every mainnet contract — the ones the live app uses — is source-verified. The testnet contracts stay reproducible instead: our local build matches their on-chain bytecode byte-for-byte, including the metadata hash.

Going to mainnet with no on-chain USDC.e to buy

  • When mainnet gas arrived, we checked liquidity before deploying: the only WHSK/USDC.e pool on HSK mainnet held 0.000001 USDC.e (every quote returned 0), and the liquid USDT has no permit. There was no way to acquire the dollar we designed for.
  • We deployed and verified both configurations: the production escrow bound to USDC.e, and a second escrow bound to our permit-enabled test token. That let us run a full gasless deal on mainnet with the unchanged app and relayer, and keep the USDC.e escrow ready for its first real payment.
  • We then pointed the public deployment itself at mainnet — same code, only configuration — and ran a second full deal end to end through it, confirming on-chain that the seller was paid and that buyer and seller still held 0 HSK.
  • One honest consequence: our in-app faucet is disabled on mainnet, so demo buyers are funded beforehand by calling the test token's public faucet() directly. We would rather carry that friction than ship a faucet button on a mainnet deployment.

A reentrancy question we had to answer precisely

  • claimDelivery and dispute are not nonReentrant, and they write state after an ERC-1271 signature check that calls into arbitrary contracts.
  • We confirmed it is safe: the checks move no funds, and OpenZeppelin v5.1.0 SignatureChecker performs the ERC-1271 call with staticcall, so a malicious smart-account signer cannot write state during verification. We document that this safety depends on that staticcall.

How we verified it

  • 35 Foundry tests and 203 web/relayer tests;
  • three rounds of code review plus a security review;
  • the full flow run in a real browser against HSK testnet, with every state change confirmed on-chain: gasless deposit, delivery claim, QR, buyer release, and an expired-deadline refund;
  • on HSK mainnet: three contracts deployed and source-verified, and two full gasless deals (deposit, delivery claim, release) confirmed on-chain with buyer and seller holding 0 HSK — the second of them driven entirely through the public deployment.

Tracks Applied (3)

General (Obligatorio)

Kuska — custodia contra entrega en HSK Chain, by Team Nusita. On-chain stablecoin escrow for pay-on-delivery B2B and soc...Read More

Road to ShanhaiWoo

Kuska is a real-world Ethereum application for local commerce in an emerging market: it replaces cash on delivery and un...Read More

Ethereum Applications Guild

Real World Applications powered by HSK Chain

Area: DeFi, Stablecoins & Payments. The live application runs on HSK Chain mainnet (chain 177), and every contract it us...Read More

Ethereum Applications Guild

Discussion

Builders also viewed

See more projects on Devfolio