Hinkal SDK

React Native SDK

Hinkal React Native SDK

Hinkal is a privacy middleware and smart-contract SDK for public blockchains that enables private transactions and settlement flows without changing wallets, custody, or chains.

@hinkal/react-native is a prebundled build of the Hinkal SDK for React Native and Expo. It includes the polyfills, shims, and worker runtime required on mobile - no custom Metro configuration is needed.

The SDK allows mobile wallets, dApps, and payment apps to integrate protocol-level privacy on Ethereum, Solana, Tron, Polygon, Base, Arbitrum, and Optimism.

With Hinkal SDK, developers can:

• Enable private sends between public wallets

• Perform private payments

• Route transactions through Hinkal’s privacy contracts without exposing sender, recipient, or amounts

• Maintain non-custodial control with optional compliance visibility via viewing keys

Compatibility

EnvironmentSupportedNotes
React Native✅v0.74+
Expo✅dev client or bare

Installation

npm install @hinkal/react-native

Or, yarn:

yarn add @hinkal/react-native

Usage

HinkalProvider

Wrap your app with HinkalProvider before using any SDK function. It runs the React Native bootstrap and mounts the hidden WebView worker host.

import { WagmiProvider } from 'wagmi';
import { HinkalProvider } from '@hinkal/react-native';
import { wagmiConfig } from './wagmiConfig';

export default function App() {
  return (
    <WagmiProvider config={wagmiConfig}>
      <HinkalProvider>
        <YourApp />
      </HinkalProvider>
    </WagmiProvider>
  );
}

Initialization

After the wallet is connected, initialize a Hinkal instance with your preferred provider helper.

Initializing the SDK creates a Hinkal object that encapsulates:

  • The user's private balances
  • Actions the user can perform, such as shielding (depositing), transfers, and swapping
  • Cryptographic keys for privacy-preserving operations

Each provider exposes three prepare helpers:

  • prepare*Hinkal - signs the Hinkal login message and initializes user keys (deterministic signers)
  • prepare*HinkalWithEnclaveSignIn - signs in through the secure enclave and stabilizes identity for non-deterministic signers (smart contract wallets, some hardware wallets)
  • prepare*HinkalFromSignature - initializes user keys from a previously stored signature

wagmi:

import { prepareWagmiHinkal } from '@hinkal/react-native';
// connector: wagmi.Connector
// wagmiConfig: wagmi.Config
const hinkal = await prepareWagmiHinkal(connector, wagmiConfig, hinkalConfig);

ethers.js:

import { prepareEthersHinkal } from '@hinkal/react-native';
const hinkal = await prepareEthersHinkal(signer, hinkalConfig);

Solana:

import { prepareSolanaHinkal } from '@hinkal/react-native';
// connector: SolanaWallet
// ethereumAddress: optional linked EVM address
const hinkal = await prepareSolanaHinkal(connector, ethereumAddress, hinkalConfig);

Tron:

import { prepareTronHinkal } from '@hinkal/react-native';
const hinkal = await prepareTronHinkal(connector, hinkalConfig);

The same WithEnclaveSignIn and FromSignature variants are available for each provider (for example, prepareWagmiHinkalWithEnclaveSignIn, prepareSolanaHinkalFromSignature).

The hinkalConfig is defined as follows:

type HinkalConfig = {
  /** Disables caching in browser localStorage, storing data only in memory. Front-end only. Defaults to false. */
  disableCaching?: boolean;

  /** If true, allows caching in a file locally. Node.js only. Defaults to false. */
  useFileCache?: boolean;

  /**
   * Path to the cache file used for storing temporary data. Node.js only.
   * Defaults to hinkalCache.json in the current working directory.
   */
  cacheFilePath?: string;

  /**
   * Indicator controlling whether the proof should be constructed remotely in secure enclave. Defaults to true.
   */
  generateProofRemotely?: boolean;

  /** Disables automatic merkle tree updates. Defaults to false. */
  disableMerkleTreeUpdates?: boolean;

  /** Override which Tron chain this Hinkal instance targets. */
  tronChainOverride?: number;
};

Identity persistence

When a user connects their wallet, they sign a fixed login message to authenticate with Hinkal. That signature defines their Hinkal identity. Their private balances, transaction ability, and all private operations depend on it.

Most wallets return the same signature every time for the same message. Some do not. Smart contract wallets, certain hardware wallets, and other non-deterministic signers may produce a different signature on each login, even for the same address and message.

When that happens, a returning user appears as a new account. Funds deposited in an earlier session remain tied to the original identity and are not accessible from the new one.

Recommended approach: use prepare*HinkalWithEnclaveSignIn instead of prepare*Hinkal. It signs the login message, stores the first signature server-side through the secure enclave, and always initializes with the original identity on later sessions. Solana Ledger wallets are handled automatically.

Manual approach: if you manage identity yourself, call storeAndGetInitialSignature and then either initUserKeysWithSignature or prepare*HinkalFromSignature:

function storeAndGetInitialSignature(
  authSignature: string,
  isSolanaLedger?: boolean,
  txMessageForSolanaLedger?: string,
): Promise<string>;

Parameters:

  • authSignature - signature from the current login session
  • isSolanaLedger - set to true for a Solana Ledger wallet. Defaults to false
  • txMessageForSolanaLedger - base64-encoded transaction message used for Solana Ledger authentication. Required when isSolanaLedger is true

Typical flow with a stored signature:

const initialSignature = await hinkal.storeAndGetInitialSignature(authSignature);
hinkal.initUserKeysWithSignature(initialSignature);

Call this once per session, after wallet connection and before fetching balances or submitting transactions.

You do not need enclave sign-in if your wallet produces deterministic signatures for the same login message on every session - in that case, prepare*Hinkal is sufficient. It is also not needed if you persist the signature yourself via prepare*HinkalFromSignature, or if you use seed-phrase-based login through initUserKeysFromSeedPhrases.

Security

The stored signature is protected at every stage. Before leaving the client, the signature is encrypted with hybrid encryption. The payload is encrypted with a symmetric key, and that key is encrypted with the enclave's public key.

Inside the secure enclave, Google Cloud KMS decrypts the symmetric key. Only then is the signature decrypted. The plaintext signature never leaves the enclave unprotected.

At rest, only the encrypted signature and encrypted key are stored in the database. A caller cannot retrieve a stored signature by wallet address alone. Each request must include any valid signature that proves wallet ownership.

Requests that fail this check are rejected. The first signature stored for a given address is never replaced. Later logins only use a fresh signature to authenticate retrieval of the original.

Private Balance

Private balances are encrypted token holdings stored within the Hinkal protocol. Unlike regular blockchain balances that are publicly visible, private balances are hidden from external observers.

After initializing the Hinkal object and calling initUserKeys (or a prepare helper), fetch balances for a specific chain:

function getTotalBalance(
  chainId: number,
  resetCacheBefore?: boolean,
  updateTokensListBefore?: boolean,
): Promise<TokenBalance[]>;

TokenBalance contains chainId, erc20Address, balance, and an optional timestamp.

For reactive UI updates, subscribe to balance changes with USD values:

// Current state keyed by chainId
hinkal.privateBalancesWithUSD;

// Subscribe to updates; returns unsubscribe function
const unsubscribe = hinkal.onPrivateBalancesWithUSDChange((state) => {
  // state: Record<chainId, TokenBalanceWithUsd[]>
});

// Trigger a refresh after a transaction
hinkal.refreshBalance({ chainIdToUpdate: chainId, updateType: PrivateBalanceUpdateType.Fresh });

Shielding: depositing funds to the private balance

Shielding moves tokens from a public blockchain address into a private, encrypted balance. Once shielded, tokens are no longer visible on-chain to external observers.

function deposit(
  chainId: number,
  erc20Addresses: string[],
  amountChanges: bigint[],
  preEstimateGas?: boolean,
  returnTxData?: boolean,
): Promise<
  | ethers.TransactionResponse
  | ethers.TransactionRequest
  | string
  | TronWebTypes.Transaction<TronWebTypes.TriggerSmartContract>
>;

where:

  • chainId - target chain
  • erc20Addresses - token contract addresses to deposit
  • amountChanges - corresponding deposit amounts in the token's smallest unit
  • preEstimateGas - if true (default), gas is estimated before executing the deposit
  • returnTxData - if true, returns unsigned transaction data without executing. Defaults to false

On Solana, use depositSolana(chainId, erc20Address, amount).

To shield funds for another user's private address, use depositForOther (EVM/Tron) or depositSolanaForOther (Solana) with their recipientInfo string from getRecipientInfo().

Receiving funds to a public deposit address

A receive address is a normal public address that shields whatever is sent to it. You hand it out, the sender makes a plain transfer, and a relayer settles the balance into your private balance for a fee (a flat fee covering the settlement gas, quoted when the balance is settled, plus 0.25%).

The address is derived from your private key, so deriving one is free: a CREATE2 address on EVM and Tron, where nothing is deployed until it is settled, and a program-derived address on Solana, where nothing is deployed at all. The relayer must supply the exact recipient the address was derived from, so it can shield your funds or do nothing - it can never redirect them.

One address takes every supported token on every chain of its network: the factory address and init code are identical on all EVM chains, so an EVM address is the same everywhere. Tron and Solana are separate networks, each with an address of its own.

Available on Solana, and on any EVM or Tron chain with a receive vault factory deployed. Check first:

function isReceiveVaultSupported(chainId: number): boolean;

A vault address belongs to a network, not one chain. To hand out an address:

function createReceiveAddress(network: ReceiveVaultNetwork, forceFresh?: boolean): Promise<ReceiveVaultRecord>;

where:

  • network - ReceiveVaultNetwork.Evm, ReceiveVaultNetwork.Tron or ReceiveVaultNetwork.Solana, the network the address is for
  • forceFresh - if true, claims a new address instead of returning the unexpired one already handed out for that network. Defaults to false

The returned ReceiveVaultRecord holds vaultAddress (the address to hand out, in the chain's native format), expiry (unix seconds, 14 days after creation), plus the terms it was derived from (index, network, version).

Calling this again returns the same address until it expires, then the next call issues a new one. Funds sent to an expired address are not shielded automatically, but the owner can recover them. To list the addresses handed out so far, along with balances the relayer declined to shield:

function getReceiveVaultAccount(): Promise<{
  entries: ReceiveVaultRecord[];
  blockedFunds: { record: ReceiveVaultRecord; erc20Address: string; chainId: number; amount: bigint; reason: ReceiveVaultBlockReason }[];
}>;

Records are restored from the private key itself, so this works on a fresh device. A fund is blocked when the relayer will not settle it - the sender was flagged, the address expired, the token cannot be shielded, or the payment could not be attributed (ReceiveVaultBlockReason).

Blocked funds are never lost: only the address's owner can move them, paying gas from their own wallet.

function recoverReceiveVault(
  record: ReceiveVaultRecord,
  erc20Address: string,
  chainId: number,
  recipientAddress: string,
  returnTxData?: boolean,
): Promise<string | ethers.TransactionRequest | TronWebTypes.Transaction<TronWebTypes.TriggerSmartContract>>;

where:

  • record - the record the blocked fund came with
  • erc20Address - token to sweep out of the address
  • chainId - chain the blocked balance sits on
  • recipientAddress - public address to send it to
  • returnTxData - if true, returns unsigned transaction data without executing. Defaults to false

Resolves to the transaction hash, and the funds land publicly at recipientAddress. With returnTxData, EVM and Tron return an unsigned transaction object; Solana returns a base64 legacy transaction with the fee payer and a recent blockhash already set, ready to sign and send.

Private Send to Public Address: withdrawing funds from the private balance

Private Send to Public Address sends tokens from a private balance to any public blockchain address without exposing the sender.

function withdraw(
  chainId: number,
  erc20Addresses: string[],
  deltaAmounts: bigint[],
  recipientAddress: string,
  isRelayerOff: boolean,
  feeToken?: string,
  feeStructureOverride?: FeeStructure,
): Promise<ethers.TransactionResponse | string>;

where:

  • recipientAddress - public address that receives the withdrawn funds
  • isRelayerOff - when false, a relayer handles gas fees; when true, the user pays gas directly
  • feeToken - optional token address used to pay protocol fees
  • feeStructureOverride - optional custom fee structure

Private Send to Private Address: transferring funds from private balance

Private Send to Private Address enables fully confidential transfers between shielded balances.

function transfer(
  chainId: number,
  erc20Addresses: string[],
  amountChanges: bigint[],
  recipientAddress: string,
  feeToken?: string,
  feeStructureOverride?: FeeStructure,
): Promise<string>;

where:

  • recipientAddress - recipient's private address string from getRecipientInfo(). Pass it as-is; do not reformat. It is a comma-separated string with five components:
    • stealthAddress - recipient's stealth address (hex, 0x prefix, 64–66 characters)
    • H0[0] - first coordinate of the H0 elliptic-curve point
    • H0[1] - second coordinate of the H0 elliptic-curve point
    • H1[1] - second coordinate of the H1 elliptic-curve point
    • encryptionKey - recipient's encryption public key (hex, 0x prefix, 66 characters)

Private Send from Public to Public addresses

Private Send from Public to Public transfers tokens between two public addresses through Hinkal's privacy infrastructure. Tokens are shielded from the sender, then withdrawn to recipient public addresses on a relayer schedule.

function depositAndWithdraw(
  chainId: number,
  erc20Address: string,
  recipientAmounts: bigint[],
  recipientAddresses: string[],
  txCompletionTime?: number,
  feeStructureOverride?: FeeStructure,
  preEstimateGas?: boolean,
): Promise<DepositAndSendExtendedResult>;

where:

  • erc20Address - token contract address (single-token transfers only)
  • recipientAmounts - amounts to send to each recipient in the token's smallest unit
  • recipientAddresses - public addresses that receive the funds
  • txCompletionTime - optional Unix timestamp in seconds by which all scheduled withdrawals must complete
  • feeStructureOverride - optional custom fee structure
  • preEstimateGas - if true (default), gas is estimated before executing the deposit

The function returns:

type DepositAndSendExtendedResult = {
  depositTxHash: string;
  scheduleId: string;
};

Private Send with bridge or swap (quote-based)

Use getDepositAndBridgeQuote and depositAndBridgeWithQuote for a private send where recipients are paid in another token, on another chain, or both. The quote picks the route: NEAR Intents for Solana and Tron sources, LI.FI for EVM sources. Fetch the quote, show expectedAmounts to the user, then pass the same quote to execute the send.

function getDepositAndBridgeQuote(
  chainId: number,
  erc20Address: string,
  destinationChainId: number,
  destinationErc20Address: string,
  sendAmounts: bigint[],
  recipientAddresses: string[],
  slippagePercent?: number,
  txCompletionTime?: number,
): Promise<DepositAndBridgeQuote>;

where:

  • chainId, erc20Address - source chain and token, taken from the sender's public balance
  • destinationChainId, destinationErc20Address - chain and token the recipients receive. The chain can equal chainId for a same-chain swap
  • sendAmounts - amount to send to each recipient, in the source token's smallest unit
  • recipientAddresses - public addresses on the destination chain that receive the funds, in the same order as sendAmounts
  • slippagePercent - optional maximum slippage in percent. If omitted: 1% for NEAR Intents; for LI.FI 0.7%, or 1.5% for a recipient amount under $10
  • txCompletionTime - optional Unix timestamp in seconds for a scheduled send. Pass the same value to depositAndBridgeWithQuote

The function returns:

interface DepositAndBridgeQuote {
  sourceChainId: number;
  sourceTokenAddress: string;
  destinationChainId: number;
  destinationTokenAddress: string;
  expectedAmounts: bigint[];
  lifiRecipients?: PublicBridgeRecipient[];
  nearLegs?: NearBridgeLeg[];
}
  • expectedAmounts - expected amount each recipient receives, in the destination token's smallest unit, in the same order as recipientAddresses
  • lifiRecipients / nearLegs - route data used by depositAndBridgeWithQuote. Exactly one of them is set. Do not modify them

To execute the quote:

function depositAndBridgeWithQuote(
  chainId: number,
  erc20Address: string,
  quote: DepositAndBridgeQuote,
  txCompletionTime?: number,
  feeStructureOverride?: FeeStructure,
): Promise<DepositAndSendExtendedResult>;

where:

  • chainId, erc20Address - must match the chain and token the quote was issued for, otherwise the call throws
  • quote - the object returned by getDepositAndBridgeQuote
  • txCompletionTime - optional Unix timestamp in seconds, the same value used for the quote
  • feeStructureOverride - optional custom fee structure

The function returns DepositAndSendExtendedResult (depositTxHash and scheduleId), the same as depositAndWithdraw.

Example:

const quote = await hinkal.getDepositAndBridgeQuote(
  8453, // Base
  usdcOnBase,
  42161, // Arbitrum
  usdcOnArbitrum,
  [10_000_000n], // 10 USDC
  ['0xRecipientAddress'],
);
console.log(quote.expectedAmounts); // amounts the recipients receive on Arbitrum

const { depositTxHash, scheduleId } = await hinkal.depositAndBridgeWithQuote(8453, usdcOnBase, quote);

Execute the quote soon after fetching it: LI.FI calldata goes stale and NEAR Intents quotes have a deadline. Fetch a new quote if the user waits.

Checking scheduled send status

After depositAndWithdraw or depositAndBridge, fetch scheduled withdrawal status using the returned scheduleId:

function checkSendTransactionStatus(scheduleId: string): Promise<ScheduledTransactionByIdResponse>;

Possible values for ScheduledTransactionStatus:

  • pending - scheduled, waiting for execution time
  • processing - relayer is submitting the withdrawal on-chain
  • waiting_for_relayer - relayer is busy; withdrawal is queued
  • sent_on_chain - submitted on-chain; txHash is available
  • completed - confirmed on-chain
  • failed - withdrawal transaction failed

Recovering funds from a failed bridge or swap

When a bridge or swap fails after the funds left the private balance and is refunded, the refund does not reach the recipient. It lands on a temporary wallet (LI.FI routes) or in the user's NEAR Intents account (NEAR Intents routes, used for Solana and Tron sources). List these balances with:

function getStuckBridgeBalances(chainIds?: number[]): Promise<StuckBridgeBalance[]>;

where:

  • chainIds - optional chains to check. Defaults to every supported chain. NEAR Intents refunds are checked only when chainIds is omitted or includes Solana or Tron

The function returns StuckBridgeBalance entries: a TemporaryWalletBalance (LI.FI) or a NearIntentsRefundBalance (NEAR Intents, has assetId). Each entry has token, balance (in the token's smallest unit) and, when a price is available, usdValue.

  • Temporary wallets created in the last 3 minutes are skipped, so funds still in transit are not listed
  • Temporary-wallet tokens are listed only when they have a USD value and are not flagged as spam or volatile
  • A TemporaryWalletBalance contains the temporary wallet's private key. Do not log these entries or send them anywhere

To recover one entry:

function recoverStuckBridgeBalance(balance: StuckBridgeBalance, recipientAddress?: string): Promise<void>;

where:

  • balance - an entry returned by getStuckBridgeBalances, unchanged
  • recipientAddress - optional public address on the entry's chain that receives the funds. Defaults to the connected wallet's address, or its Solana public key for a NEAR Intents refund on Solana

The recovery fee is deducted from the recovered amount. If a temporary wallet's balance does not cover it, the call throws Insufficient funds to cover recovery fees. Temporary wallets created by bridgePrivateToPrivate are shielded instead: into your private balance by default, or into the private balance of recipientAddress.

Example:

const stuck = await hinkal.getStuckBridgeBalances([8453]); // Base
for (const balance of stuck) {
  await hinkal.recoverStuckBridgeBalance(balance);
}

If the deposit confirmed but the withdraw transaction never ran or reverted, the funds are stuck in the private balance instead: use getStuckShieldedBalances and withdrawStuckUtxos.

Swapping tokens from the private balance

function swap(
  chainId: number,
  erc20Addresses: string[],
  deltaAmounts: bigint[],
  externalActionId: ExternalActionId,
  swapData: string,
  feeToken?: string,
  feeStructureOverride?: FeeStructure,
): Promise<string>;

Getting swap quotes and calldata:

EVM chains - getEvmSwapPrices(chainId, inSwapAmount, inSwapTokenAddress, outSwapTokenAddress) returns a LI.FI quote ({ outSwapAmountValue, lifiDataValue }), or null when no route is found. LI.FI aggregates the underlying DEXs, so there is one quote per pair. Pass lifiDataValue as the swap calldata with ExternalActionId.Lifi.

Solana - getSolanaSwapPrices(...) returns an OKX quote ({ outSwapAmountValue, okxDataValue }). Pass okxDataValue to swap with ExternalActionId.Okx. Shielded Solana swaps route through OKX; LI.FI also supports Solana for Public (Proxy) account swaps and for cross-chain routes.

Interacting with smart contracts privately

function actionPrivateWallet(
  chainId: number,
  erc20Addresses: string[],
  deltaAmounts: bigint[],
  onChainCreation: boolean[],
  ops: string[],
  feeToken?: string,
  feeStructureOverride?: FeeStructure,
): Promise<string>;

Generate user operations with emporiumOp:

function emporiumOp(
  contract: ethers.Contract | string,
  func?: string,
  args?: unknown[],
  callDataString?: string,
  invokeWallet?: boolean,
  value?: bigint,
): string;

Stateless interactions (swaps, simple staking) use default invokeWallet: false.

Stateful interactions (reward tracking, voting power) require invokeWallet: true so the call runs from a persistent wallet address.

const operations = [
  hinkal.emporiumOp(usdcContractInstance, 'approve', [swapRouterAddress, amountIn]),
  hinkal.emporiumOp(swapRouterContractInstance, 'exactInputSingle', [swapSingleParams]),
];

Supported Chains

ChainChain IDStatus
Ethereum1✅ Live
Arbitrum42161✅ Live
Polygon137✅ Live
Base8453✅ Live
Tempo4217✅ Live
BNB56✅ Live
Robinhood4663✅ Live
Arc5042✅ Live
Solana501✅ Live
Tron728126428✅ Live
Arc Testnet5042002✅ Live
Tron Nile3448148188✅ Live