Build guides
How-tos for swaps, zaps, bundles, yield deposits, and cross-chain flows with Enso APIs.
By Javier1 author67 articles
- How do I borrow or repay through Enso?Borrow, repay, and similar lending actions are Bundle cases, generally with the delegate strategy. They are not available as a single Route path.
- How should a wallet show a cross-chain transfer that is still in progress?Treat source confirmation as in-progress, not complete. Show pending or inflight status, the estimated delivery time, and refresh until delivered, failed, or a refund or manual-completion state.
- How do I tell which bridge a Route response selected?Read the Route hop where action is bridge and use its protocol field. bridgingEstimates also includes the protocol name and estimated delivery time. Do not hardcode a provider.
- How do I set refundReceiver on a cross-chain route?Set refundReceiver to the address that should receive a refund when a refund path applies. On Solana destinations it is a required source-chain EVM address. Confirm destinations in quote metadata.
- How do I send a cross-chain output to a different receiver?Set receiver to the destination-chain address that should get tokenOut. It does not have to be the signer. On Solana, use a case-sensitive Solana address and a separate EVM refundReceiver.
- How do I read estimated delivery time from an Enso quote?Read bridgingEstimates from the Route response and use estimatedSeconds on the first entry as the estimated delivery time and as an optional delay before the first status poll.
- How do I poll bridge status without hitting rate limits?Poll bridge status no more than once every 10 seconds per API key. A faster loop returns HTTP 429. Use estimatedSeconds as an optional delay before the first poll.
- How do I charge a fee on a destination-chain intent route?On an intent route, a caller fee with destinationFeeReceiver is charged by the keeper on the destination chain. Without that field, the fee is charged on the source chain, as…
- How do I force a bridge callback route instead of an intent route?Set useIntentAddress to false on the Route request. For a fully specified destination action list, use a Bundle bridge action with a callback that starts with a balance check.
- How do I bridge and swap in one flow?Call the Route API with destinationChainId, a source-chain tokenIn, and a destination-chain tokenOut. Enso returns a source-chain transaction; destination execution is a later stage.
- How do I add a same-asset bridge, not a swap?Call Route with destinationChainId and set tokenOut to the destination-chain address of the same asset. A direct-delivery path can stay a plain bridge transfer.
- How do I validate that a transaction has not been tampered with?After you simulate with Enso Quoter, send the unsigned transaction and simulationId to the validate endpoint. Sign only when valid is true and every field check passes.
- How do I track token flows in a Quoter simulation?Pass tokenIn, amountIn, and tokenOut so Quoter knows which assets to track. The predicted outputs come back in result.amountOut, one value per tokenOut, in wei.
- How do I simulate transactions from another protocol or aggregator?Enso Quoter is source-agnostic. Take the calldata you already have from any valid EVM source, map to, data, from, and value into the simulate request, then validate before signing.
- How do I simulate multiple transactions at once?Use Enso Quoter’s batch simulate endpoint to preview up to five already-built transactions in one request. They must share the same tokenIn, tokenOut, and amountIn.
- How do I simulate a transaction with curl?POST the already-built transaction as JSON to https://quoter.api.enso.build/api/v1/simulate with a Bearer API key, then optionally POST the simulationId to /api/v1/validate.
- How do I add cross-chain swaps to my app?Use a routing API that returns a source-chain transaction and tracks destination delivery separately. Enso’s Route API does this with destinationChainId.
- How do I use the Enso SDK?Install @ensofinance/sdk and create an EnsoClient with your API key. Use it for Route, Bundle, protocol data, and balances. Install from the current docs page so the version stays accurate.
- How do I use the documentation sandbox vs a production key?The API documentation sandbox does not require authentication. For building and production, use a dedicated API key from the Developer Portal.
- How do I use a flashloan in an Enso bundle?Declare a flashloan action with a non-empty callback inside one Bundle request. The callback must be able to repay the borrowed amount plus any protocol fee.
- How do I call the Route API with curl?POST to https://api.enso.build/api/v1/shortcuts/route with your API key and a JSON body of tokens, amounts, chain, and slippage. Copy current field names from the docs.
- How do I tag a request with a referral code?Add the referralCode field on a Route or Bundle request. The executing contract emits ShortcutExecuted, and the higher 16 bytes of requestId contain that code.
- How do I skip approval when allowance is already enough?Skip a returned token approval only when the existing allowance already covers this spend, for this token and spender. If preTransactions still lists a required approval, submit it.
- How do I set the receiver of a route?Set query-level receiver to the address that should receive the final output. It can differ from fromAddress. Keep intermediate outputs with the executor when later actions consume them.
- How do I handle native token inputs?Use the documented native-asset placeholder 0xeee…eee on EVM, and send the tx.value returned by the API exactly. Amounts are decimal strings in the smallest unit.
- How do I estimate gas for an Enso route?Read the gas field on the Route or Bundle response, which comes from simulation. Do not treat it as a combined source-plus-destination total on a cross-chain route.
- How do I display APY and TVL from Enso data?Read APY, TVL, protocol, and underlying-asset fields from GET /v1/tokens, with metadata included, and refresh those figures after a transaction.
- How do I claim fees from a splitter contract?On chains with a fee splitter, the whole fee goes to that contract until claim() or claimERC20(tokens) is called. Claiming is permissionless; the caller pays gas.
- How do I chain bundle actions together?Use useOutputOfCallAt, and an index when the earlier action returns an array, so a later Bundle action consumes that output instead of a hardcoded amount.
- How do I call Enso from a custom smart contract?A custom contract can call the Enso router with the transaction data returned from the API. Use the current tx fields; do not hardcode a router address.
- How do I add checks or slippage guards inside a bundle?Add an Enso slippage action, or another documented check, on an intermediate Bundle output. Chain the amount with useOutputOfCallAt and set bps in basis points.
- How do I build a leverage or looping position in one transaction?Compose the deposit, borrow, and any swap or flashloan as a same-chain Bundle so the steps succeed or revert together. This is not a single Route call.
- How do I harvest or claim rewards in the same transaction?The redeem action does not withdraw extra pool rewards. To claim them in the same transaction, add a harvest action in a Bundle, typically with the delegate strategy.
- How do I route into a non-tokenized position?Discover the position with GET /api/v1/nontokenized, then call GET /api/v1/shortcuts/route/nontokenized with positionOut, typically using the delegate strategy.
- How do I track a cross-chain transaction after the user signs?After the source transaction is submitted, poll Enso’s bridge status APIs with the source chain ID and source transaction hash. Source confirmation is not destination delivery.
- How do I let users deposit into yield from another chain?Request a cross-chain Route from the token the user holds into the yield position on the destination chain, then track delivery separately. Enso’s Route API does this with destinationChainId.
- How do I add a same-chain swap to my app?Request a Route from the token the user holds to the destination token on the same chain, show the quote, then submit the returned transaction as-is. Enso’s Route API is…
- When should I use the Bundle API instead of Route?Use Bundle when you need a fixed action order, checks, dynamic outputs, or actions Route does not cover, such as harvest, borrow, or repay.
- How do I add a cross-chain deposit, not just a swap?Request a cross-chain Route whose tokenOut is the destination position, not only a destination token, then track delivery with bridge status.
- How do I show a quote before the user signs?Show expected output, minimum output, gas, price impact, and any approval from the Route or Bundle response, then collect a signature on the returned transaction.
- How do I submit Enso transaction data from my app?Submit any required approvals first, then send the returned tx.to, tx.data, and tx.value unchanged. Rebuild the quote if it is stale.
- How do I handle token approvals in a routing flow?When the user spends an ERC-20 through the router and allowance is too low, submit the approval or preTransactions first, using the spender from the response.
- Can I route assets to Solana with Enso?Yes. Solana is a Route API destination only. Enso does not originate routes on Solana or run destination callbacks there.
- How do I set slippage on an Enso route?Pass slippage in basis points on the Route request and show expected and minimum output from the response. Do not also set minAmountOut.
- Which bridges does a cross-chain Enso route use?On a Route request, Enso can select a documented bridge automatically. Use a Bundle bridge action when you need a particular provider or a destination callback.
- How do I add an Earn tab to a wallet or app?Build a catalog from token and protocol data, read balances, route into the selected destination, apply portal-configured fees if needed, then refresh balances.
- How do I withdraw from a vault and swap in one transaction?If the exit is a single path into one token, use the Route API. If you need redeem or harvest in a fixed order, use the Bundle API, often with…
- How do I migrate a yield position between protocols?Use the Route API when Enso can find a single path into one new destination. Use the Bundle API when the action order must be fixed.
- How do I simulate a transaction that needs a token approval first?Put the approval in preSimulationTransactions so Quoter runs it on the fork before the main call. You must still submit a real approval on-chain before the live transaction.
- How do I simulate a delegate call or smart-account transaction?Set operationType to 1 on the Quoter transaction to simulate a DelegateCall. The default, 0, is a standard Call. This is useful for smart-account and ERC-4337 flows.
- How do I simulate a DeFi transaction before sending it?Send the already-built EVM transaction to Enso Quoter’s simulate endpoint to preview amountOut, gas, and whether the call would succeed, then validate before signing.
- How do I read Quoter validation checks?The validate response includes a valid flag and a checks object for data, to, from, value, and chainId. If valid is false, inspect the failed fields and re-simulate; do not…
- How do I estimate tokens received from a contract call?Encode the contract call, then simulate it with Enso Quoter, passing tokenOut so the response’s amountOut array estimates the tokens received at current state.
- How do I preview the output of a transaction?Ask Enso Quoter to simulate the already-built transaction and read result.amountOut for each tokenOut you asked it to track, plus result.status and gas.
- How do I estimate gas for a DeFi transaction?Simulate the already-built transaction with Enso Quoter and read result.gas. The figure comes from actual execution on a forked state at simulation time.
- How do I check if a transaction will revert?Simulate the transaction with Enso Quoter and read result.status. Error means the call would fail on the fork; inspect result.error and do not send the transaction.
- How do I authenticate Enso Quoter requests?Use the same Developer Portal API key as the main Enso API. Pass it as a Bearer token or as an api_key query parameter to https://quoter.api.enso.build.
- Can I simulate a multicall with Enso Quoter?Yes. If you already have multicall calldata, send it to Quoter as a single transaction. To preview up to five separate already-built transactions, use the batch simulate endpoint.
- How do I set a partner fee on user trades?Configure fee rules and a payout wallet in the Developer Portal Fees tab. Enso applies them automatically to quotes from your API key; no request parameter is required.
- How do I simulate or validate a transaction I built myself?Send the already-built EVM transaction to Enso Quoter’s simulate endpoint, then validate the unsigned transaction against the simulationId before the user signs.
- How do I discover tokens, vaults, and protocols from the API?Use GET /v1/tokens, /v1/protocols, /v1/standards, and /v1/actions for the live catalog and metadata. Do not hardcode coverage from a static list.
- How do I get wallet balances and DeFi positions?Call GET /v1/wallet/balances before and after execution. Set useEoa to true when reading an EOA, or false for the associated Enso wallet.
- How do I use Enso with a smart wallet?Use the delegate routing strategy when execution must stay with the smart wallet or retain protocol state. Do not send router approvals unless the response asks for them.
- How do I attach destination actions after a bridge?Use a Bundle bridge action with a callback that starts with a balance action, then the destination deposit or swap, chaining amounts with useOutputOfCallAt.
- How do I bundle multiple DeFi actions into one transaction?Send an ordered list of actions to a bundling API so they run in one same-chain transaction. Enso’s Bundle API returns the signer-ready transaction data.
- How do I let users deposit into yield from any token?Route the token the user already holds into the chosen yield destination in one request, then refresh balances. Enso’s Route API is the standard path.
- How do I add a one-click zap into a vault?A zap lets users start from the token they hold and end in a vault or position in one flow. With Enso, route from that token into the destination position.
