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

# getFlowQuote

> Quote a Flow payment's attached source with the JavaScript SDK, get the deposit address for a deposit-address source, and set the payer's amount in deposit mode.

Quotes the payment for the attached source: how much the payer sends, how much is delivered, and the fees. For a deposit-address source, the quote also creates the deposit address. Each call replaces the previous quote with a new version.

## When to call

Call `getFlowQuote` when `executionState` is `source_attached`, `quoted`, or `signing`. Calling it from `quoted` refreshes the quote. Calling it from `signing` returns the flow to `quoted`, so do not sign the previous transaction afterward.

Exchange sources have no quote. The payer pays through the exchange's purchase link instead.

## Usage

```javascript theme={"system"}
import { getFlowQuote } from '@dynamic-labs-sdk/client';

const flow = await getFlowQuote({
  flowId: 'your-flow-id',
  fromChainId: '8453',
  fromTokenAddress: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913', // USDC on Base
});

console.log('Send:', flow.quote.fromAmount, flow.quote.fromTokenInfo?.symbol);
console.log('Fees (USD):', flow.quote.fees?.totalFeeUsd);
```

## Parameters

| Parameter | Type | Description |
| - | - | - |
| `flowId` | `string` | The flow ID. |
| `fromTokenAddress` | `string` (optional) | The token the payer pays with: a contract address on EVM, or a mint on Solana. Defaults to the native token of the chain set when the source was attached. Pass it whenever the payer pays with another token. |
| `fromChainId` | `string` (optional) | Replaces the network set when the source was attached. The chain family and the wallet address stay as attached; to change them, call `attachFlowSource` again. |
| `amount` | `string` (optional) | `deposit` mode only: the amount the payer chose, as a positive decimal string in `amountCurrency`. It replaces the flow's `amount`. |
| `amountCurrency` | `FlowQuoteAmountCurrency` (optional) | The currency of `amount`: `'USD'`, the default, or `'SOURCE_TOKEN'` for whole units of the token being paid with, where `'0.5'` means 0.5 of that token. |
| `slippage` | `number` (optional) | The slippage tolerance for a payment that needs a swap, as a decimal fraction from `0` to `0.1`. For example, `0.005` is 0.5%. |

Only `deposit` mode accepts `amount`. Use at most 2 decimals for `USD` and at most the token's decimals for `SOURCE_TOKEN`. When `amount` is omitted, the flow's current amount in USD is quoted, so resend a `SOURCE_TOKEN` amount on every quote to keep it fixed in the token. When the source is a wallet, changing the amount screens the wallet again.

## Returns

`Promise<Flow>`: the flow with `executionState: 'quoted'` and a new `quote`. For a deposit-address source, `flow.depositAddress` is the address the payer sends funds to.

| `quote` field | Description |
| - | - |
| `version` | The quote's version. Each quote increases it. |
| `fromAmount` | The amount the payer sends, in the smallest unit of the source token. |
| `toAmount` | The amount to be delivered, in the smallest unit of the settlement token. |
| `fromTokenInfo`, `toTokenInfo` | Each token's `symbol`, `decimals`, and optional `name` and `logoURI`. |
| `fromChainId`, `fromChainName`, `fromToken` | The source chain and token that were quoted. |
| `toChainId`, `toChainName`, `toToken` | The settlement chain and token. |
| `fees` | `totalFeeUsd`, the total fees in USD, and an optional `gasEstimate`. |
| `createdAt`, `expiresAt` | When the quote was created, and when it expires. |

Format `fromAmount` and `toAmount` with `formatTokenAmount` from `@dynamic-labs-sdk/client` and the token's `decimals`. For example, `'1500000'` with 6 decimals is `1.5`.

A wallet quote is valid for 60 seconds, and `expiresAt` marks that time. A deposit-address quote guarantees the amount to send for 60 seconds too, but its `expiresAt` shows the flow's expiry instead, so time a refresh from `createdAt`. The deposit address itself stays open until the flow ends. [Expiry and cancellation](https://docs.dynamic.xyz/docs/flow/expiry-and-cancellation.md#quote-expiry) explains both.

## Examples

### Refresh an expired wallet quote

```javascript theme={"system"}
import { getFlowQuote } from '@dynamic-labs-sdk/client';

const refreshed = await getFlowQuote({
  flowId: flow.id,
  fromChainId: flow.quote.fromChainId,
  fromTokenAddress: flow.quote.fromToken,
});
```

### Quote a payer-chosen deposit amount

```javascript theme={"system"}
import { getFlowQuote } from '@dynamic-labs-sdk/client';

const flow = await getFlowQuote({
  flowId: 'your-flow-id',
  fromChainId: '8453',
  fromTokenAddress: '0x0000000000000000000000000000000000000000', // Native ETH on Base
  amount: '0.5',
  amountCurrency: 'SOURCE_TOKEN',
});
```

### Show a deposit address

```javascript theme={"system"}
import { formatTokenAmount, getFlowQuote } from '@dynamic-labs-sdk/client';

const flow = await getFlowQuote({
  flowId: 'your-flow-id',
  fromChainId: '8453',
  fromTokenAddress: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913', // USDC on Base
});

const amount = formatTokenAmount({
  rawAmount: flow.quote.fromAmount,
  decimals: flow.quote.fromTokenInfo.decimals,
});

console.log(`Send ${amount} ${flow.quote.fromTokenInfo.symbol} to ${flow.depositAddress}`);
```

[Build a custom payment UI](https://docs.dynamic.xyz/docs/javascript/reference/flow-ui-guide.md#deposit-address) shows how to build a QR code payment URI and refresh the quote every 60 seconds.

## Errors

| Error | When |
| - | - |
| `FlowQuoteAmountError` | `amount_invalid`: the amount is malformed, too precise, or too small. `amount_not_editable`: the flow is not in `deposit` mode. |
| `FlowQuoteUnavailableError` | No route was found to any settlement token. `quoteFailures` says why for each token. |
| `FlowSourceBlockedError` | `sanctions_blocked`: the wallet failed screening for the new amount. `risk_blocked`: the flow is blocked by risk screening. |
| `FlowStateConflictError` | The flow can no longer be quoted, for example because the payment was sent, or another request changed it first. |
| `FlowSessionTokenMissingError` | No session token for the flow is stored on this device. |
| `FlowSessionExpiredError` | The server no longer accepts the stored session token, for example because the flow ended or a source was attached on another device. |

Some rejections have no dedicated class, for example a flow with `disableSwaps` whose source does not match a settlement, or a token that cannot be priced. Show `error.message` for those. [Handle Flow errors](https://docs.dynamic.xyz/docs/javascript/reference/flow-errors.md) describes each error and the quote failure reasons.

## React

`useGetFlowQuote` is a mutation hook. It takes the same parameters, and it writes the returned flow into the `useGetFlow` cache.

```tsx theme={"system"}
import { useGetFlowQuote } from '@dynamic-labs-sdk/react-hooks';

function QuoteButton({ flowId, fromChainId, fromTokenAddress }) {
  const { mutate: getFlowQuote, isPending } = useGetFlowQuote();

  return (
    <button onClick={() => getFlowQuote({ flowId, fromChainId, fromTokenAddress })} disabled={isPending}>
      {isPending ? 'Quoting...' : 'Get quote'}
    </button>
  );
}
```

## Related

* [Build a custom payment UI](https://docs.dynamic.xyz/docs/javascript/reference/flow-ui-guide.md): review a wallet quote, show a deposit address, and enter a deposit amount.
* [`attachFlowSource`](https://docs.dynamic.xyz/docs/javascript/reference/client/attach-flow-source): attach the source to quote.
* [`submitFlowTransaction`](https://docs.dynamic.xyz/docs/javascript/reference/client/submit-flow-transaction): send a quoted wallet payment.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.