Portal’s React Native SDK provides high-level 0x swaps throughDocumentation Index
Fetch the complete documentation index at: https://docs.portalhq.io/llms.txt
Use this file to discover all available pages before exploring further.
portal.trading.zeroX.tradeAsset(...).
Overview
Using the high-level 0x flow, you can:- Trade assets end-to-end with one call
- Track lifecycle progress from quote fetch to confirmation
- Override signer and confirmation behavior per call when needed
0x vs Li.Fi:
- 0x: Best for same-chain token swaps. Executes one transaction with fast, simple chain confirmation. No cross-chain routing.
- Li.Fi: Best for cross-chain bridges and swaps. Handles multi-step routes (bridge + swap) with protocol-level status tracking.
Prerequisites
Before using the 0x API, make sure you have:- A properly initialized Portal client
- An active wallet with sufficient balance on the source network (see Create a wallet)
- 0x integration enabled in your Portal Dashboard (see 0x Integration) OR have a 0x API Key available
High-Level Methods
tradeAsset
Fetches a 0x quote, signs and broadcasts the quote transaction, waits for on-chain confirmation, and returns hashes.
Signature
| Name | Required | Description |
|---|---|---|
chainId | Yes | CAIP-2 chain (e.g. 'eip155:1'). See Supported Networks. |
sellToken | Yes | Token to sell (symbol or address). |
buyToken | Yes | Token to buy (symbol or address). |
sellAmount | Yes | Amount in base units (smallest units). |
fromAddress | No | Sender address used by high-level 0x execution. |
slippageBps | No | Max slippage in basis points (e.g. 100 = 1%). |
swapFeeRecipient, swapFeeBps, swapFeeToken | No | Integrator fee fields. |
tradeSurplusRecipient | No | Surplus recipient. |
gasPrice | No | Optional gas price. |
excludedSources | No | Comma-separated sources to exclude. |
sellEntireBalance | No | 'true' / 'false'. |
onProgress | No | Stages such as fetching_quote, signing, submitted, confirming, confirmed, failed. |
zeroXApiKey | No | Override the Dashboard key for this call. |
ZeroXTradeAssetOptions:
| Name | Required | Description |
|---|---|---|
signAndSendTransaction | No | Per-call signer override. |
waitForConfirmation | No | Per-call confirmation override. MUST return true or resolve for success. Returning false, throwing an error, or timing out will abort the swap and throw an error. |
| Field | Description |
|---|---|
hashes | Broadcast transaction hashes. |
0x
tradeAsset follows Yield-style execution precedence:- Signer: per-call
options.signAndSendTransaction-> instance default signer -> throw - Confirmation: per-call
options.waitForConfirmation-> instance default waiter -> throw
false, times out, throws an error, or the network is unsupported, the swap fails immediately.onProgress + default on-chain wait)
try/catch around tradeAsset; onProgress may emit failed before the thrown error.
Example (custom API key + execution options)
Using a Custom 0x API Key (Optional)
By default, Portal uses the 0x API Key that can be added through the Portal Dashboard to communicate with the 0x integration.Getting a Price (Indicative)
Useportal.trading.zeroX.getPrice to retrieve an indicative price for a
token swap without generating executable transaction data.
This method is useful for displaying prices, estimating swap outcomes, or
building preview experiences without committing to a quote.
Getting a Swap Quote
Useportal.trading.zeroX.getQuote to fetch a swap quote from 0x.
Getting Liquidity Sources
You can query available liquidity sources supported by 0x usingportal.trading.zeroX.getSources.
For full request and response details, refer to the Client API documentation.
Executing the Swap
Once you receive a quote containing transaction data, execute the swap by sending the transaction throughportal.request.
Note
The transaction data returned by 0x may include gas parameters such asgasorgasPrice. These fields are optional — you can omit them and let Portal estimate gas automatically, or include them if you prefer to use 0x’s suggested values.
Supported Networks
Theportal.trading.zeroX API supports a predefined set of EIP-155 networks.
Requests using unsupported chains will fail.
| Network | EIP-155 Chain ID |
|---|---|
| Ethereum | eip155:1 |
| Optimism | eip155:10 |
| BSC | eip155:56 |
| Unichain | eip155:130 |
| Polygon | eip155:137 |
| Monad | eip155:143 |
| Worldchain | eip155:480 |
| Mantle | eip155:5000 |
| Base | eip155:8453 |
| Monad Testnet | eip155:10143 |
| Mode | eip155:34443 |
| Arbitrum | eip155:42161 |
| Avalanche | eip155:43114 |
| Ink | eip155:57073 |
| Linea | eip155:59144 |
| Berachain | eip155:80094 |
Next Steps
- Learn how to sign Ethereum transactions
- Explore how to send tokens
- Review the Client API 0x endpoints