Skip to main content
Please contact sales for additional pricing information on using the Swaps integrations at partner@portalhq.io
Swaps in the React Native SDK are a two-part flow:
  1. Fetch a quote from a trading integration on your Portal instance — portal.trading.zeroX for same-chain swaps, or portal.trading.lifi for cross-chain swaps and bridges.
  2. Execute the quote’s transaction — either with portal.request(...), or with the execute() helper in the @portal-hq/swaps package.
The legacy quote and liquidity-source methods on @portal-hq/swaps — swaps.getQuote() and swaps.getSources(), along with the QuoteArgs and QuoteResponse types — have been removed. Use portal.trading.zeroX.getQuote() and portal.trading.zeroX.getSources() instead. See the 0x guide for the full quote, price, and liquidity-source API.

Installing Swaps support

The @portal-hq/swaps package is only needed for its execute() helper. If you send the swap transaction with portal.request(...) directly, you can skip this step. Run the following in your project directory.

Initializing Swaps

Initializing Swaps requires an existing Portal instance.
The constructor still accepts a first apiKey argument so that existing new Swaps(apiKey, portal) call sites keep compiling, but the SDK no longer uses it — you can pass an empty string. The parameter will be removed in the next major version.Quotes are authenticated with the Portal client API key you already pass to the Portal constructor, and 0x credentials are configured in the Portal Dashboard (see the 0x integration guide).

Fetching a swap quote

Use portal.trading.zeroX.getQuote() to fetch an executable quote. The response wraps the quote in data.rawResponse, whose transaction field holds the transaction to broadcast.
To list the liquidity sources available on a chain, use portal.trading.zeroX.getSources('eip155:1'). Both methods are documented in full in the 0x guide.

Executing a swap

If you’re selling ERC20 tokens, the token must have an allowance for the 0x spender contract of at least the amount you’re selling before the swap transaction will succeed. If you’re selling the chain’s native asset (for example ETH), this step is not necessary. When you’re ready to execute the swap, send the quote’s transaction with the Provider on your existing Portal instance.
execute() sends an eth_sendTransaction request through the provider and resolves with the transaction hash. You can send the same transaction without the @portal-hq/swaps package by calling portal.request(...) directly, which also lets you pass request options such as a signature approval memo.

Next steps