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

# x402 Protocol

> How HYRE uses the HTTP 402 Payment Required protocol for machine-to-machine payments.

# x402 Protocol

HYRE uses the **x402** protocol for payment -- an extension of HTTP that turns the `402 Payment Required` status code into a machine-readable payment flow. Agents pay per request with no API keys, no OAuth, and no subscriptions.

***

## How x402 Works

**1. Agent sends request without payment**

```bash theme={null}
curl https://mpp.hyreagent.fun/defi/tvl
```

The server returns HTTP 402 with payment requirements in the response body.

**2. Server returns 402 with payment details**

```json theme={null}
{
  "x402Version": 1,
  "accepts": [
    {
      "scheme": "exact",
      "network": "solana",
      "maxAmountRequired": "1000",
      "resource": "https://mpp.hyreagent.fun/defi/tvl",
      "payTo": "7G73PLhKvAPBGTzG5ESAE4coE7QrVeTTKfhTxQZbyGgC",
      "asset": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
      "description": "Total Value Locked across chains",
      "maxTimeoutSeconds": 300
    }
  ]
}
```

**3. Agent signs payment and retries**

The agent constructs a payment payload, signs it with its wallet, base64-encodes it, and attaches it as the `X-PAYMENT` header.

```bash theme={null}
curl -X POST https://mpp.hyreagent.fun/defi/tvl \
  -H "X-PAYMENT: eyJ4NDAyVmVyc2lvbiI6MSwi..." \
  -H "Content-Type: application/json" \
  -d '{"chain": "solana"}'
```

**4. Facilitator verifies and settles**

The HYRE server forwards the payment to a **facilitator** that verifies the signature and settles the USDC transfer on-chain. If valid, the server processes the request and returns data.

***

## Facilitators

HYRE uses two facilitators depending on the payment chain:

| Chain | Facilitator | URL | Gas |
| - | - | - | - |
| Solana | Dexter | `https://x402.dexter.cash` | Sponsored by HYRE |
| Base | PayAI | `https://facilitator.payai.network` | Caller pays (\~\$0.01) |
| SKALE | PayAI | `https://facilitator.payai.network` | Free (sFUEL) |

The facilitator acts as a neutral third party:

1. **Verify** -- Checks the payment signature is valid and the amount is sufficient.
2. **Settle** -- Executes the USDC transfer on-chain after the server delivers data.

***

## Payment Header Format

The `X-PAYMENT` header contains a base64-encoded JSON object:

```json theme={null}
{
  "x402Version": 1,
  "scheme": "exact",
  "network": "solana",
  "payload": {
    "signature": "<base58-encoded-solana-signature>",
    "transaction": "<base64-encoded-transaction>"
  }
}
```

For EVM chains (Base, SKALE), the payload contains an EIP-712 signed authorization instead of a Solana transaction.

***

## Discovery

Agents can discover HYRE's payment requirements programmatically:

```bash OpenAPI spec theme={null}
curl https://mpp.hyreagent.fun/openapi.json | jq '.info["x-payment-protocols"]'
```

```bash Agent card theme={null}
curl https://mpp.hyreagent.fun/.well-known/agent-card.json | jq '.capabilities.x402'
```

```bash x402 discovery theme={null}
curl https://mpp.hyreagent.fun/.well-known/x402 | jq
```

***

## Pay-To Addresses

| Chain | Address |
| - | - |
| Solana | `7G73PLhKvAPBGTzG5ESAE4coE7QrVeTTKfhTxQZbyGgC` |
| Base (EVM) | `0xb5998e11E666Fd1e7f3B8e8d9122A755eec1E9b7` |
| SKALE (EVM) | `0xb5998e11E666Fd1e7f3B8e8d9122A755eec1E9b7` |

> [!WARNING]
>
> Root paths (`/`) only accept Solana payments. Use `/base/*` for Base and `/skale/*` for SKALE. Sending an EVM payment to a root path returns a 402 redirect hint.


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