Smart Contracts
Hinkal Protocol — Contracts Overview
This page summarizes the core contracts and how they interact to enable private transactions, external DeFi integrations, and modular execution logic.
Core Orchestration
Hinkal (
contracts/Hinkal.sol)Entrypoint for users. Verifies Groth16 proofs via
VerifierFacade, enforces Merkle root membership, slippage and balance invariants, and coordinates hooks and logic calls.Delegates complex execution to
HinkalInLogicand writes commitments/nullifiers viaHinkalBase.
HinkalBase (
contracts/HinkalBase.sol)Holds canonical state: Merkle tree of commitments and spent nullifiers.
Emits
NewCommitment/Nullifiedwith semantics for off-chain vs on-chain UTXOs.Provides Transferer helpers and access control for helper/logic addresses.
Logic Layer
HinkalInLogicBase / HinkalInLogic
Implements internal approval UTXO lifecycle, external action execution, and proofless deposit fund handling.
inHinkalTransactroutes: ONLY_APPROVAL, EXECUTE.inHinkalExecutionFlowspends approvals, executes external calls safely, reconciles balances/allowances, forms UTXOs, and enforces invariants.External action path:
handleRunExternalActionprepares deltas and invokes adapter’srunAction.
Policy/Preflight
HinkalHelper (
libs/hardhat/contracts/HinkalHelper.sol)Relay whitelisting and fee policy (RelayStore), token limits and registry (ERC20TokenRegistry), and circuit input construction (CircomDataBuilder).
Validates transaction dimensions, sender/relay consistency, calldata hash, gas token usage, access token rules, and EIP-712 EXECUTE metadata.
Mints access tokens on demand when signatures are present.
External Integrations
ExternalActionSwap and Adapters
ExternalActionSwapexecutes a single swap against a router and returns one UTXO. Handles input/output fee deductions and ETH wrapping.UniswapExternalAction: Uniswap V3 exactInputSingle using encodedfeetier.OneInchExternalAction: Executes raw calldata from 1inch API; computes output by balance delta.OdosExternalAction: Executes Odos calldata; expects output amount in return data.
Emporium
Upgradeable, batch-execution external action. Decodes
EmporiumStack(signed when stateful) and runs operations either via direct calls or through a user’sHinkalWallet.Anti-replay with
usedMessages, EIP-712 signature binding, per-token accounting with delta adjustments, and relay fee payment.
HinkalWallet
Minimal, Emporium-controlled wallet supporting stateful sequences.
Exposes strictly gated calls (
callHinkalWallet,doSendToRelay) and EIP-1271 for signature verification.
Typical Flow (transact)
Client builds
CircomData, generates proof, and submitstransact.Hinkal calls
HinkalHelper.performHinkalChecks→ returns circuit public signals.verifyProofandrootHashExistsgates pass.Optional hooks run; approvals processed if requested.
Execution branch:
Internal deposit/withdrawal
In-logic execution (spend approvals, external call, reconcile)
External action adapter (e.g., Uniswap/1inch/Odos)
Slippage and balance equations enforced per token.
Nullifiers inserted; commitments added; events emitted for indexers.
Last updated