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

# Pay per call (x402)

> Pay US$0.02 in USDC for one REST call at the Pro tier's limits, with no account and no key.

**Test network only.** Payments run on Base Sepolia (`eip155:84532`) with test USDC.
No real money moves yet. This page will name the mainnet network when it goes live.

The free tiers stay as they are. When a call **with no Authorization header** meets a
tier limit on a paid resource, SILO answers HTTP 402 instead of 403. The caller can
pay for that one call and send it again. The paid call is served at the
[Pro tier's](https://octo-98895abd.mintlify.site/api-docs/v2/authentication.md) limits.

| Item | Value |
| - | - |
| Protocol | x402 v2, `exact` scheme, over HTTP headers |
| Price | 20000 atomic USDC units = US\$0.02 per call |
| Network | Base Sepolia, `eip155:84532` (test network) |
| Asset | USDC `0x036CbD53842c5426634e7929541eC2318f3dCF7e` |
| Paid resources | `prices`, `statements`, `macro` |
| Transport | REST v2 only. MCP v2 does not take payments. |

## The flow

1. Send the call with no Authorization header. A call inside the free tier gets 200 and costs nothing.
2. A call over a tier limit gets **402** with error code `payment_required`. The `PAYMENT-REQUIRED` header holds base64 JSON: `accepts[0]` gives the amount, asset, network and `payTo` address.
3. Sign an EIP-3009 `TransferWithAuthorization` for that amount to `payTo`. The EIP-712 domain is `name` and `version` from `accepts[0].extra`, the chain id from `network`, and `asset` as the verifying contract.
4. Send **the same request** again with a `PAYMENT-SIGNATURE` header: base64 JSON of `{"x402Version": 2, "accepted": <accepts[0]>, "payload": {"signature", "authorization"}}`.
5. SILO verifies the payment, serves the data, then settles it. A 200 carries `meta.tier: pro`, `meta.payment: x402` and a `PAYMENT-RESPONSE` header with the settlement receipt (`success`, `transaction`, `network`, `payer`).

The buyer wallet needs USDC only. It needs no ETH, because the payment service pays the gas.

## What is charged

* **An error is never charged.** SILO settles only after it has served the data. An unknown ticker, a bad parameter or a failed data call is not settled.
* **A payment that does not verify** gets 402 with the reason, for example `invalid_exact_evm_signature` or `insufficient_funds`. Nothing is served or charged.
* **A payment for other terms** (another amount, asset, network or `payTo`) is refused before verification.
* **A failed settle** gets 402, and the data is withheld. `PAYMENT-RESPONSE` carries the failure.
* **A signed-in caller** is never offered a payment. A `PAYMENT-SIGNATURE` header next to an Authorization header is ignored.
* SQL-side ceilings still apply to a paid call, for example the option chain's row ceiling.

## Example (Python)

This example pays for 6 months of daily PETR4 prices, which is wider than the anonymous
tier's 3 months. Keep the key in your environment. Use a wallet that holds only a small balance.

```python theme={null}
import base64, json, os, time
import httpx
from eth_account import Account
from eth_account.messages import encode_typed_data

URL = ("https://zcjbtpxuhdekpwcxmepn.supabase.co/functions/v1/silo-api/v2/prices"
       "?id=PETR4&from=2026-01-01&to=2026-06-30")
acct = Account.from_key(os.environ["BUYER_PRIVATE_KEY"])

first = httpx.get(URL)
assert first.status_code == 402, first.text
req = json.loads(base64.b64decode(first.headers["payment-required"]))
a = req["accepts"][0]

now = int(time.time())
auth = {"from": acct.address, "to": a["payTo"], "value": a["amount"],
        "validAfter": str(now - 600), "validBefore": str(now + a["maxTimeoutSeconds"]),
        "nonce": "0x" + os.urandom(32).hex()}
typed = {
    "types": {
        "EIP712Domain": [{"name": "name", "type": "string"}, {"name": "version", "type": "string"},
                         {"name": "chainId", "type": "uint256"}, {"name": "verifyingContract", "type": "address"}],
        "TransferWithAuthorization": [{"name": "from", "type": "address"}, {"name": "to", "type": "address"},
                                      {"name": "value", "type": "uint256"}, {"name": "validAfter", "type": "uint256"},
                                      {"name": "validBefore", "type": "uint256"}, {"name": "nonce", "type": "bytes32"}],
    },
    "primaryType": "TransferWithAuthorization",
    "domain": {"name": a["extra"]["name"], "version": a["extra"]["version"],
               "chainId": int(a["network"].split(":")[1]), "verifyingContract": a["asset"]},
    "message": {**auth, "value": int(auth["value"]), "validAfter": int(auth["validAfter"]),
                "validBefore": int(auth["validBefore"]), "nonce": bytes.fromhex(auth["nonce"][2:])},
}
sig = "0x" + acct.sign_message(encode_typed_data(full_message=typed)).signature.hex().removeprefix("0x")
payment = {"x402Version": 2, "accepted": a, "payload": {"signature": sig, "authorization": auth}}

paid = httpx.get(URL, headers={"PAYMENT-SIGNATURE": base64.b64encode(json.dumps(payment).encode()).decode()},
                 timeout=90)
body = paid.json()
print(paid.status_code, body["meta"]["tier"], body["meta"]["payment"], len(body["data"]))
print(json.loads(base64.b64decode(paid.headers["payment-response"])))
```

An x402 client library does the same steps for you. Point it at the URL and give it a wallet.

## Pay or sign in

| You are | Use |
| - | - |
| An agent with a wallet and no account | Pay per call when a tier limit applies |
| A person who calls often | [Sign in](https://octo-98895abd.mintlify.site/api-docs/v2/authentication.md) for the free signed-in tier |
| A service that needs Pro every day | Ask for a Pro integration key |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.