Skip to main content

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.

J
Written by Javier Diaz

Encode the contract call, then simulate it with Enso Quoter. Pass tokenOut so the response’s amountOut array estimates the tokens received if that call were executed at current state.

Definition

This is a preview of token output from calldata you already have — a deposit, swap, or other contract interaction — not a request for Enso to find a route. You tell Quoter which output tokens to track, and it reports predicted amounts in wei.

How it works

  • Encode the function call into hex data and set to, from, and value.

  • Choose tokenIn and amountIn for the assets the call spends, and tokenOut for the assets you expect to receive.

  • If the receiver is not the sender, set the optional receiver field so tracking can follow the destination.

  • Send the request to the simulate endpoint and read result.amountOut when status is "Success".

  • Validate before signing if you will submit this same calldata.

How Enso does this

The Third-Party Transactions guide shows encoding a contract call and sending it to POST https://quoter.api.enso.build/api/v1/simulate. Map data, to, from, and value from your web3 library into that request. Quoter does not modify the call. If you instead want Enso to build the path, use the Route API.

FAQ

What units is the estimate in?

amountOut is in wei (the token’s base unit), one value per tokenOut address.

Can I estimate output from a transaction I did not get from Enso?

Yes. Quoter is source-agnostic and accepts any valid EVM calldata.

Related articles

  • How do I preview the output of a transaction?

  • How do I simulate transactions from another protocol or aggregator?

  • How do I track token flows in a Quoter simulation?

  • How do I simulate a transaction with curl?

  • What is Enso Quoter?

Sources

Did this answer your question?