Hinkal API

Swap

Execute a private swap

POST/swap
https://api.hinkal.io/swap

Relays 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

NameTypeDescription
x-hinkal-request-signaturestringRequired 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

NameTypeDescription
sessionIdrequiredstring (uuid)
noncerequiredstring (uuid)
signaturestringEIP-712 or ed25519 signature (EIP-712 mode only)
chainIdrequiredinteger
tokenAddressesrequiredstring[][inputTokenAddress, outputTokenAddress]
amountsrequiredstring[][negativeInputAmount, positiveOutputAmount]
externalActionIdrequiredstringExternal action id string returned by GET /get-swap-data (e.g. "Lifi", "Okx")
swapDatarequiredstringSwap calldata returned by GET /get-swap-data
feeTokenstringFee token for EVM swaps (typically the input token). Not used on Solana — the server always uses tokenAddresses[1]; any value passed is ignored.
feeAmountstringOptional — omit it and the server computes the fee automatically. Pass it only to lock in a fee amount already quoted from GET /get-fee.
refstringReferral code for attribution (must be a whitelisted referral identifier)

Responses

200Relayed transaction hash
NameTypeDescription
successrequiredboolean
One of: true
txHashrequiredstring
noncerequiredstringEchoed per-request nonce from the request, added before signing.
400Validation error
NameTypeDescription
successrequiredboolean
One of: false
errorrequiredstring
401Invalid signature or reused nonce
NameTypeDescription
successrequiredboolean
One of: false
errorrequiredstring
409Request `nonce` already consumed. Each `nonce` is single-use; generate a fresh UUID for every request.
NameTypeDescription
successrequiredboolean
One of: false
errorrequiredstring
500Server error
NameTypeDescription
successrequiredboolean
One of: false
errorrequiredstring