Skip to main content
Below are the two methods to get a quote for a swap from a given route:
When providing HBAR in the path array, use the wrapped HBAR token ID (WHBAR).
For production environments, it’s highly recommended to use a paid Mirror Node provider for commercial and high-traffic purposes. While Hedera’s public mirror node offers free REST API and JSON API endpoints, they have global rate limits. These are best suited for development or low rate usage scenarios.

Get output quote from exact input amount

Get the output amount from a given exact input amount and a swap route. Function name: quoteExactInput No gas cost — read-only call.
The data passed to the ‘path’ parameter follows this format: [token, fee, token, fee, token, …], with each ‘token’ in the route being 20 bytes long and each ‘fee’ being 3 bytes long. Example, 0x0001F4 for a 0.05% fee.

Code overview

Resources:

Get input quote from exact output amount

Get the input amount from a given exact output amount and a swap route. Function name: quoteExactOutput No gas cost — read-only call.
The data passed to the ‘path’ parameter follows this format: [token, fee, token, fee, token, …], but reversed (i.e. the first token in the array should be output token), with each ‘token’ in the route being 20 bytes long and each ‘fee’ being 3 bytes long. Example, 0x000BB8 for a 0.30% fee.

Code overview

Resources:

Next steps

Swap tokens for tokens (V2)

Execute the swap you just quoted.

Fetch all pools (V2)

Find pool fee tiers to build the quote path.

Contract deployments

QuoterV2 and SwapRouter IDs for mainnet and testnet.