Simulation
Simulation answers a quote that has already been checked against the current chain state. A simulation never submits anything on-chain.
The inline simulate flag
POST /transfers accepts options.simulate: true. The server simulates the
transfer and measures its gas, so metadata.gas in the response is a measured
estimate rather than a value taken from the quote.
If the transfer reverts, the request answers the simulation-failed 400 and no transaction is returned.
Leave the flag unset for a plain quote. A plain quote carries no metadata.gas,
because a quote alone does not produce one.
What the flag changes
| Field | simulate unset | simulate: true |
|---|---|---|
| HTTP status | 200 | 200, or 400 when the transfer reverts |
metadata.gas | absent | measured against the current chain state |
tx | present | present when the transfer simulates |
tx never carries a gas field, with or without the flag. Read the gas estimate
from metadata.gas.
Cost of the flag
simulate: true adds two remote calls to the request: one simulation and one gas
estimate. Leave the flag unset when you do not need either.
Why simulate first?
A quote describes what the route should do. A simulation describes what it does against the state the chain holds now. Between the two, a pool can move, a balance can change, or a fee bound can be crossed.
Simulate before you ask a user to sign when the request must not fail on-chain. Leave the flag unset when you only need the route and the transaction payload.