Simulate a built transaction before signing
const url = 'https://api.getchord.xyz/v1/swap/simulate';const options = { method: 'POST', headers: {'Content-Type': 'application/json'}, body: '{"chain":5042,"from":"0xb145400da27a2497d9fc2cd5621f2bfd37617af4","to":"0x1b1fee89a381e595fe6536b99ba91f3e16e9601a","data":"0xdc72a437…","value":"0"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}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.
Request Bodyrequired
Section titled “Request Bodyrequired”object
EVM address, hex, case-insensitive.
EVM address, hex, case-insensitive.
Calldata from /swap.
Amount in the token’s smallest unit, as a decimal string. Never a float.
Example
{ "chain": 5042, "from": "0xb145400da27a2497d9fc2cd5621f2bfd37617af4", "to": "0x1b1fee89a381e595fe6536b99ba91f3e16e9601a", "data": "0xdc72a437…", "value": "0"}Responses
Section titled “ Responses ”ok: true with the simulated output and gas, or ok: false with the decoded revert.
object
Simulated output, smallest unit.
Estimated gas units.
Decoded reason (when ok is false).
4-byte error selector.
Example
{ "ok": true, "amountOut": "465", "gas": 318189}Invalid parameters — error names the check that failed (INVALID_PARAMS, BAD_ADDRESS, BAD_LIMIT, BAD_HOURS, …).
Every non-2xx body.
object
Stable machine code, e.g. INVALID_PARAMS, NOT_READY, RATE_LIMIT_EXCEEDED.
For humans.
HTTP status, when included.
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.
Every non-2xx body.
object
Stable machine code, e.g. INVALID_PARAMS, NOT_READY, RATE_LIMIT_EXCEEDED.
For humans.
HTTP status, when included.
Example
{ "error": "INVALID_PARAMS", "message": "amount must be an integer string in the token's smallest unit"}