> For the complete documentation index, see [llms.txt](https://xdocs.ngd.network/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://xdocs.ngd.network/integrations/x402/quick-start.md).

# Quick Start

## Prerequisites

To use x402 on Neo X, you need:

* access to a Neo X RPC endpoint
* a wallet capable of signing the required authorization payloads
* a token supported by the settlement flow
* an agent, relayer, or backend that can submit transactions on-chain

`settleWithPermit(...)` is intended for tokens that support EIP-2612 so approval and settlement can be combined into one transaction path. If the token-side `permit()` attempt fails, settlement can still proceed when the required Permit2 approval already exists.

## Payment Flow

A typical x402 flow consists of four steps.

### 1. Obtain payment requirements

A service defines the payment requirements, such as:

* token
* amount
* recipient
* timing constraints

These parameters are used to construct the authorization payload the user will sign.

### 2. Sign the authorization

The user signs a Permit2-based authorization.

In the exact settlement flow, the signed payload is bound to:

* the token and amount
* the destination address through the witness
* the `validAfter` constraint

This ensures the payment can only be settled under the agreed conditions.

Example EIP-712 signing shape:

```ts
import { createWalletClient, custom } from "viem";

const walletClient = createWalletClient({
  chain,
  transport: custom(window.ethereum),
});

const signature = await walletClient.signTypedData({
  account,
  domain: {
    name: "Permit2",
    chainId,
    verifyingContract: permit2Address,
  },
  types: {
    TokenPermissions: [
      { name: "token", type: "address" },
      { name: "amount", type: "uint256" },
    ],
    ExactPaymentWitness: [
      { name: "to", type: "address" },
      { name: "validAfter", type: "uint256" },
    ],
    PermitWitnessTransferFrom: [
      { name: "permitted", type: "TokenPermissions" },
      { name: "spender", type: "address" },
      { name: "nonce", type: "uint256" },
      { name: "deadline", type: "uint256" },
      { name: "witness", type: "ExactPaymentWitness" },
    ],
  },
  primaryType: "PermitWitnessTransferFrom",
  message: {
    permitted: { token, amount },
    spender: x402ExactPermit2Proxy,
    nonce,
    deadline,
    witness: {
      to: recipient,
      validAfter,
    },
  },
});
```

The exact witness type string and calldata fields must match the deployed contract implementation.

### 3. Submit settlement

An agent or backend submits the settlement transaction to:

* `x402ExactPermit2Proxy`

Depending on the flow, this is either:

* `settle(...)`
* `settleWithPermit(...)`

The submitter pays gas for execution. You can run that yourself, or use a facilitator such as [Ax402](https://ax402.io/), which provides settlement for Neo X; account creation includes an API key with free settlements.

### 4. Execute on-chain

The contract:

* validates the settlement inputs
* checks timing constraints
* uses Permit2 to execute the witness-bound transfer
* emits a settlement event on success

Once confirmed, the payment is settled on-chain.

## When to use `settleWithPermit(...)`

Use `settleWithPermit(...)` when:

* the token supports EIP-2612
* you want to combine approval and settlement into a single on-chain transaction path

This can improve UX by avoiding a separate prior approval step.

However:

* the EIP-2612 amount must match the Permit2 permitted amount exactly
* token-side `permit()` failure does not necessarily prevent settlement if Permit2 approval already exists

## Notes

* users do not need to submit the transaction themselves
* agents can handle execution and gas payment
* the destination is cryptographically bound through the witness
* this contract settles the exact permitted amount, not a partial amount

## Next Steps

* Review [Contracts](/integrations/x402/contracts.md) for implementation details and trust assumptions
* Check [Networks](/development/networks.md) for deployed addresses
* See [SDKs and tooling](/integrations/x402.md#sdks-and-tooling) for x402 client libraries and optional Ax402 packages
