> 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/technical-description/transactions/deposits-and-withdrawals.md).

# Deposits & Withdrawals

For Hinkal, depositing and withdrawing funds are two key operations. To interact with the protocol, users must first create and mint an access token. After that, they generate a Zero-Knowledge Proof (ZKP) off-chain and submit it on-chain using the Hinkal contract’s `transact` function. The contract then performs several checks, including verifying the proof, checking the root hashes of both the Hinkal and Access Token Merkle trees, and ensuring the protocol’s balances are accurate.

During this process, the contract nullifies any commitments tied to the provided nullifiers to prevent them from being reused. It also adds any new commitments to Hinkal's Merkle tree. For deposits, the user’s funds are transferred to the Hinkal contract. In the case of withdrawals, the contract first pays any relayer fees (if a relayer is involved) and then transfers the remaining funds to the recipient. To prevent frontrunning attacks, a calldata hash is submitted with the ZKP, ensuring that transaction details, such as the relayer, cannot be maliciously altered during the transaction.

<figure><img src="/files/Mu6cAh6xEvTaW3txlTiE" alt=""><figcaption><p>Deposit</p></figcaption></figure>

<figure><img src="/files/zWPljL8pWaaOrhPJ8Lat" alt=""><figcaption><p>Withdrawal</p></figcaption></figure>
