Dexter
Dexter
Docs

Paying for Resources

Paying for an x402 resource requires no account, no API key, and no signup. You need a wallet with USDC and a client that speaks x402.

The Payment Flow

sequenceDiagram
    participant You as Your Agent/Client
    participant API as Paid Endpoint
    participant Fac as Facilitator
 
    You->>API: Request resource
    API-->>You: 402 + payment requirements
    You->>You: Build USDC transfer, sign with wallet
    You->>API: Retry with X-PAYMENT header
    API->>Fac: POST /settle (verify + submit)
    Fac-->>API: Settlement proof
    API-->>You: 200 OK + data

Step by step

1. Request the endpoint. Any HTTP method works. If the resource is paid, you get back a 402 Payment Required with a JSON body listing what the seller accepts.

curl -i https://x402.dexter.cash/api/jupiter/quote
HTTP/1.1 402 Payment Required
 
{
  "x402Version": 2,
  "accepts": [{
    "scheme": "exact",
    "network": "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",
    "asset": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
    "amount": "10000",
    "payTo": "...",
    "maxTimeoutSeconds": 60,
    "extra": { "feePayer": "..." }
  }]
}

2. Pick a chain. The accepts array may list multiple chain/asset pairs. Pick the one your wallet is funded on.

3. Build and sign. Construct a USDC transfer matching the amount and payTo, sign it with your wallet. On Solana, the facilitator's feePayer pays transaction fees for you.

4. Retry with payment. Base64-encode the signed transaction and send it in the X-PAYMENT header:

curl -H "X-PAYMENT: <base64-payload>" https://x402.dexter.cash/api/jupiter/quote

5. Get your data. The server forwards your payment to the facilitator, which verifies it, submits it on-chain, and returns a settlement proof. You get the API response.

Using the SDK

The @dexterai/x402 SDK handles steps 2-4 automatically:

import { wrapFetch } from "@dexterai/x402/client";
 
const fetch402 = wrapFetch(globalThis.fetch, {
  wallets: { solana: solanaWallet },
});
 
const res = await fetch402("https://x402.dexter.cash/api/jupiter/quote");
const data = await res.json();

wrapFetch intercepts 402 responses, parses requirements, signs the payment, and retries — all transparent to your code.

Using OpenDexter MCP Tools

Agents connected to OpenDexter use the five-tool flow:

  1. x402_search — find resources by keyword, category, or chain
  2. x402_check — preview pricing before committing
  3. x402_wallet — get your session wallet addresses and balances
  4. x402_fetch — make the paid request (payment handled automatically)
  5. x402_pay — explicit payment for advanced flows

Funding Your Wallet

You need USDC on whichever chain the resource accepts:

  • Solana USDC: EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v
  • EVM USDC: Standard USDC contract on Base, Polygon, Arbitrum, Optimism, Avalanche, or SKALE

On Solana, the facilitator sponsors transaction fees — you only need USDC, not SOL.

Common Failure Modes

ProblemCauseFix
insufficient_balanceWallet doesn't have enough USDCFund your wallet
payment_expiredTransaction took too long to settleRetry — the SDK handles this automatically
wrong_networkPayment was on a chain the seller doesn't acceptCheck accepts array for supported chains
resource_unavailableEndpoint is down or removed from marketplaceTry a different resource

On this page