Skip to main content

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.

J
Written by Javier Diaz

Send the already-built EVM transaction to Enso Quoter’s simulate endpoint to preview amountOut, gas, and whether the call would succeed. Then validate the unsigned transaction against the returned simulationId before the user signs.

Definition

Simulating before sending means executing the calldata on a forked copy of current chain state, not broadcasting it. You get a predicted outcome first, and you only submit if that outcome is acceptable and the unsigned transaction still matches the simulation.

How it works

  • Build or receive the transaction (to, data, value, from) and choose the chainId.

  • Send it to the simulate endpoint with the tokens and amounts you want to track.

  • If result.status is "Error", fix the transaction and simulate again. Do not send it.

  • If it succeeds, show amountOut and gas, then call validate immediately before signing.

  • Sign and submit only when valid is true, using the transaction you built. Quoter does not rewrite it.

How Enso does this

POST https://quoter.api.enso.build/api/v1/simulate, then POST /api/v1/validate. Authenticate with the same Developer Portal key as the main Enso API. See Simulating Transactions. You do not need this flow before a Route call; Route already simulates the path it returns. Use Quoter when you already have calldata.

FAQ

Is this the same as requesting a Route quote?

No. Route finds a path and returns signer-ready tx data. This flow simulates a transaction you already built.

How long do I have after I simulate?

Simulations are cached for five minutes. After that, validate returns 404 and you must simulate again.

Related articles

  • How do I simulate or validate a transaction I built myself?

  • How do I preview the output of a transaction?

  • How do I check if a transaction will revert?

  • What is Enso Quoter?

  • Enso Route vs Enso Quoter

Sources

Did this answer your question?