Hinkal API

Private Send Bridge

POST /private-send-bridge is a Private Send where recipients are paid in another token, on another chain, or both. The caller deposits public tokens; after the deposit confirms, the enclave privately pays each recipient through a bridge or swap route. The on-chain link between sender and recipients is never visible.

The source chain decides the route:

Source chainRouteHow each recipient is paid
EVMLI.FIThe enclave runs the LI.FI bridge or swap from a temporary wallet
Solana, TRONNEAR IntentsThe enclave privately sends to a NEAR Intents deposit address; NEAR delivers the destination token
EndpointPurpose
GET /get-private-send-bridge-quoteQuote the route and the expected amount per recipient
POST /private-send-bridgePrepare the order from the quote; returns the deposit transaction
GET /private-send-bridge/{orderId}Track the order
GET /stuck-bridge-balanceList funds left by a failed bridge or swap
POST /recover-stuck-bridge-balanceRecover those funds to a public address

Authentication, broadcasting the deposit and polling work as in Private Send. The code below uses its helpers (createSession, signPayload, buildActionBinding, pollOrder) and post from Examples.

Complete integration

async function privateSendBridge(
  wallet,
  provider,
  chainId,
  tokenAddress,
  destinationChainId,
  destinationTokenAddress,
  recipients, // [{ address, amount }] — addresses on the destination chain, amounts in source token units
) {
  // 1. Authenticate — normal mode session
  const session = await createSession(wallet);

  // 2. Quote
  const params = new URLSearchParams({
    sessionId: session.sessionId,
    nonce: randomUUID(),
    chainId: String(chainId),
    destinationChainId: String(destinationChainId),
    inputTokenAddress: tokenAddress,
    outputTokenAddress: destinationTokenAddress,
  });
  recipients.forEach(({ address, amount }) => {
    params.append('recipientAddresses', address);
    params.append('amounts', amount);
  });
  const queryString = params.toString();
  const quoteRes = await fetch(`${BASE_URL}/get-private-send-bridge-quote?${queryString}`, {
    headers: {
      'x-hinkal-request-signature': signPayload(
        session.privateKey,
        `${buildActionBinding('GET', '/get-private-send-bridge-quote')}\n${queryString}`,
      ),
    },
  });
  const { quote, expectedAmounts } = await quoteRes.json(); // show expectedAmounts to the user

  // 3. Prepare the order — destination, recipients and amounts must match the quote
  const body = {
    sessionId: session.sessionId,
    nonce: randomUUID(),
    chainId,
    tokenAddress,
    destinationChainId,
    destinationTokenAddress,
    recipients,
    quote,
    timestamp: Date.now(),
  };
  const order = await post('/private-send-bridge', body, {
    'x-hinkal-request-signature': signPayload(
      session.privateKey,
      `${buildActionBinding('POST', '/private-send-bridge')}\n${JSON.stringify(body)}`,
    ),
  });

  // 4. Approve if required, then sign and broadcast the deposit (EVM)
  if (order.approvalAddress) {
    const token = new ethers.Contract(tokenAddress, ERC20_ABI, wallet);
    await (await token.approve(order.approvalAddress, BigInt(order.amountIn))).wait();
  }
  const tx = ethers.Transaction.from('0x' + Buffer.from(order.serializedTx, 'base64').toString('hex'));
  tx.nonce = await provider.getTransactionCount(wallet.address, 'pending');
  await provider.send('eth_sendRawTransaction', [await wallet.signTransaction(tx)]);

  // 5. Poll — pollOrder from Private Send with the /private-send-bridge URL and binding (see Step 4)
  return pollOrder(session, order.orderId);
}

Step 1 - Get a quote

GET /get-private-send-bridge-quote is a read endpoint. Sign the query string with the "GET /get-private-send-bridge-quote" binding (see Authentication).

Query parameterRequiredDescription
sessionId, nonceYesSession and per-request UUID, as for every read endpoint
chainIdYesSource chain
destinationChainIdYesChain the recipients are paid on. Can equal chainId for a same-chain swap
inputTokenAddressYesSource token
outputTokenAddressYesToken the recipients receive. Must differ from inputTokenAddress when the chains are the same
recipientAddressesYesRecipient address on the destination chain. Repeat the key once per recipient
amountsYesAmount per recipient as a positive integer in the source token's smallest unit. Repeat once per recipient, in the same order
slippagePercentageNoMaximum slippage, 0 to 10. If omitted: 1% for NEAR Intents; for LI.FI 0.7%, or 1.5% for a recipient amount under $10
txCompletionTimeNoUnix timestamp in seconds for a scheduled send. It is stored in the quote

Response:

{
  "success": true,
  "quote": "<quote>",
  "expectedAmounts": ["9985000"],
  "nonce": "ff3ce3a6-0808-4c94-a735-76dd415e4664"
}
  • quote - the quote as a JSON string. Pass it to POST /private-send-bridge unchanged. It includes the route calldata, so it can be tens of KB.
  • expectedAmounts - expected amount per recipient in the destination token's smallest unit, in request order.

Step 2 - Prepare the order

Body fieldRequiredDescription
sessionId, nonceYesSession and per-request UUID
chainIdYesSource chain, as in the quote
tokenAddressYesSource token, as in the quote
destinationChainIdYesAs in the quote
destinationTokenAddressYesAs in the quote
recipientsYes[{ address, amount }] with the same recipients and amounts as the quote
quoteYesThe quote string from Step 1
refNoReferral code (must be a whitelisted referral identifier)

Normal mode signs the body with the "POST /private-send-bridge" binding. EIP-712 mode signs the PrivateSendBridge typed data (EVM/TRON) or plain-text message (Solana); see Authentication.

The response has the same fields as POST /private-send: orderId, approvalAddress, serializedTx, amountIn, amountOut, fee, txData, nonce. amountIn and fee are in the source token. amountOut is the total of the quote's expectedAmounts in the destination token, so amountIn - amountOut is not the fee. Recipients can receive less than amountOut by up to the slippage.

A quote:

  • expires 10 minutes after it is issued,
  • is bound to the session's address, chainId and tokenAddress,
  • fixes destinationChainId, destinationTokenAddress, recipients and amounts - the body must match them,
  • carries txCompletionTime - the body has no txCompletionTime field.

Step 3 - Approve and broadcast the deposit

Same as Private Send, Step 3: approve amountIn to approvalAddress when it is set, then sign and broadcast serializedTx.

LI.FI can charge a fee in the native token:

  • ERC20 source: the deposit transaction's value includes that fee, so the wallet needs that much native token on top of gas. amountIn and fee do not include it.
  • Native-token source: amountIn and fee include it.

Step 4 - Poll the order status

Use pollOrder from Private Send, Step 4 with /private-send-bridge/${orderId} as the URL and buildActionBinding("GET", "/private-send-bridge/:orderId") as the binding. Order statuses and per-recipient statuses are the same as in Private Send.

Each scheduledTransactions[].txHash is the source-chain transaction that starts the recipient's payout: the LI.FI call, or the transfer to the NEAR Intents deposit address.

GET /private-send/{orderId} returns 404 for bridge orders, and GET /private-send-bridge/{orderId} returns 404 for private-send orders.

Recover funds from a failed bridge

When a bridge or swap fails after the payout transaction and is refunded, the refund does not go to the recipient. It lands here:

RouteWhere the refund landsWhen it is listed
LI.FIA temporary wallet on the source chainWhen the refund arrives. Temporary wallets created in the last 3 minutes are skipped, so funds still in transit are not listed
NEAR IntentsThe sender's NEAR Intents accountAfter NEAR refunds the deposit. An unfilled deposit is refunded after the quote deadline: 20 minutes after the scheduled send time, or after the quote for an immediate send

If the deposit confirmed but the withdraw transaction never ran or reverted, the funds are stuck UTXOs instead: use GET /stuck-utxo-balance and POST /withdraw-stuck-utxos.

Check stuck balances

GET /stuck-bridge-balance is a read endpoint. Sign the query string with the "GET /stuck-bridge-balance" binding.

Query parameterRequiredDescription
sessionId, nonceYesSession and per-request UUID, as for every read endpoint
chainIdYesChain to check
const params = new URLSearchParams({ sessionId: session.sessionId, nonce: randomUUID(), chainId: String(chainId) });
const queryString = params.toString();
const res = await fetch(`${BASE_URL}/stuck-bridge-balance?${queryString}`, {
  headers: {
    'x-hinkal-request-signature': signPayload(
      session.privateKey,
      `${buildActionBinding('GET', '/stuck-bridge-balance')}\n${queryString}`,
    ),
  },
});
const { balances } = await res.json();

Response:

{
  "success": true,
  "balances": [{ "chainId": 8453, "tokenAddress": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", "balance": "9985000" }],
  "nonce": "5f0e8c1a-1d2b-4c3e-9f4a-7b6c5d4e3f21"
}
  • balances - one entry per token: the total stuck amount on chainId in the token's smallest unit, before recovery fees. NEAR Intents refunds are included for Solana and TRON.
  • Temporary-wallet tokens are listed only when they have a USD value and are not flagged as spam or volatile.

Recover

POST /recover-stuck-bridge-balance recovers every stuck balance of tokenAddress on chainId, one after another, and sends it to recipientAddress. The recovery fee is deducted from each recovered amount.

Body fieldRequiredDescription
sessionId, nonceYesSession and per-request UUID
chainIdYesChain the funds are stuck on
tokenAddressYesToken to recover, from GET /stuck-bridge-balance
recipientAddressYesPublic address on chainId that receives the funds

Normal mode signs the body with the "POST /recover-stuck-bridge-balance" binding. EIP-712 mode signs the RecoverStuckBridgeBalance typed data (EVM/TRON) or plain-text message (Solana); see Authentication.

const body = {
  sessionId: session.sessionId,
  nonce: randomUUID(),
  chainId,
  tokenAddress: balances[0].tokenAddress,
  recipientAddress: wallet.address,
  timestamp: Date.now(),
};
const result = await post('/recover-stuck-bridge-balance', body, {
  'x-hinkal-request-signature': signPayload(
    session.privateKey,
    `${buildActionBinding('POST', '/recover-stuck-bridge-balance')}\n${JSON.stringify(body)}`,
  ),
});

Response:

{
  "success": true,
  "recoveredCount": 1,
  "recoveredAmount": "9985000",
  "failedCount": 0,
  "errors": [],
  "nonce": "8a7b6c5d-4e3f-4a1b-9c2d-1e0f9a8b7c6d"
}
  • recoveredCount - number of stuck balances recovered.
  • recoveredAmount - total of the recovered balances in the token's smallest unit, before recovery fees.
  • failedCount, errors - balances that could not be recovered, with their error messages. Call the endpoint again to retry them.

If none of the balances can be recovered, the endpoint returns 500 with the first message in error and all messages in errors.