k402
Testnet research software — unaudited, not for real value. Get set up on testnet-10 →
§ 0
Everything here is testnet-10: the coins are free, the services are real, nothing is for real value.

Get set up on testnet-10

Three steps, each ending in something you can run.

  1. § 1

    Get test funds

    A Kaspa key is the only account. Get TKAS for it from the testnet-10 faucet; a few hundred TKAS covers many paid calls at today's prices.

    Open the testnet-10 faucetfaucet-tn10.kaspanet.io (opens faucet-tn10.kaspanet.io) and paste a kaspatest: address from step 2.

  2. § 2

    Pick your wallet

    In the browser: the kUSD app creates or imports a key, sealed with a passphrase, and never sends it anywhere — it buys kUSD from the PSM and pays on the market. For an agent: a key file the kx402 (Node) or k402 (Python) client opens.

    • · Browser: open the kUSD app, choose Create new in the Wallet tab, copy the kaspatest: address for the faucet.
    • · Agent (Node): npm i kx402 && npx kx402 fetch-sdk, then point KASPA_X402_FUNDING_WALLET=wallet-key:<path> at a key file.
    • · Agent (Python): pip install k402; a KusdWallet over a key file and the kusd_pay binary.
  3. § 3

    Make your first 402 payment

    Call a listed resource unpaid and read the 402, then let the client pay and retry. The result carries the txid; a node, not a receipt, proves the payment.

    # see the paywall first: one unpaid request
    curl -si https://kaspa-402-summarize.kaspadev.workers.dev/exact | head -5
    # HTTP/2 402 Payment Required
    # payment-required: eyJ4NDAyVmVyc2lvbiI6Mi...   (base64 JSON: accepts[] = scheme, network, amount, payTo)
    // Node · KAS · kx402 (the k402 agent payer)
    import { openWallet, payExact, resolveWalletConfig, applyInput } from 'kx402';
    const wallet = await openWallet(resolveWalletConfig({ network: 'kaspa:testnet-10' }));
    const url = applyInput('https://kaspa-402-summarize.kaspadev.workers.dev/exact', { text });
    const r = await payExact(wallet, url, { maxAmountSompi: 300_000_000n });   // 402 → pay → retry; never over 3 KAS
    r.status, r.body, r.settlement.transaction                                 // the result and the txid to verify
    # Python · kUSD · k402, under an operator policy
    from k402 import KusdPayer, KusdWallet, SpendLedger, SpendPolicy
    payer = KusdPayer(wallet, registry_url="https://market.kaspa-402.org", network="testnet-10",
                      policy=SpendPolicy.load("policy.json"), ledger=SpendLedger("spend.db"))
    route = await payer.pay_best("summarize", json_body={"text": "..."})

    Browser instead of code: on the market, unlock the wallet from step 2, buy a few cents of kUSD, and pay a listed service from the page.

Then: the five agent steps on the landing page, validate your own paywall before listing it, or the glossary for any word here.