> ## Documentation Index
> Fetch the complete documentation index at: https://sella.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Purchase a Dataset and Settle x402 Payment on Sella

> Call get_dataset to retrieve full dataset content. Free tiers deliver immediately; paid tiers run an x402 challenge-sign-settle handshake automatically.

Once a dataset passes your evaluation checklist, call `get_dataset` to retrieve the full content. Free-tier datasets return immediately. Paid-tier datasets trigger a two-step [x402](/reference/x402) handshake — Sella issues a payment challenge, your agent signs and retries, and the content follows. Your agent handles both flows with a single tool.

## Call get\_dataset

```json theme={null}
{
  "name": "get_dataset",
  "arguments": {
    "dataset_id": "<id>"
  }
}
```

The server's response depends on the dataset's tier and your payment state:

* **Free dataset** → content is returned immediately in the response.
* **Paid dataset, no payment yet** → a `402 Payment Required` response containing the payment challenge.
* **Paid dataset, valid payment attached** → full content is delivered.

## Free vs. paid flow

<Tabs>
  <Tab title="Free dataset">
    Call `get_dataset` with the dataset ID. The response includes the full content or a presigned download URL — no wallet interaction required.

    ```json theme={null}
    {
      "name": "get_dataset",
      "arguments": {
        "dataset_id": "<id>"
      }
    }
    ```
  </Tab>

  <Tab title="Paid dataset">
    The first call returns a `402` challenge. Sign the challenge with your wallet, then retry with the `payment_signature` field attached.

    ```json theme={null}
    {
      "name": "get_dataset",
      "arguments": {
        "dataset_id": "<id>",
        "payment_signature": "<base64 PAYMENT-SIGNATURE>"
      }
    }
    ```
  </Tab>
</Tabs>

## Anatomy of the 402 challenge

When a paid dataset has no valid payment, Sella responds with a `PAYMENT-REQUIRED` payload describing exactly what to pay:

```json theme={null}
{
  "x402Version": 2,
  "accepts": [
    {
      "network": "base",
      "priceInAtomicUnits": "45000000",
      "payTo": "0x…SellaVault",
      "expiresAt": "2026-07-02T21:00:00Z"
    }
  ]
}
```

The challenge is the authoritative source for chain, amount, and recipient address. Never hard-code these values — they can change between listings and over time.

## Completing payment

Your agent signs the challenge using the wallet stored at `~/.sella-wallet.json`, then calls `get_dataset` again with the signature:

```json theme={null}
{
  "name": "get_dataset",
  "arguments": {
    "dataset_id": "<id>",
    "payment_signature": "<base64 PAYMENT-SIGNATURE (v2, preferred)>"
  }
}
```

<AccordionGroup>
  <Accordion title="Legacy payment fields" icon="clock">
    Older clients may send `payment_proof` (historically the `X-PAYMENT-RESPONSE` header) or `x_payment` (v1 `X-PAYMENT`). Both are accepted for backwards compatibility. For new integrations, always use `payment_signature`.
  </Accordion>

  <Accordion title="Where the money goes" icon="wallet">
    Sella verifies and settles through the x402 facilitator on-chain. The dataset publisher receives the payment in USDC minus a 3% platform fee. Settlement completes in seconds.
  </Accordion>
</AccordionGroup>

## Content delivery modes

How content arrives depends on the dataset's storage configuration:

<CardGroup cols={2}>
  <Card title="Inline" icon="file-text" href="/consumers/discover">
    Small datasets return their full content directly inside the tool response body. No secondary download step is required.
  </Card>

  <Card title="Asset-backed" icon="cloud-download" href="/consumers/discover">
    Larger datasets return a **presigned download URL** pointing to object storage. The URL is valid for a short window — download promptly after receiving it.
  </Card>
</CardGroup>

<Info>
  Purchases are recorded against your account. Re-calling `get_dataset` for a dataset you have already bought returns the content without charging you again.
</Info>

## Error reference

| Signal            | Meaning                                           | What to do                                                   |
| ----------------- | ------------------------------------------------- | ------------------------------------------------------------ |
| `402` after retry | Signature is invalid or the challenge has expired | Re-fetch the challenge, re-sign it, and retry                |
| `WALLET_UNFUNDED` | Insufficient USDC balance in your wallet          | [Fund the wallet](/consumers/operators) and retry the call   |
| `401`             | Missing or invalid authentication key             | Re-[authenticate](/consumers/authentication) and retry       |
| `404`             | Unknown or unlisted dataset ID                    | Verify the `dataset_id` via [discovery](/consumers/discover) |

## Next steps

<CardGroup cols={2}>
  <Card title="Compute: Cradle & Mergekit" icon="cpu" href="/consumers/compute">
    Use your purchased datasets to fine-tune or fuse models with a single paid MCP call.
  </Card>

  <Card title="x402 reference" icon="book-open" href="/reference/x402">
    Explore the full x402 protocol — chains, versions, and facilitator details.
  </Card>
</CardGroup>
