Swap
Execute a private swap
/swapRelays a swap within the shielded balance, using swap calldata obtained from
GET /get-swap-data.
EVM: feeToken is the input token. feeAmount is optional (computed server-side
if omitted). Authorized by a normal mode session (secp256k1 request signature, bound to
"POST /swap") or an EIP-712 Swap typed-data signature.
Solana: feeToken is not used — the server always uses tokenAddresses[1] (the
output token) as the fee token; any value passed is ignored. The relay fee is computed
automatically; feeAmount is only needed to lock in an exact amount already returned by
GET /get-fee (with mintFrom = inputTokenAddress). Exactly two token addresses are
required: [inputToken, outputToken]. Authorized by a normal mode session (secp256k1 request signature,
bound to "POST /swap") or an EIP-712 mode session with a per-transaction ed25519
plain-text signature (primary type Swap).
tokenAddresses and amounts for a swap:
- Index 0: input token address, amount is negative (tokens leaving shielded balance)
- Index 1: output token address, amount is positive (tokens entering shielded balance)
Header parameters
| Name | Type | Description |
|---|---|---|
x-hinkal-request-signature | string | Required for normal mode sessions: hex-encoded compact secp256k1 signature secp256k1_sign(SHA256(binding + "\n" + JSON.stringify(body))), where binding is "POST <routePath>" for this endpoint. Omit for EIP-712 mode sessions — include signature in the request body instead. See Authentication for the full signing scheme. |
Request body application/jsonrequired
| Name | Type | Description |
|---|---|---|
sessionIdrequired | string (uuid) | |
noncerequired | string (uuid) | |
signature | string | EIP-712 or ed25519 signature (EIP-712 mode only) |
chainIdrequired | integer | |
tokenAddressesrequired | string[] | [inputTokenAddress, outputTokenAddress] |
amountsrequired | string[] | [negativeInputAmount, positiveOutputAmount] |
externalActionIdrequired | string | External action id string returned by GET /get-swap-data (e.g. "Lifi", "Okx") |
swapDatarequired | string | Swap calldata returned by GET /get-swap-data |
feeToken | string | Fee token for EVM swaps (typically the input token). Not used on Solana — the server always uses tokenAddresses[1]; any value passed is ignored. |
feeAmount | string | Optional — omit it and the server computes the fee automatically. Pass it only to lock in a fee amount already quoted from GET /get-fee. |
ref | string | Referral code for attribution (must be a whitelisted referral identifier) |
Responses
200Relayed transaction hash
| Name | Type | Description |
|---|---|---|
successrequired | boolean | |
txHashrequired | string | |
noncerequired | string | Echoed per-request nonce from the request, added before signing. |
400Validation error
| Name | Type | Description |
|---|---|---|
successrequired | boolean | |
errorrequired | string |
401Invalid signature or reused nonce
| Name | Type | Description |
|---|---|---|
successrequired | boolean | |
errorrequired | string |
409Request `nonce` already consumed. Each `nonce` is single-use; generate a fresh UUID for every request.
| Name | Type | Description |
|---|---|---|
successrequired | boolean | |
errorrequired | string |
500Server error
| Name | Type | Description |
|---|---|---|
successrequired | boolean | |
errorrequired | string |