Skip to content
BlockhashBlockhashBlock 123,784,775 Sign in Join the waitlist Dashboard

Swap API

A price, or the transactions to sign, for any two tokens: powered by Mancer.

The endpoint

The Swap API answers one request, quote: what one token is worth in another on Robinhood Chain. Asked bare, the answer is the price. Asked with the wallet that swaps, the answer is the transactions that wallet signs.

The route is found by Mancer, the dex aggregator and order layer of Robinhood Chain, and every answer says so. Every transaction is Mancer’s calldata, handed on unchanged for your user to sign. Blockhash signs and sends nothing.

The path is the endpoint, your key, the network, then quote. The key can be sent as Authorization: Bearer instead, to /swap/v1/robinhood-mainnet/quote; both at once is refused. The same key works on the RPC and the Data API.

An app’s rules hold here as at the RPC: its websites, its IP addresses, and its contracts list, which must hold both tokens, ether counted as WETH.

Any origin may call, and no cookie is read. The parameters are query parameters; a name the table does not list is refused, so a misspelled one is never dropped.

An address is 0x and 40 hex digits in either case; every address in an answer is lower case. An amount is a decimal string of raw units, digits only. Every answer carries Cache-Control: no-store and X-Request-Id, which a page on any origin can read, as it can Retry-After.

Request
Method
GET
Network
robinhood-mainnet
Key
In the path, or as a Bearer token
A quote
800 units
Powered by
Mancer
KEY="<your key>"

curl -H "authorization: Bearer $KEY" \
  "https://api.blockhash.xyz/swap/v1/robinhood-mainnet/quote?tokenIn=0x0bd7d308f8e1639fab988df18a8011f41eacad73&tokenOut=0x5fc5360d0400a0fd4f2af552add042d716f1d168&amountIn=100000000000000000"

Parameters

A value out of its bounds is refused, naming the parameter. It is never passed on to be clamped.

taker holds the input, signs every transaction and sends them. recipient receives the output; it is the taker where it is not sent.

The swap’s calldata carries a floor, minAmountOut in the answer: under it the swap reverts and nothing is spent but gas. It is Mancer’s estimate less slippageBps. Send the floor your user agreed to as minAmountOut: if the fresh amount out is under it, the quote is refused with slippage-exceeded, and otherwise the stronger of the two floors holds.

NameTypeWhat it meansDefault
tokenInaddressRequired. The token sold. 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee for ether.
tokenOutaddressRequired. The token bought. Not the same token as tokenIn, ether and WETH counted as one.
amountIndecimal stringRequired. How much of tokenIn is sold, in raw units (wei for ether): 1 to 2^256 - 1, at most 78 digits.
takeraddressThe wallet that holds tokenIn, signs and sends. With it the answer carries the transactions. Not the zero address.a price
recipientaddressThe address that receives tokenOut. Needs taker. Not the zero address.the taker
slippageBpswhole numberHow far under the quoted amount the swap may deliver before it reverts: 1 to 5,000 basis points. Needs taker.Mancer’s
minAmountOutdecimal stringThe least amount out your user accepted when they saw the price, in raw units of tokenOut. Needs taker.
integratorFeeBpswhole numberYour own fee: 1 to 100 basis points (1%).no fee
integratorFeeRecipientaddressThe address your fee is paid to. Required with integratorFeeBps. Not the zero address, and not one of Mancer’s own addresses.
integratorFeeSide"output" or "input"Which token pays your fee. Needs the two above.output

Ether

Ether is 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee in tokenIn or tokenOut, as other swap APIs spell it. The zero address is read the same, and an answer spells it as the first.

With ether sold, the swap’s value is amountIn and there is no approval.

Ether for WETH, either way, is a wrap and no swap: the two count as one token, and the request is refused. WETH is 0x0bd7d308f8e1639fab988df18a8011f41eacad73.

https://api.blockhash.xyz/swap/v1/<your key>/robinhood-mainnet/quote?tokenIn=0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee&tokenOut=0x5fc5360d0400a0fd4f2af552add042d716f1d168&amountIn=100000000000000000
{"network":"robinhood-mainnet",
 "chainId":4663,
 "tokenIn":"0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
 "tokenOut":"0x5fc5360d0400a0fd4f2af552add042d716f1d168",
 "amountIn":"100000000000000000",
 "routeFound":true,
 "amountOut":"180721381",
 "minAmountOut":null,
 "amountInUsd":180.56099028739087,
 "amountOutUsd":180.7213814934,
 "priceImpactBps":0,
 "recommendedSlippageBps":20,
 "slippageBps":null,
 "fees":{"mancer":{"bps":2,"token":"0x0bd7d308f8e1639fab988df18a8011f41eacad73","side":"input"},
   "integrator":null},
 "route":[
   {"venue":"ramsescl",
     "tokenIn":"0x0bd7d308f8e1639fab988df18a8011f41eacad73",
     "tokenOut":"0x5fc5360d0400a0fd4f2af552add042d716f1d168",
     "shareBps":10000}],
 "transactions":null,
 "requirements":null,
 "simulation":null,
 "warnings":[],
 "expiresAt":null,
 "poweredBy":"Mancer"}

A price

Asked with no taker, the answer is a price: the fields of a quote, with those of the transactions null.

The sample asks what 0.1 WETH is worth in USDG.

https://api.blockhash.xyz/swap/v1/<your key>/robinhood-mainnet/quote?tokenIn=0x0bd7d308f8e1639fab988df18a8011f41eacad73&tokenOut=0x5fc5360d0400a0fd4f2af552add042d716f1d168&amountIn=100000000000000000
{"network":"robinhood-mainnet",
 "chainId":4663,
 "tokenIn":"0x0bd7d308f8e1639fab988df18a8011f41eacad73",
 "tokenOut":"0x5fc5360d0400a0fd4f2af552add042d716f1d168",
 "amountIn":"100000000000000000",
 "routeFound":true,
 "amountOut":"180721381",
 "minAmountOut":null,
 "amountInUsd":180.56099028739087,
 "amountOutUsd":180.7213814934,
 "priceImpactBps":0,
 "recommendedSlippageBps":20,
 "slippageBps":null,
 "fees":{"mancer":{"bps":2,"token":"0x0bd7d308f8e1639fab988df18a8011f41eacad73","side":"input"},
   "integrator":null},
 "route":[
   {"venue":"ramsescl",
     "tokenIn":"0x0bd7d308f8e1639fab988df18a8011f41eacad73",
     "tokenOut":"0x5fc5360d0400a0fd4f2af552add042d716f1d168",
     "shareBps":10000}],
 "transactions":null,
 "requirements":null,
 "simulation":null,
 "warnings":[],
 "expiresAt":null,
 "poweredBy":"Mancer"}

A quote with transactions

Asked with taker, the answer carries the transactions that wallet signs, in order: here an approval, then the swap.

The sample sells 0.1 WETH for USDG at the tolerance Mancer recommends, 20 bps: its floor is that far under Mancer’s estimate, and the swap reverts after its expiry.

A price is asked again as a quote with transactions when your user is ready to sign, and a quote that waited is asked again, not kept.

A token Mancer swaps through a launchpad, not its router, is answered with its price alone: no transactions, and the warning transactions-unavailable. It is charged as a quote.

https://api.blockhash.xyz/swap/v1/<your key>/robinhood-mainnet/quote?tokenIn=0x0bd7d308f8e1639fab988df18a8011f41eacad73&tokenOut=0x5fc5360d0400a0fd4f2af552add042d716f1d168&amountIn=100000000000000000&taker=<a wallet>
{"network":"robinhood-mainnet",
 "chainId":4663,
 "tokenIn":"0x0bd7d308f8e1639fab988df18a8011f41eacad73",
 "tokenOut":"0x5fc5360d0400a0fd4f2af552add042d716f1d168",
 "amountIn":"100000000000000000",
 "routeFound":true,
 "amountOut":"180712919",
 "minAmountOut":"180351492",
 "amountInUsd":180.56099028739087,
 "amountOutUsd":180.74906900020002,
 "priceImpactBps":1,
 "recommendedSlippageBps":20,
 "slippageBps":20,
 "fees":{"mancer":{"bps":2,"token":"0x0bd7d308f8e1639fab988df18a8011f41eacad73","side":"input"},
   "integrator":null},
 "route":[
   {"venue":"metric",
     "tokenIn":"0x0bd7d308f8e1639fab988df18a8011f41eacad73",
     "tokenOut":"0x5fc5360d0400a0fd4f2af552add042d716f1d168",
     "shareBps":10000}],
 "transactions":[
   {"type":"approval",
     "to":"0x0bd7d308f8e1639fab988df18a8011f41eacad73",
     "data":"0x095ea7b30000000000000000000000004c16269006db0dd87e6ae3c8a014b2807aa2e388000000000000000000000000000000000000000000000000016345785d8a0000",
     "value":"0",
     "gas":"79453"},
   {"type":"swap",
     "to":"0xa62858659c83095eb5e702f0af6a7bb7f370b3e7",
     "data":"0x85e6ff1e0000000000000000000000000000000000000000000000000000000000000020…0000000000000000",
     "value":"0",
     "gas":"462742"}],
 "requirements":{"balance":{"token":"0x0bd7d308f8e1639fab988df18a8011f41eacad73",
     "amount":"100000000000000000"},
   "allowance":{"token":"0x0bd7d308f8e1639fab988df18a8011f41eacad73",
     "spender":"0x4c16269006db0dd87e6ae3c8a014b2807aa2e388",
     "amount":"100000000000000000"}},
 "simulation":{"ok":true,
   "block":117043135,
   "error":null,
   "native":{"needed":"22006610660000","balance":"2509167418793094395","covered":true}},
 "warnings":[],
 "expiresAt":1794967062,
 "poweredBy":"Mancer"}

The answer

A request that is answered is 200 with one of three bodies: a price, a quote with transactions, or no route. A price and a quote with transactions have the same fields: one that belongs to the transactions is null on a price, never missing.

FieldFormWhat it is
network, chainIdstring, numberThe network asked, and its chain’s id: 4663.
tokenIn, tokenOut, amountInaddress, address, stringWhat was asked, in lower case, ether as 0xeeee…eeee.
routeFoundbooleantrue; false where there is no route.
amountOutstringWhat the recipient receives, after Mancer’s fee and yours. With transactions, what Mancer’s simulation of the swap measured. The number to show.
minAmountOutstring or nullThe floor the swap’s calldata enforces. null on a price.
amountInUsd, amountOutUsdnumber or nullThe two amounts in dollars, by Mancer’s reference prices.
priceImpactBpsnumber or nullWhat the order’s size cost against its route’s marginal rate. Never negative.
recommendedSlippageBpsnumberThe tolerance Mancer recommends for the pair now.
slippageBpsnumber or nullThe tolerance the floor was made with: yours, else the recommended one. null on a price.
feesobjectMancer’s fee and yours, each already taken out of amountOut.
routelistEach pool the swap goes through: venue, tokenIn, tokenOut, and shareBps, the leg’s share of what the route spends of its tokenIn.
transactionslist or nullWhat the taker signs and sends, in order. null on a price.
requirementsobject or nullWhat the wallet must hold and allow before signing. null on a price.
simulationobject or nullWhether the transactions ran from the wallet’s own balances, and why not. null on a price.
warningslistWhat to show your user before they sign. Empty where there is nothing.
expiresAtnumber or nullThe Unix second after which the swap reverts: ten minutes after it was built. null on a price.
poweredBystring"Mancer".

Fees

Mancer’s fee is taken by Mancer’s router inside the swap, out of amountOut. fees.mancer is {bps, token, side}: its rate, the token it is taken in, and the side, input, output or mid. Mancer gives no amount for it.

It is taken in the pair’s higher-ranked token: ether, then dollars, then any other, and from the input on a tie.

PairMancer’s fee
A dollar and a dollar (USDG, USDC)Nothing
Ether or WETH and a dollar2 bps (0.02%)
Every other pair10 bps (0.10%)
Either token first seen less than 24 hours ago50 bps (0.50%)
https://api.blockhash.xyz/swap/v1/<your key>/robinhood-mainnet/quote?tokenIn=0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee&tokenOut=0x5fc5360d0400a0fd4f2af552add042d716f1d168&amountIn=100000000000000000&taker=<a wallet>&integratorFeeBps=10&integratorFeeRecipient=<your fee’s address>&integratorFeeSide=output
{"network":"robinhood-mainnet",
 "chainId":4663,
 "tokenIn":"0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
 "tokenOut":"0x5fc5360d0400a0fd4f2af552add042d716f1d168",
 "amountIn":"100000000000000000",
 "routeFound":true,
 "amountOut":"180532207",
 "minAmountOut":"180171141",
 "amountInUsd":180.56099028739087,
 "amountOutUsd":180.74906900120124,
 "priceImpactBps":1,
 "recommendedSlippageBps":20,
 "slippageBps":20,
 "fees":{"mancer":{"bps":2,"token":"0x0bd7d308f8e1639fab988df18a8011f41eacad73","side":"input"},
   "integrator":{"bps":10,
     "recipient":"0x…",
     "side":"output",
     "token":"0x5fc5360d0400a0fd4f2af552add042d716f1d168",
     "amount":"180712"}},
 "route":[
   {"venue":"metric",
     "tokenIn":"0x0bd7d308f8e1639fab988df18a8011f41eacad73",
     "tokenOut":"0x5fc5360d0400a0fd4f2af552add042d716f1d168",
     "shareBps":10000}],
 "transactions":[
   {"type":"swap",
     "to":"0xa62858659c83095eb5e702f0af6a7bb7f370b3e7",
     "data":"0x85e6ff1e0000000000000000000000000000000000000000000000000000000000000020…0000000000000000",
     "value":"100000000000000000",
     "gas":"526679"}],
 "requirements":{"balance":{"token":"0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
     "amount":"100000000000000000"},
   "allowance":null},
 "simulation":{"ok":true,
   "block":117043139,
   "error":null,
   "native":{"needed":"100021081907012000","balance":"2509167418793094395","covered":true}},
 "warnings":[],
 "expiresAt":1794967063,
 "poweredBy":"Mancer"}

Your own fee

  • Add a fee of up to 100 bps (1%) with integratorFeeBps, paid inside the swap to integratorFeeRecipient. Blockhash adds no fee of its own and takes no part of yours.
  • output, the default, pays it in the token bought: the rate of what the swap delivers, taken at its end. amountOut and the floor are after it.
  • input pays it in the token sold: exactly the rate of amountIn, taken before the swap. The taker still spends the whole amountIn.
  • A fee on a side that is ether is paid as ether. A recipient that refuses ether, or needs more than 30,000 gas to take it, is paid WETH.
  • Your fee’s recipient may not be one of Mancer’s own addresses: its router, the router’s allowance target, WETH, MancerIntegratorFee, its DirectPoolExecutor, the key that sends MancerOrders’ fills.
  • Send the same three parameters on the price and on the quote with transactions, so the price shows what your user will receive.
  • The fee adds a step to the swap, and its gas is inside each transaction’s gas. Some routes cannot carry it: with a fee, such a token may find a lesser route, or none.
  • fees.integrator is {bps, recipient, side, token, amount}, ether as 0xeeee…eeee. On the input amount is the exact fee; on the output it is the fee at this quote.

The transactions to sign

Send transactions in order, each once the one before it has its receipt. Each is {type, to, data, value, gas}: type is approval, swap, or authorization (a launchpad’s own setup); the swap is last, and there is exactly one. Sign data as it is.

gas is a limit Mancer’s simulation proved: what the transaction spent, 30% more, and 10,000 for the chain’s data fee. It is null where the simulation did not reach it.

requirements.balance is what the taker must hold: the whole amountIn. requirements.allowance is what the spender must be allowed to take, null where ether is sold; the approval sets exactly that.

Before transactions are served, Blockhash reads the swap’s calldata and holds it to the request: the tokens, the amount, the recipient, the floor and your fee. A build that differs is not served (unavailable), and is not charged. So no transaction pays anyone you did not name.

Before it answers, Mancer runs the transactions from the taker’s own balances and allowances on the chain’s head. simulation.ok false is still a 200: the price and the transactions stand, and the wallet cannot send them now. Show why, and ask for no signature. simulation.native says whether the wallet’s ether covers every transaction’s gas and value.

The swap reverts after expiresAt, ten minutes after it was built. Today the swap goes to MancerRouter, 0xa62858659c83095eb5e702f0af6a7bb7f370b3e7, and the approval’s spender is its allowance target, 0x4c16269006db0dd87e6ae3c8a014b2807aa2e388. Both are Mancer’s to change: https://api.mancer.xyz/v1/contracts names the live ones with the hash of their code.

// 200, with the price and both transactions: the wallet cannot send them now
{"transactions":[
   {"type":"approval","to":"0x0bd7d308f8e1639fab988df18a8011f41eacad73",
    "data":"0x095ea7b3…","value":"0","gas":"79453"},
   {"type":"swap","to":"0xa62858659c83095eb5e702f0af6a7bb7f370b3e7",
    "data":"0x85e6ff1e…","value":"0","gas":null}],
 "simulation":{"ok":false,"block":116741864,
   "error":{"transaction":1,"reason":"Error",
     "message":"step 2 (swap) reverts Error: ERC20: transfer amount exceeds balance at the head"},
   "native":{"needed":null,"balance":"…","covered":null}},
 …}

Warnings

Each warning is {code, message}, and sell-tax also carries bps. Show it to your user before they sign. Match on the code: the message is a sentence to read.

Where Mancer refuses the trade there is nothing to warn on: it is an error, and a price is refused as its transactions would be.

CodeWhen
value-discrepancyThe amount out is worth half or less of the amount in, by Mancer’s reference prices, and the quote is still served.
round-tripSelling what the swap buys straight back would lose half or more, and the quote is still served.
sell-gatedThe route buys through a pool that accepts a sale only with its issuer’s signature.
sell-taxThe token bought keeps a share of a later sale, given as bps.
sell-unprovenA wallet that never bought could not sell the token in simulation, and nobody has traded it yet.
market-noteMancer’s own sentence about market hours, word for word.
cautionAny other reason of Mancer’s to warn.
transactions-unavailableA launchpad’s token asked with a taker: its price is answered, and its transactions are not. It comes first.

Tokenized stocks

Some tokens on Robinhood Chain are tokenized stocks. The Swap API quotes them and builds their transactions for every key, from every place.

You answer for where your own users are. Do not show, quote or build a tokenized stock for a user in a place where it may not be offered to them.

Blockhash does not check which country a request comes from, and passes nothing of where it came from on to Mancer.

Mancer’s public API says which tokens are stocks: every token there carries isStock. https://api.mancer.xyz/v1/tokens/<address> reads one, and https://api.mancer.xyz/v1/tokens/discover?filter=stocks lists them, up to a hundred a page. Neither needs a key.

A quote between two tokens that are not stocks can route through a stock, and its transactions can leave some of that stock with your user.

Outside US market hours a stock’s price is wide, and the answer carries the market-note warning. Show it.

None of this is legal advice about any place.

No route

Where Mancer finds no route the answer is 200 and short, with routeFound false. It is the market’s answer, and it is charged.

An amount the market cannot fill is no route, or a route at a poor price that priceImpactBps shows.

https://api.blockhash.xyz/swap/v1/<your key>/robinhood-mainnet/quote?tokenIn=0x0bd7d308f8e1639fab988df18a8011f41eacad73&tokenOut=0x000000000000000000000000000000000000dead&amountIn=10000000000000000
{"network":"robinhood-mainnet","chainId":4663,
 "tokenIn":"0x0bd7d308f8e1639fab988df18a8011f41eacad73",
 "tokenOut":"0x000000000000000000000000000000000000dead",
 "amountIn":"10000000000000000",
 "routeFound":false,"poweredBy":"Mancer"}

Errors

A refusal has an HTTP status and the body {"error": {"code", "message"}}: a word, and a sentence to read, as the Data API’s are. Match on the status and the code.

A refusal of the trade (409) is not retried with a new floor: Mancer keeps a pair refused while its market is.

CodeHTTPCaseCharged
invalid-key401No key, or one that does not exist or was revokedNo
invalid-parameter400A parameter missing, malformed, out of its bounds, unknown or sent twice, the same token twice, a fee recipient that is one of Mancer’s own addresses, or the key in the path and as a Bearer both; or a request Mancer refused, such as an input-side fee that leaves nothing to swap. The message names what to fixWhere Mancer refused it
method-not-allowed405Any method but GET, answered with Allow: GETNo
no-such-network404A network that is not served: the message names those that areNo
not-found404A call under the network that is not quoteNo
origin-not-allowed403A website the app’s rules leave outNo
ip-not-allowed403An IP address the app’s rules leave outNo
contract-not-allowed403A token the app’s contracts list leaves out, ether counted as WETHNo
suspended403The account is suspendedNo
limit-reached403The monthly limit set on Pay as you go reachedNo
month-used403The Free plan’s month used upNo
rate-limited429Over the account’s speed or a ceiling, or too many quotes waiting: wait the seconds in Retry-AfterNo
slippage-exceeded409The price moved under minAmountOutYes
sell-blocked409The token bought cannot be soldYes
sell-gated409The token’s market takes a sale only with its issuer’s signature, and nothing else would buy it backYes
router-refused409The token refuses a transfer out of the router, so no route can deliver itYes
round-trip409Selling what the swap buys straight back would return under halfYes
pool-fee409A pool on the route keeps most of the tradeYes
value-discrepancy409The amount out is far below the reference valueYes
no-transaction409A price was found, and no transaction could be built that passes simulationYes
refused409Any other refusal of the tradeYes
integrator-fee-unavailable503Your fee cannot be taken now: ask without it, or after Retry-AfterNo
unavailable503Mancer did not answer, its quotes are paused, or a build did not match the request: ask again after Retry-AfterNo
timeout504The quote ran past its time of 11 secondsNo
curl -G "$SWAP/quote" \
  -d tokenIn=0x0bd7d308f8e1639fab988df18a8011f41eacad73 \
  -d tokenOut=0x5fc5360d0400a0fd4f2af552add042d716f1d168 \
  -d amountIn=100000000000000000 \
  -d slipageBps=50
HTTP 400
{"error":{"code":"invalid-parameter",
   "message":"slipageBps is not a parameter of a quote: it takes tokenIn, tokenOut, amountIn, taker, recipient, slippageBps, minAmountOut, integratorFeeBps, integratorFeeRecipient, integratorFeeSide"}}

Units and limits

A price and a quote with transactions cost the same, 800 units, and take 50 units from the plan’s speed, which is one bucket across the RPC, the Data API and the Swap API.

A quote is charged once it is sent to Mancer and Mancer answers anything but a failure of its own: a price, transactions whatever their simulation says, no route, a trade Mancer will not build, and a request Mancer refuses as wrong. A caller who hangs up after the quote was sent is charged too: Mancer did the work.

Not charged: what Blockhash refuses before asking Mancer, Mancer refusing Blockhash’s own key or its bucket for it being full, and Mancer’s failures: no answer, a quote past its time, an answer that cannot be read, a build that does not match the request.

Past a ceiling the request is refused with rate-limited and Retry-After, and Mancer is not asked. Every figure in compute units is on Compute units.

A quote
800 units
Against the speed
50 units
A refusal
5 units of speed
A thousand quotes
$0.16
CeilingFigure
Quotes a second, every account together25
Quotes a second, the free accounts together5
Quotes a second, any one account10
Quotes waiting on Mancer at once, every account together50
Quotes waiting on Mancer at once, any one account10
Seconds for an answer11