Endpoints
/build

Build a Transaction

The /build endpoint lets you build a transaction from a received quote.

https://api.hypersonic.exchange/v1/build

Request type: POST

To build a transaction from a generated quote, send the data object received as output from /quote to the /build endpoint.

Body Parameters

Same as /quote output (data object).

Example Body

{
  "chainId": 10,
  "inToken": "0x4200000000000000000000000000000000000006",
  "inDecimals": 18,
  "inAmount": "1000000000000000000",
  "outToken": "0x4200000000000000000000000000000000000042",
  "outDecimals": 18,
  "outAmount": "1603772673769497210334",
  "slippage": 1,
  "minReceived': "1587734947031802238231",
  "bestRoute": [
      {"percent": 14, "swaps": [[Array], [Array]]},
      {"percent": 32, "swaps": [[Array], [Array]]},
      {"percent": 54, "swaps": [[Array], [Array]]},
  ],
  "contractAddress": "0xf9d5DCFB8490F67F1f7CFd148846D666d4ff6F25",
  "contractMethod": "hyperswap",
  "blockNumber": 100000000,
}

Responses

  • 200 Successful request.
  • 400 Quote is outdated.
  • 5xx Service unavailable.
{
  "success": true,
  "data" : {
    "to": "0xf9d5DCFB8490F67F1f7CFd148846D666d4ff6F25",
    "transaction": "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...",
    "value": "0"
 
  },
  "timestamp": "2000-01-01T00:00:00.000Z"
}

Response Fields

  • success: Boolean indicating if the request was successful.
  • to: String related to the router contract for the according chainId.
  • transaction: Return a byte-encoded transaction represented as a hexadecimal string.
  • value: String related to the value of the native chain token that should be sent.
  • timestamp: UTC timestamp of when the build was generated.

Try it yourself

To ping the API using curl, you can use the following command:

curl -X POST https://api.hypersonic.exchange/v1/build \
-H "Content-Type: application/json" \
-d '{
    <your-generated-quote-here>
}'

This will send a POST request to the infos endpoint and return the response.