Skip to main content

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.

J
Written by Javier Diaz

Send the already-built EVM transaction to Enso Quoter’s simulate endpoint, then validate the unsigned transaction against the returned simulationId before the user signs.

Definition

This flow is for a transaction you already constructed — including calldata that did not come from the Route or Bundle API. Simulation predicts output and gas; validation checks that the unsigned transaction still matches what was simulated.

How it works

  • Send the transaction, chain ID, and the tokens and amounts to track to the simulate endpoint.

  • Review result.status, predicted amountOut, and gas. If status is an error, fix the transaction and simulate again.

  • Immediately before signing, send the unsigned transaction with the simulationId to the validate endpoint.

  • Sign only when valid is true. If any check fails or the simulation has expired, do not sign; simulate again.

How Enso does this

Use https://quoter.api.enso.build. Authenticate with the same API key as the main Enso API. Call POST /api/v1/simulate with chainId, transaction (to, data, value, from), tokenIn, tokenOut, and amountIn. Then call POST /api/v1/validate with that simulationId and the unsigned transaction. Simulations expire after five minutes. You can also simulate up to five transactions in one POST /api/v1/simulate/batch request. See Simulating Transactions and Validating Transactions.

FAQ

Should I use Quoter before every Route call?

No. Route already simulates internally. Use Quoter for transactions you built yourself, or when you want an extra simulate-then-validate check on existing calldata.

What if validation returns 404?

The simulation was not found or has expired. Re-simulate to get a fresh simulationId and validate again within the five-minute window.

Related articles

  • What is Enso Quoter?

  • Enso Route vs Enso Quoter

  • What is transaction simulation in DeFi?

  • How do I show a quote before the user signs?

  • What is signer-ready transaction data?

Sources

Did this answer your question?