> For the complete documentation index, see [llms.txt](https://cjay-1.gitbook.io/cjay-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cjay-1.gitbook.io/cjay-docs/overview/how-it-works.md).

# How it works

The whole system is one object — a **legacy plan** — moving through five states.

## Step by step

### 1. The owner creates a plan

In the app the owner:

* names **beneficiaries** and gives each a percentage (must total 100%),
* names **guardians** and sets a threshold (e.g. "2 of my 3 guardians"),
* chooses an **asset and amount** to protect (e.g. 5,000 USDC).

This calls `create_legacy` on the contract. **No money moves yet.** The plan is in `Draft`.

### 2. The owner funds the plan

The owner approves a token transfer and calls `deposit`. The committed amount moves from the owner's wallet **into the contract**. The plan is now `Funded` — the app shows this as "Protected."

From here the owner can still `cancel_legacy` and get the full amount back.

### 3. Life goes on

The owner does a periodic **Life Check-In** — one tap on "I'm Here." Heirloom sends gentle reminders by email before each due date. As long as check-ins happen, nothing changes on-chain.

### 4. A check-in is missed

If the owner stops checking in, Heirloom escalates: more reminders, then a notice to the guardians. Each guardian independently decides whether to act.

### 5. Guardians verify

Each participating guardian calls `approve_guardian` (a Freighter signature). When the number of approvals reaches the threshold, the contract moves the plan from `Funded` to `Verified`. Double approvals and non-guardians are rejected on-chain.

### 6. Release is finalized

Once `Verified`, the owner is presumed gone, so `finalize_release` takes **no authorization** — any party (a beneficiary, a guardian, Heirloom, a script) can call it. The contract:

* checks its own token balance actually covers the committed amount,
* splits the amount across beneficiaries by their basis-point shares,
* gives any rounding remainder to the last beneficiary,
* records a `ClaimData` entry per beneficiary,
* moves the plan to `Released`.

### 7. Beneficiaries claim

Each beneficiary gets a private link — `/claim/<token>` — with a guided reveal of the messages and documents left for them. To take the assets, they connect their own wallet and call `claim_assets`. The contract transfers their share and marks it claimed. Beneficiaries claim **independently**; one slow beneficiary never blocks another.

## What Heirloom can and cannot do

| Heirloom (the service) can                      | Heirloom cannot                            |
| ----------------------------------------------- | ------------------------------------------ |
| Send reminder and notification emails           | Move or freeze the deposited funds         |
| Store encrypted documents and messages          | Approve a plan on a guardian's behalf      |
| Build unsigned transactions for the app to sign | Decide that release should happen          |
| Show the plan's status                          | Change a beneficiary's allocation on-chain |

Every state change is signed by the relevant person in Freighter, or — for `finalize_release` — gated purely by on-chain state.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://cjay-1.gitbook.io/cjay-docs/overview/how-it-works.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
