# @provex/indexer-client

Typed client and React hooks for querying the Provex indexer. Ships with the indexer schema bundled inline, so the package works out of the box against the hosted Provex indexer at `https://indexer.provex.com` and can be re-pointed at a self-hosted indexer with a single config option.

## Install

```bash
npm install @provex/indexer-client @tanstack/react-query react viem
```

### Peer Dependencies

| Package | Version |
|---------|---------|
| `react` | `^18.0.0 \|\| ^19.0.0` |
| `@tanstack/react-query` | `^5.0.0` |
| `viem` | `^2.0.0` |

## Quick Start

```tsx
import { createPonderAdapter, useDeposits } from '@provex/indexer-client'

const indexer = createPonderAdapter()
// Defaults to the hosted Provex indexer. Override with:
// createPonderAdapter({ url: 'https://my-indexer.example.com' })

function DepositList() {
  const { data, isLoading } = useDeposits({ token: '0x...', paymentMethod: 'venmo' })
  // ...
}
```

The hooks need to be inside a `QueryClientProvider` from `@tanstack/react-query` and a `ProvexProvider` from `@provex/react`. See the [@provex/react quick-start](https://www.npmjs.com/package/@provex/react) for the full setup.

## Configuration

```ts
import { createProvexIndexerClient } from '@provex/indexer-client'

const client = createProvexIndexerClient({
  url: 'https://my-indexer.example.com',
  // schema: customSchema, // optional — override the bundled schema
})
```

### Environment Variables

When using `createPonderAdapter()` without explicit config, the following env vars are consulted (Vite naming):

| Variable | Default | Purpose |
|----------|---------|---------|
| `VITE_INDEXER_URL` | `https://indexer.provex.com` | Provex indexer base URL |
| `VITE_TOKEN_INDEXER_URL` | `https://token.provex.com` | Token-list indexer base URL |

## What's bundled

The package inlines the schema definitions for both the main indexer (deposits, intents, events) and the token indexer (token metadata) via tsup. This means consumers get a single dependency for the full indexer surface — no separate schema package to install or version.

The bundled schemas track the deployed Provex indexer. If you run a custom indexer with a different schema, pass it explicitly via `createProvexIndexerClient({ schema })`.

## Integration

For the React hooks and SDK built on this client, see [@provex/react](https://www.npmjs.com/package/@provex/react). For the underlying contract ABIs, see [@provex/abis](https://www.npmjs.com/package/@provex/abis).

## License

MIT
