# ICTC

A distributed transaction framework for Defi application on IC network. It supports Motoko language. The core idea of [ICTC](https://github.com/iclighthouse/ICTC) is inspired by the DTC (Distributed Transaction Coordinator), which is commonly used in the financial sector.

Distributed transactions on blockchain networks, like IC-based dapps and DeFi applications, face challenges due to distinct trust assumptions. Unlike traditional systems that trust participating entities, blockchain systems trust only the smart contract code.

For cross-canister calls within a canister, data inconsistency can arise due to callee faults:

1. Business error: like insufficient token balance.
2. Runtime error: such as a divide-by-0 error.
3. Fail-stop: where the callee's subnet becomes inaccessible.

Although the IC network rarely experiences fail-stop, it's crucial for DeFi apps to handle potential failures and ensure eventual consistency, or face severe repercussions.

A new framework, ICTC, rooted in "Base: An Acid Alternative," aims for eventual consistency in cross-canister transactions. However, ICTC only ensures "best-effort delivery" and depends on governance or manual interventions for final consistency.

ICTC mandates: For callee:

* Achieve task atomicity.
* Implement features for eventual consistency:
  * Allow retries with idempotency.
  * Use Nonce for orderly execution and idempotency.
  * Pre-calculate globally unique txid.
  * Offer reversal transaction functions.

For caller:

* Ensure eventual consistency using:
  * Retries.
  * Automatic/manual reversal transactions.
  * "Debit first, credit later" approach.
  * Caller-led coordination.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://iclighthouse.gitbook.io/iclighthouse/products/ictc.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
