$ man tx-simulate-swap
/tx-simulate-swap(1)
PRICE / CALL
$0.02
USDC · base mainnet · scheme: exact
METHOD
POST
CLUSTER
edgemarketCATEGORY
uncategorized
STATUS
● live
NAME
tx-simulate-swap — tx simulate swap / pre-trade quote / dex swap simulator / 1inch + llamaswap quote / would-it-succeed check
SYNOPSIS
POST https://x402.org/v1/tx-simulate-swap
Content-Type: application/json
X-PAYMENT: <signed-transferWithAuthorization>
{ ... }↳ first call →
402 Payment Required. Sign USDCtransferWithAuthorization, retry with theX-PAYMENT header.DESCRIPTION
Tx simulate swap / pre-trade quote / DEX swap simulator / 1inch + LlamaSwap quote / would-it-succeed check. Given (from_token, to_token, amount_in, chain), pulls a routed quote from a free DEX meta-aggregator and returns expected output, min-out at user-supplied slippage (default 1%), gas estimate, router address, and a would_succeed verdict. Quote-only depth — full Tenderly-style state simulation requires a paid API and is documented in the response's simulation_caveat.
INPUT — request schema
| property | type | description | req? |
|---|---|---|---|
| from_token | string | 0x-prefixed 20-byte ERC-20 input token. | required |
| to_token | string | 0x-prefixed 20-byte ERC-20 output token. | required |
| amount_in | string | Input amount as a decimal string in smallest units (wei-equivalent). | required |
| chain | string | EVM chain. Default 'base'. enum: base · ethereum · polygon · arbitrum · optimism | optional |
| slippage_pct | number | Slippage tolerance for min_out, in percent. Range [0, 50]. Default 1. | optional |
OUTPUT — response shape
| field | type | description |
|---|---|---|
| chain | string | Chain identifier (e.g. ethereum, base, arbitrum) the quote was routed on. |
| from_token | string | Source token address or symbol being swapped from. |
| to_token | string | Destination token address or symbol being swapped into. |
| amount_in | string | Input amount of from_token, echoed back in the same units the caller supplied. |
| expected_out | string | Routed quote's expected output amount of to_token before slippage is applied. |
| min_out | string | Minimum acceptable output amount after applying slippage_pct, used as the swap floor. |
| slippage_pct | string | Slippage tolerance applied to derive min_out, defaulting to 1% when caller omits it. |
| gas_estimate | string | Estimated gas units the routed swap would consume on-chain. |
| router | string | Address of the DEX router contract the quote would execute against. |
| approval_target | string | Address the user must grant ERC-20 allowance to before the swap can pull from_token. |
| would_succeed | string | Boolean verdict on whether the routed quote looks executable given current liquidity and gas. |
| simulation_kind | string | Label for the simulation depth used (quote-only vs full state sim). |
| source | string | Upstream aggregator that produced the quote, e.g. 1inch or LlamaSwap. |
EXAMPLES — two ways to call
EXAMPLE 1 · curl
curl -X POST https://x402.org/v1/tx-simulate-swap \
-H 'Content-Type: application/json' \
-d '{ }'first response =
402 Payment Required with payment requirements; sign + retry with X-PAYMENT.EXAMPLE 2 · mcp
# install once claude mcp add x402 --command "npx x402-deployer-mcp" # then ask Claude Code: # "use the tx-simulate-swap tool to ..."
MCP server handles payment automatically — your coding agent just calls the tool by name.
METADATA
- tags
- edge-marketdex-aggregatorswap-quotepre-trade-simulationslippage-checkgas-estimate1inchswap-simulator
- methods
- POST
- cluster
- edgemarket
- price
- $0.02 USDC per call
ADJACENT — other endpoints in edgemarket
| endpoint | description | price |
|---|---|---|
| defi-llama-protocol | DefiLlama protocol lookup — TVL, chain breakdown, current TVL, 24h/7d/30d changes, audits, parent protocol, categories. | $0.02 |
| gas-now-base | Gas oracle / EIP-1559 fee estimator. | $0.02 |
| gas-price | Gas price API / EIP-1559 fee estimator / Base + Ethereum + Optimism + Arbitrum gas tracker / pre-tx cost estimator. | $0.02 |
| token-price | Crypto token price API / CoinGecko wrapper. | $0.02 |
| tx-receipt-decode | EVM transaction receipt decoder / log decoder / event log reader / Etherscan tx debug / receipt parser / Basescan tx explainer / tenderly… | $0.02 |
| bridge-rates | Cross-chain bridge rate aggregator. | $0.03 |
| dao-proposal-monitor | Snapshot.org DAO proposal monitor. | $0.03 |
| ens-resolve | ENS resolver / Ethereum Name Service lookup. | $0.03 |
SEE ALSO