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

# ERC-7420

```solidity
/// @title ERC-7420: Swap-Native Non-Fungible Token
interface IERC7420 {
    /// Emitted when an NFT swaps into its bonded token allocation.
    event SwapToTokens(address indexed holder, uint256 indexed tokenId, uint256 amount);

    function bondToken()    external view returns (address); // the fungible ROOT
    function tokensPerNFT() external view returns (uint256); // 500e18
    function launched()     external view returns (bool);    // swaps open?

    /// Burn tokenId, receive tokensPerNFT of ROOT. One-way, irreversible.
    function swapToTokens(uint256 tokenId) external;
}
```

The implementation is three small contracts:

| Contract       | Role                                                                     |
| -------------- | ------------------------------------------------------------------------ |
| `Rootwood.sol` | ERC-721 · mint sale · one-way swap · constant-product curve — all in one |
| `Root.sol`     | ROOT (ERC-20) · fixed supply · minted exactly once, at launch            |
| `IERC7420.sol` | The interface + ERC-165 id                                               |

Built with **Foundry**. **19 tests green**, including a solvency fuzz that hammers the pool with random buy/sell sequences. Compiled with the `via-ir` optimizer. Every ETH path is reentrancy-guarded.

***

The full lifecycle was driven by **real on-chain transactions**, each leg a separate tx:

```
mint ×3
   → launch (seed 0.001 ETH)
      → swap NFT#0 → 500 ROOT
         → buy  (spot 2.86 → 6.39 gwei/ROOT, fee accrued)
            → sell (price falls back)
               → withdraw creator revenue
```

The accounting invariant held **to the wei**:

```
contract balance  =  poolReserve  +  accruedFees  +  mintProceeds
```

…and withdrawing creator revenue **never touched the pool reserve.**

***

### Security & trust model

What the contract can and cannot do, stated plainly.

**Guaranteed by the code:**

* ROOT supply is **fixed** — minted once at launch, no `mint` afterward, no hidden inflation.
* The swap bucket is **locked** — those 499,500 tokens are reachable only by burning an NFT.
* The pool is **solvent** — constant-product math means sells are always honorable.
* Creator withdrawals **cannot touch the pool reserve** — proceeds and fees are separate buckets.
* Every ETH-moving function is **reentrancy-guarded**.

**Trust you still extend to the creator:**

* They choose the **seed depth** — thin depth means a volatile market.
* They hold **15% of supply** and control the **team address**.
* They set the **base URI** for metadata.
* Launch timing is **their call**.

None of this is hidden — it's all on-chain and visible. But it's honest to name it: this is a launch with a real team allocation, and the market should price that in.


---

# 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://rootwood.gitbook.io/rootwood-docs/erc-7420.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.
