Hinkal API

Get Fee

Get the fee amount for an operation

GET/get-fee
https://api.hinkal.io/get-fee

Returns the relay fee amount for the given operation. Withdraw, transfer, and swap all compute this fee automatically, so calling this endpoint first is optional — use it to show the fee to a user before they confirm, or to lock in an exact feeAmount by passing it into the transaction request.

Read-only — requires an active session. Pass sessionId and nonce as query parameters and include x-hinkal-request-signature: secp256k1_sign(SHA256("GET /get-fee\n" + queryString)) in the headers.

Solana-specific parameters:

  • amounts[] — provide the transaction amounts so the server can calculate the exact nullifier count (used to estimate ATA creation costs).
  • mintFrom — for Solana swap fee estimation, pass the input token address so the server can estimate the OKX Associated Token Account cost.

Query parameters

NameTypeDescription
sessionIdrequiredstring (uuid)Session identifier UUID from POST /create-session
noncerequiredstring (uuid)Per-request UUID. Echoed back in the response.
chainIdrequiredstringChain ID (e.g. 10 for Optimism, 501 for Solana mainnet)
feeTokenrequiredstringToken address used to pay the fee
tokenAddressesrequiredstring[]Token addresses involved in the operation
externalActionIdrequiredstringExternal action id string (e.g. "Transact", "Okx", "Lifi")
amountsstring[](Solana only) Transaction amounts used to calculate nullifier count for accurate fee estimation. Provide the amounts that will be used in the subsequent transaction.
mintFromstring(Solana swap only) Input token mint address for OKX ATA cost estimation.
refstringReferral code, checked the same way as by the route it quotes. With Transact, a ref that carries a custom Hinkal fee returns that rate in hinkalVariableRateBps. The same rate applies on /withdraw, /transfer, /private-send and /private-send-bridge. Custom fees don't apply to swaps, so with Okx or Lifi only whitelisted referral codes are accepted, as in POST /swap. Any other ref is rejected with 400.

Header parameters

NameTypeDescription
x-hinkal-request-signaturerequiredstringHex-encoded compact secp256k1 signature: secp256k1_sign(SHA256(binding + "\n" + payload)), where binding is "<METHOD> <routePath>" (this route's own method and path, e.g. "POST /deposit" or "GET /balance") and payload is JSON.stringify(body) for POST requests or the raw query string for GET requests. Binding the route into the signed digest stops a signature captured for one endpoint from being replayed against another. See Authentication for the full signing scheme.

Responses

200Fee amount
NameTypeDescription
successrequiredboolean
One of: true
feeAmountrequiredstringFlat fee covering network and relaying costs, in the fee token's smallest unit.
hinkalVariableRateBpsrequiredintegerHinkal fee in bps. The default is 10. For Transact, a custom rate from ref takes precedence over one stored for the Hinkal Partner API key in x-api-key. The total variable fee charged is hinkalVariableRateBps + partnerFeeBps (0 when absent).
partnerFeeBpsintegerHinkal Partner fee in bps added on top of the Hinkal fee. Present only when the request carries a valid Hinkal Partner API key in x-api-key.
breakdownone ofHow feeAmount was derived, in the chain's own fee terms. All currency amounts are integer strings in the native coin's smallest unit: wei (EVM, 18 decimals), lamports (Solana, 9), sun (Tron, 6). networkFee is the sum of the chain's components. feeAmount = networkFee / 10^nativeDecimals × priceRatio × 10^feeTokenDecimals, rounded down, where priceRatio = nativeTokenPriceUSD / feeTokenPriceUSD. Recomputing it can differ from feeAmount by 1 smallest unit due to floating-point rounding.
noncerequiredstringEchoed per-request nonce from the request.
400Validation error
NameTypeDescription
successrequiredboolean
One of: false
errorrequiredstring
401Invalid signature or reused nonce
NameTypeDescription
successrequiredboolean
One of: false
errorrequiredstring
500Server error
NameTypeDescription
successrequiredboolean
One of: false
errorrequiredstring