# selectRequirement

> Select the first acceptable payment requirement matching the payer's network.

```ts
import { selectRequirement } from 'x402-avm-js';
```

```ts
export function selectRequirement(paymentRequired: Pick<PaymentRequired, 'accepts'>, network: string): PaymentRequirements;
```

Select the first acceptable payment requirement matching the payer's network.

Searches the `accepts` array of a PaymentRequired challenge for an offer using the "exact"
payment scheme matching the specified network (resolved via `resolveNetwork`).

## Parameters

- `paymentRequired` (`true`): " required>
Parsed PaymentRequired object (anything with an `accepts` array).

- `network` (`string`, required):
Desired network name, alias, or CAIP-2 identifier.

## Returns

- `returns` (`PaymentRequirements`):
The matching PaymentRequirements entry.

## Throws

- `NoSupportedRequirementError`: If `accepts` is empty.
- `NetworkMismatchError`: If no requirement matches the requested network.

## Example

```ts
const req = selectRequirement(paymentRequired, 'mainnet');
console.log(`Pay ${req.amount} microALGO to ${req.payTo}`);
```

Source: [src/index.ts](https://github.com/x402-avm/x402-avm-js/blob/main/src/index.ts#L336)

Source: https://x402-avm.github.io/reference/js/select-requirement
