> For the complete documentation index, see [llms.txt](https://solana-unchained.gitbook.io/whitepaper/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://solana-unchained.gitbook.io/whitepaper/technical-specifications/smart-contract-architecture.md).

# Smart Contract Architecture

1\. **Vault Staking Contract Design**

Lock/Unlock Logic:

* User calls lock\_tokens(amount, duration) — tokens transferred to program-owned escrow account
* Lock period tracked by absolute slot number at time of deposit + duration in slots
* Unlock only executable after current\_slot >= unlock\_slot
* Early exit: disabled by default; future governance vote could enable with penalty fee

Reward Calculation:

`reward = principal × APR × (elapsed_slots / slots_per_year)`

* slots\_per\_year ≈ 157,680,000 (at \~0.5s per slot target)
* APR tier assigned at deposit time and locked for the duration
* Rewards accumulated per epoch, claimable at any time without breaking lock

2\. **Commerce Protocol On-Chain Flow**

User initiates purchase → $UCHN deducted from wallet

&#x20;       ↓

Program verifies balance + calculates fee split

&#x20;       ↓

Merchant payment settled (stablecoin or $UCHN)

&#x20;       ↓

Fee: X% burned, Y% to treasury, Z% to staker pool

&#x20;       ↓

Cashback (if applicable) credited to user in $UCHN

{% hint style="info" %}
No KYC is required because the protocol operates at the token level, the user's identity is never involved, only their wallet address and token balance.
{% endhint %}

3\. **SPL Token Authority Structure**

| Authority                 | Status           | Controller                          |
| ------------------------- | ---------------- | ----------------------------------- |
| Mint authority            | Revoked post-TGE | No one. Supply is permanently fixed |
| Freeze authority          | Revoked post-TGE | No one                              |
| Program upgrade authority | Multisig         | Core team multisig wallet           |
| Treasury                  | Multisig         | Core team + advisors                |

Revoking mint and freeze authority at TGE is a rug-pull mitigation — no party can create new tokens or freeze user funds after launch.

4\. **Guardian Threshold Signature Scheme (M-of-N)**

Social recovery uses an M-of-N multisig model:

* User selects N guardians (recommended: 3–5)
* Recovery requires M approvals (recommended: M = ceil(N/2) + 1)
* Guardian addresses stored in a program-derived account (PDA) tied to the user's wallet
* Recovery transaction includes a time delay (e.g., 48 hours) to allow the original owner to cancel if unauthorized

Example: 3-of-5 guardian setup

* 5 guardians designated
* Any 3 can initiate a recovery
* 48-hour cancellation window before execution

5\. **Dead Man's Switch: On-Chain Inheritance Implementation**

User registers beneficiary address + inactivity\_threshold (e.g., 365 days)

&#x20;       ↓

Heartbeat transactions reset the inactivity counter

&#x20;       ↓

If no heartbeat for inactivity\_threshold slots:

&#x20;       ↓

Beneficiary can claim assets via claim\_inheritance() instruction

&#x20;       ↓

Assets transferred from user's escrow to beneficiary address

The heartbeat can be any valid on-chain transaction from the wallet, normal usage inherently resets the timer.


---

# 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://solana-unchained.gitbook.io/whitepaper/technical-specifications/smart-contract-architecture.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.
