> For the complete documentation index, see [llms.txt](https://hinkal-team.gitbook.io/hinkal/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hinkal-team.gitbook.io/hinkal/hinkal-api/api-reference/get-fee.md).

# Get Fee

## Get the fee amount for an operation

> 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\
> &#x20; exact nullifier count (used to estimate ATA creation costs).\
> \- \`mintFrom\` — for Solana swap fee estimation, pass the input token address so the\
> &#x20; server can estimate the OKX Associated Token Account cost.<br>

```json
{"openapi":"3.0.3","info":{"title":"Hinkal API","version":"1.0.0"},"tags":[{"name":"Get Fee"}],"servers":[{"url":"https://api.hinkal.io","description":"Production"}],"paths":{"/get-fee":{"get":{"operationId":"getFee","summary":"Get the fee amount for an operation","description":"Returns the relay fee amount for the given operation. Withdraw, transfer, and swap all\ncompute this fee automatically, so calling this endpoint first is optional — use it to\nshow the fee to a user before they confirm, or to lock in an exact `feeAmount` by passing\nit into the transaction request.\n\nRead-only — requires an active session. Pass `sessionId` and `nonce` as query parameters\nand include `x-hinkal-request-signature: secp256k1_sign(SHA256(\"GET /get-fee\\n\" + queryString))`\nin the headers.\n\n**Solana-specific parameters:**\n- `amounts[]` — provide the transaction amounts so the server can calculate the\n  exact nullifier count (used to estimate ATA creation costs).\n- `mintFrom` — for Solana swap fee estimation, pass the input token address so the\n  server can estimate the OKX Associated Token Account cost.\n","tags":["Get Fee"],"parameters":[{"$ref":"#/components/parameters/XHinkalRequestSignature"},{"name":"sessionId","in":"query","required":true,"description":"Session identifier UUID from POST /create-session","schema":{"type":"string","format":"uuid"}},{"name":"nonce","in":"query","required":true,"description":"Per-request UUID. Echoed back in the response.","schema":{"type":"string","format":"uuid"}},{"name":"chainId","in":"query","required":true,"description":"Chain ID (e.g. 10 for Optimism, 501 for Solana mainnet)","schema":{"type":"string"}},{"name":"feeToken","in":"query","required":true,"description":"Token address used to pay the fee","schema":{"type":"string"}},{"name":"tokenAddresses","in":"query","required":true,"description":"Token addresses involved in the operation","schema":{"type":"array","items":{"type":"string"}},"style":"form","explode":true},{"name":"externalActionId","in":"query","required":true,"description":"External action id string (e.g. \"Transact\", \"Okx\", \"Lifi\")","schema":{"type":"string"}},{"name":"amounts","in":"query","required":false,"description":"(Solana only) Transaction amounts used to calculate nullifier count for accurate\nfee estimation. Provide the amounts that will be used in the subsequent transaction.\n","schema":{"type":"array","items":{"type":"string"}},"style":"form","explode":true},{"name":"mintFrom","in":"query","required":false,"description":"(Solana swap only) Input token mint address for OKX ATA cost estimation.","schema":{"type":"string"}},{"name":"ref","in":"query","required":false,"description":"Referral code, checked the same way as by the route it quotes. With `Transact`, a ref that\ncarries a custom Hinkal fee returns that rate in `hinkalVariableRateBps`. The same rate applies\non `/withdraw`, `/transfer`, `/private-send` and `/private-send-bridge`. Custom fees don't apply\nto swaps, so with `Okx` or `Lifi` only whitelisted referral codes are accepted, as in\n`POST /swap`. Any other ref is rejected with 400.\n","schema":{"type":"string"}}],"responses":{"200":{"description":"Fee amount","headers":{},"content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[true]},"feeAmount":{"type":"string","description":"Flat fee covering network and relaying costs, in the fee token's smallest unit."},"hinkalVariableRateBps":{"type":"integer","minimum":0,"maximum":100,"description":"Hinkal fee in bps. The default is 10. For `Transact`, a custom rate from `ref` takes\nprecedence over one stored for the Hinkal Partner API key in `x-api-key`. The total\nvariable fee charged is `hinkalVariableRateBps` + `partnerFeeBps` (0 when absent).\n"},"partnerFeeBps":{"type":"integer","minimum":0,"maximum":100,"description":"Hinkal Partner fee in bps added on top of the Hinkal fee. Present only when the\nrequest carries a valid Hinkal Partner API key in `x-api-key`.\n"},"breakdown":{"$ref":"#/components/schemas/FeeBreakdown"},"nonce":{"type":"string","description":"Echoed per-request `nonce` from the request."}},"required":["success","feeAmount","hinkalVariableRateBps","nonce"]}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"500":{"$ref":"#/components/responses/ServerError"}}}}},"components":{"parameters":{"XHinkalRequestSignature":{"name":"x-hinkal-request-signature","in":"header","required":true,"schema":{"type":"string"},"description":"Hex-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](/enclave-api/authentication) for the full signing scheme."}},"schemas":{"FeeBreakdown":{"description":"How `feeAmount` was derived, in the chain's own fee terms. All currency amounts are integer\nstrings in the native coin's smallest unit: wei (EVM, 18 decimals), lamports (Solana, 9),\nsun (Tron, 6). `networkFee` is the sum of the chain's components.\n\n`feeAmount` = `networkFee` / 10^nativeDecimals × `priceRatio` × 10^feeTokenDecimals, rounded\ndown, where `priceRatio` = `nativeTokenPriceUSD` / `feeTokenPriceUSD`. Recomputing it can differ\nfrom `feeAmount` by 1 smallest unit due to floating-point rounding.\n","oneOf":[{"$ref":"#/components/schemas/FeeBreakdownEvm"},{"$ref":"#/components/schemas/FeeBreakdownSolana"},{"$ref":"#/components/schemas/FeeBreakdownTron"}],"discriminator":{"propertyName":"chainFamily","mapping":{"evm":"#/components/schemas/FeeBreakdownEvm","solana":"#/components/schemas/FeeBreakdownSolana","tron":"#/components/schemas/FeeBreakdownTron"}}},"FeeBreakdownEvm":{"description":"`networkFee` = `gas` × `gasPrice` + `l1Fee`","allOf":[{"$ref":"#/components/schemas/FeeBreakdownPrices"},{"type":"object","properties":{"chainFamily":{"type":"string","enum":["evm"]},"gas":{"type":"integer","description":"Estimated gas units."},"gasPrice":{"type":"string","description":"Gas price in wei per gas unit."},"l1Fee":{"type":"string","description":"L1 data fee in wei on rollups (Optimism, Base, Arbitrum). \"0\" on other chains."}},"required":["chainFamily","gas","gasPrice","l1Fee"]}]},"FeeBreakdownPrices":{"type":"object","properties":{"networkFee":{"type":"string","description":"Total network fee in the native coin's smallest unit."},"nativeTokenPriceUSD":{"type":"number","description":"USD price of the chain's native coin used for the conversion."},"feeTokenPriceUSD":{"type":"number","description":"USD price of the fee token used for the conversion."},"priceRatio":{"type":"number","description":"Fee tokens per one native coin (`nativeTokenPriceUSD` / `feeTokenPriceUSD`), both in whole\nunits. Multiply a native-coin amount by it to get the fee-token amount; equals 1 when the fee\ntoken is the native coin.\n"}},"required":["networkFee","nativeTokenPriceUSD","feeTokenPriceUSD","priceRatio"]},"FeeBreakdownSolana":{"description":"`networkFee` = `baseFee` + `prioritizationFee` + `rent` + `buffer`","allOf":[{"$ref":"#/components/schemas/FeeBreakdownPrices"},{"type":"object","properties":{"chainFamily":{"type":"string","enum":["solana"]},"baseFee":{"type":"string","description":"5000 lamports per signature, summed over the operation's transactions."},"computeUnitLimit":{"type":"integer","description":"Compute unit limit, summed over the operation's transactions."},"computeUnitPrice":{"type":"string","description":"Priority fee in micro-lamports per compute unit."},"prioritizationFee":{"type":"string","description":"`computeUnitLimit` × `computeUnitPrice` / 1,000,000, in lamports, rounded up."},"rent":{"type":"string","description":"Rent for accounts the operation creates or grows (nullifiers, token accounts, Merkle root\nbucket), in lamports.\n"},"buffer":{"type":"string","description":"Fixed margin for priority fee spikes, in lamports."}},"required":["chainFamily","baseFee","computeUnitLimit","computeUnitPrice","prioritizationFee","rent","buffer"]}]},"FeeBreakdownTron":{"description":"`networkFee` = `energy` × `energyPrice` + `bandwidth` × `bandwidthPrice`","allOf":[{"$ref":"#/components/schemas/FeeBreakdownPrices"},{"type":"object","properties":{"chainFamily":{"type":"string","enum":["tron"]},"energy":{"type":"integer","description":"Estimated energy, including the dynamic energy penalty."},"energyPrice":{"type":"string","description":"Energy price in sun per energy unit."},"bandwidth":{"type":"integer","description":"Estimated bandwidth in bytes."},"bandwidthPrice":{"type":"string","description":"Bandwidth price in sun per byte."}},"required":["chainFamily","energy","energyPrice","bandwidth","bandwidthPrice"]}]},"FailedResponse":{"type":"object","properties":{"success":{"type":"boolean","enum":[false]},"error":{"type":"string"}},"required":["success","error"]}},"responses":{"BadRequest":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/FailedResponse"}}}},"Unauthorized":{"description":"Invalid signature or reused nonce","content":{"application/json":{"schema":{"$ref":"#/components/schemas/FailedResponse"}}}},"ServerError":{"description":"Server error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/FailedResponse"}}}}}}}
```
