Skip to content

Simulate a built transaction before signing

POST
/swap/simulate
curl --request POST \
--url https://api.getchord.xyz/v1/swap/simulate \
--header 'Content-Type: application/json' \
--data '{ "chain": 5042, "from": "0xb145400da27a2497d9fc2cd5621f2bfd37617af4", "to": "0x1b1fee89a381e595fe6536b99ba91f3e16e9601a", "data": "0xdc72a437…", "value": "0" }'

eth_calls the built calldata from the user’s address and estimates gas, so a revert is caught before the wallet opens. Known selectors are decoded (NotRouter, a paused Kuru market, allowance and balance errors). An allowance revert is advisory: approve first, then swap.

Media typeapplication/json
object
chain
integer
Allowed values: 5042 4663 143 43114 8453 56 42161 1
from
required

EVM address, hex, case-insensitive.

string
/^0x[a-fA-F0-9]{40}$/
to
required

EVM address, hex, case-insensitive.

string
/^0x[a-fA-F0-9]{40}$/
data
required

Calldata from /swap.

string
value
required

Amount in the token’s smallest unit, as a decimal string. Never a float.

string
/^\d+$/
Example
{
"chain": 5042,
"from": "0xb145400da27a2497d9fc2cd5621f2bfd37617af4",
"to": "0x1b1fee89a381e595fe6536b99ba91f3e16e9601a",
"data": "0xdc72a437…",
"value": "0"
}

ok: true with the simulated output and gas, or ok: false with the decoded revert.

Media typeapplication/json
object
ok
boolean
amountOut

Simulated output, smallest unit.

string | null
gas

Estimated gas units.

integer | null
revert

Decoded reason (when ok is false).

string
selector

4-byte error selector.

string | null
Example
{
"ok": true,
"amountOut": "465",
"gas": 318189
}

Invalid parameters — error names the check that failed (INVALID_PARAMS, BAD_ADDRESS, BAD_LIMIT, BAD_HOURS, …).

Media typeapplication/json

Every non-2xx body.

object
error
required

Stable machine code, e.g. INVALID_PARAMS, NOT_READY, RATE_LIMIT_EXCEEDED.

string
message

For humans.

string
statusCode

HTTP status, when included.

integer
Example
{
"error": "INVALID_PARAMS",
"message": "amount must be an integer string in the token's smallest unit"
}

The lane behind this endpoint is not ready or not enabled here (NOT_READY, CHAIN_NOT_ENABLED, NOT_ENABLED, *_UNAVAILABLE). Retry later; do not treat it as an empty answer.

Media typeapplication/json

Every non-2xx body.

object
error
required

Stable machine code, e.g. INVALID_PARAMS, NOT_READY, RATE_LIMIT_EXCEEDED.

string
message

For humans.

string
statusCode

HTTP status, when included.

integer
Example
{
"error": "INVALID_PARAMS",
"message": "amount must be an integer string in the token's smallest unit"
}