Skip to main content

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.

J
Written by Javier Diaz

POST the already-built transaction as JSON to https://quoter.api.enso.build/api/v1/simulate with a Bearer API key. Then, before signing, POST the simulationId and unsigned transaction to /api/v1/validate.

Definition

curl is just an HTTP client for the same simulate-then-validate flow. You still send chainId, transaction, tokenIn, tokenOut, and amountIn, and you still sign only when valid is true.

How it works

  • Set ENSO_API_KEY to your Developer Portal key.

  • POST a JSON body to /api/v1/simulate with Content-Type: application/json and Authorization: Bearer $ENSO_API_KEY.

  • Read result.status, result.amountOut, result.gas, and simulationId from the response. HTTP 200 is not enough; check result.status.

  • Within five minutes, POST to /api/v1/validate with that simulationId and the unsigned transaction fields (data, to, from, value, chainId).

  • For up to five already-built transactions that share the same token-flow fields, POST to /api/v1/simulate/batch instead.

How Enso does this

The Quoter overview and Simulating Transactions show this HTTP interface. You can also pass the key as api_key on the query string. Quoter does not modify the transaction you later submit.

FAQ

Where do I get the transaction fields?

From the calldata you already built (to, data, value, from) and the chain you will submit on. If Enso should build the path, call the Route API instead of composing calldata by hand.

What if curl returns 401 or 404?

401 means the key is missing or invalid. 404 on validate means the simulationId was not found or expired; simulate again.

Related articles

  • How do I authenticate Enso Quoter requests?

  • How do I simulate a DeFi transaction before sending it?

  • How do I simulate multiple transactions at once?

  • Why is my Quoter simulation status Error but the HTTP status is 200?

  • How do I submit Enso transaction data from my app?

Sources

Did this answer your question?