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

# Quotes and execution

> QuoteIntent, CommitIntent, ExecuteIntent, and AbortIntent.

These four endpoints cover the full active lifecycle of an intent: getting a route, locking it in, executing, and canceling if needed.

For authentication and base URL, see the [API overview](/cross-chain/api-reference/overview).

***

## QuoteIntent

Get a route and fee estimate for a payment. The quote is valid for 5 minutes.

**Endpoint**: `POST /QuoteIntent`

### Request parameters

| Field                       | Type                                | Required          | Description                                                                                                 |
| --------------------------- | ----------------------------------- | ----------------- | ----------------------------------------------------------------------------------------------------------- |
| `ownerAddress`              | string                              | Yes               | The customer's wallet address                                                                               |
| `originChainId`             | number                              | Yes               | Chain ID of the source network                                                                              |
| `originTokenAddress`        | string                              | Yes               | Token contract address on the source network                                                                |
| `destinationChainId`        | number                              | Yes               | Chain ID of the destination network                                                                         |
| `destinationTokenAddress`   | string                              | Yes               | Token contract address at the destination                                                                   |
| `tradeType`                 | `"EXACT_INPUT"` \| `"EXACT_OUTPUT"` | Yes               | Whether the fixed amount is on the input or output side                                                     |
| `originTokenAmount`         | string                              | If `EXACT_INPUT`  | Amount to send, in the origin token's smallest unit                                                         |
| `destinationTokenAmount`    | string                              | If `EXACT_OUTPUT` | Amount to receive, in the destination token's smallest unit                                                 |
| `destinationToAddress`      | string                              | Yes               | Wallet or contract address to receive funds                                                                 |
| `destinationCalldata`       | string                              | No                | ABI-encoded calldata for a destination action (see [programmable destinations](/cross-chain/money-actions)) |
| `options.slippageTolerance` | number                              | No                | Maximum acceptable slippage as a decimal (e.g. `0.005` for 0.5%)                                            |

### Response fields

| Field        | Description                                                                      |
| ------------ | -------------------------------------------------------------------------------- |
| `intent`     | The full intent object, including `depositAddress`: the address to send funds to |
| `feeOptions` | Array of fee payment options; pass your chosen option to `ExecuteIntent`         |

### Example

```typescript theme={null}
import { TrailsApi } from "@0xtrails/api";

const trails = new TrailsApi({
  baseUrl: "https://trails-api.sequence.app/rpc/Trails/",
  accessKey: process.env.TRAILS_ACCESS_KEY,
});

const { intent, feeOptions } = await trails.quoteIntent({
  ownerAddress: "0xCUSTOMER_ADDRESS",
  originChainId: 1,
  originTokenAddress: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC on Ethereum
  destinationChainId: 137,
  destinationTokenAddress: "0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359", // USDC on Polygon
  destinationToAddress: "0xPRODUCT_WALLET",
  tradeType: "EXACT_INPUT",
  originTokenAmount: "1000000", // 1 USDC (6 decimals)
  options: {
    slippageTolerance: 0.005,
  },
});

console.log("Send funds to:", intent.depositAddress);
console.log("Available fee options:", feeOptions);
```

***

## CommitIntent

Lock in a quoted intent. After committing, the route and fees are fixed. The intent must be executed within 10 minutes or it expires.

**Endpoint**: `POST /CommitIntent`

### Request parameters

| Field    | Type   | Required | Description                                        |
| -------- | ------ | -------- | -------------------------------------------------- |
| `intent` | object | Yes      | The full `intent` object returned by `QuoteIntent` |

### Response fields

| Field      | Description                                                                  |
| ---------- | ---------------------------------------------------------------------------- |
| `intentId` | Unique identifier for the committed intent; use this in all subsequent calls |

### Example

```typescript theme={null}
const { intentId } = await trails.commitIntent({ intent });

console.log("Intent committed:", intentId);
```

***

## ExecuteIntent

Initiate execution of a committed intent. Two execution methods are available.

**Endpoint**: `POST /ExecuteIntent`

### Method A: Transfer

Send funds to `intent.depositAddress` from your wallet or on-ramp, then submit the source transaction hash.

| Field                    | Type   | Required | Description                                          |
| ------------------------ | ------ | -------- | ---------------------------------------------------- |
| `intentId`               | string | Yes      | The intent ID from `CommitIntent`                    |
| `depositTransactionHash` | string | Yes      | Transaction hash of the transfer to `depositAddress` |

```typescript theme={null}
// After sending funds to intent.depositAddress onchain:
await trails.executeIntent({
  intentId,
  depositTransactionHash: "0xSOURCE_TX_HASH",
});
```

### Method B: Permit (gasless, ERC-2612)

For tokens that support ERC-2612 permit signatures, execute without a separate approval transaction. The customer signs an off-chain permit instead of sending a transaction.

| Field              | Type   | Required | Description                                          |
| ------------------ | ------ | -------- | ---------------------------------------------------- |
| `intentId`         | string | Yes      | The intent ID from `CommitIntent`                    |
| `feeOption`        | object | Yes      | The selected fee option from `QuoteIntent`           |
| `permitSignature`  | string | Yes      | ERC-2612 permit signature authorizing the transfer   |
| `intentSignature`  | string | Yes      | Customer's signature over the intent                 |
| `depositSignature` | string | Yes      | Signature authorizing the deposit                    |
| `nonce`            | number | Yes      | Nonce used in the permit signature                   |
| `deadline`         | number | Yes      | Unix timestamp deadline used in the permit signature |

```typescript theme={null}
await trails.executeIntent({
  intentId,
  feeOption: feeOptions[0],
  permitSignature,
  intentSignature,
  depositSignature,
  nonce,
  deadline,
});
```

***

## AbortIntent

Cancel a `QUOTED` or `COMMITTED` intent. Intents that are `EXECUTING`, `SUCCEEDED`, or `FAILED` cannot be aborted.

**Endpoint**: `POST /AbortIntent`

### Request parameters

| Field      | Type   | Required | Description             |
| ---------- | ------ | -------- | ----------------------- |
| `intentId` | string | Yes      | The intent ID to cancel |

### Example

```typescript theme={null}
await trails.abortIntent({ intentId });
```
