# PaymentRequired

> Decoded payload of the HTTP 402 PAYMENT-REQUIRED header.

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

```ts
export interface PaymentRequired {
  x402Version: number;
  error?: string | null;
  resource?: ResourceInfo | null;
  accepts: PaymentRequirements[];
  extensions?: Record<string, unknown> | null;
}
```

Decoded payload of the HTTP 402 PAYMENT-REQUIRED header.

Contains the x402 protocol version (2), optional error string, protected resource info,
list of acceptable payment requirements, and optional extensions.

## Properties

- `x402Version` (`number`, required):
x402 protocol version (2).

- `error` (`string | null`):
Optional error message from the server.

- `resource` (`ResourceInfo | null`):
The protected resource.

- `accepts` (`PaymentRequirements[]`, required):
The payment offers the server accepts. `selectRequirement` and `payForRequirement` pick the `exact` offer for the wallet's network.

- `extensions` (`true`): | null">
Optional protocol extensions. `encodePaymentHeader` copies them into the payment payload.

## Example

```ts
const challenge: PaymentRequired = {
  x402Version: 2,
  accepts: [
    {
      scheme: 'exact',
      network: 'algorand:wGHE2Pwdvd7S12BL5FaOP20EGYesN73k',
      asset: '0',
      amount: '10000',
      payTo: 'RECEIVER_ADDRESS',
      maxTimeoutSeconds: 300
    }
  ]
};
```

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

Source: https://x402-avm.github.io/reference/js/payment-required
