> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ownafarm.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# Invoice tokenization

> How OwnaFarm converts real-world agricultural invoices into ERC-1155 NFTs, enabling fractional investor ownership and instant farmer liquidity.

Invoice tokenization enables farmers to receive instant liquidity by converting real-world invoices into blockchain assets.

## Process

```mermaid theme={null}
flowchart LR
    A[Invoice] --> B[Smart Contract]
    B --> C[ERC-1155 NFT]
    C --> D[Investor Purchase]
    D --> E[Fractional Ownership]
```

When a farmer submits an invoice:

<Steps>
  <Step title="Record on-chain">
    Invoice details are recorded on-chain.
  </Step>

  <Step title="Mint NFT">
    An ERC-1155 NFT is minted to represent the invoice.
  </Step>

  <Step title="Investors purchase">
    Investors purchase fractional ownership of the invoice.
  </Step>

  <Step title="Claim at maturity">
    Token holders claim their share when the invoice matures.
  </Step>
</Steps>

## Benefits

<Tabs>
  <Tab title="For farmers">
    | Benefit       | Description                  |
    | ------------- | ---------------------------- |
    | Speed         | Funding in hours, not months |
    | Access        | No bank account requirements |
    | Fair rates    | Market-determined pricing    |
    | No collateral | Invoice is the security      |
  </Tab>

  <Tab title="For investors">
    | Benefit              | Description                |
    | -------------------- | -------------------------- |
    | Fractional ownership | Invest any amount          |
    | Diversification      | Spread across invoices     |
    | Transparency         | Full visibility into terms |
    | Automation           | Smart contract settlement  |
  </Tab>
</Tabs>

## Invoice lifecycle

```mermaid theme={null}
stateDiagram-v2
    [*] --> Pending: submitInvoice()
    Pending --> Approved: approveInvoice()
    Pending --> Rejected: rejectInvoice()
    Approved --> Funded: invest() 100%
    Funded --> Completed: all harvested
```

| Status    | Code | Description           |
| --------- | ---- | --------------------- |
| Pending   | 0    | Awaiting admin review |
| Approved  | 1    | Open for investment   |
| Rejected  | 2    | Did not pass review   |
| Funded    | 3    | Fully funded          |
| Completed | 4    | All claims processed  |

## Invoice structure

| Field        | Type    | Description           |
| ------------ | ------- | --------------------- |
| farmer       | address | Invoice submitter     |
| offtakerId   | bytes32 | Buyer identifier      |
| targetFund   | uint128 | Amount to raise       |
| fundedAmount | uint128 | Current amount funded |
| yieldBps     | uint16  | Yield in basis points |
| duration     | uint32  | Lock period (seconds) |
| status       | uint8   | Current status        |

## Investment example

```text Invoice: $10,000 target, 15% yield theme={null}
Investor A: $2,000 (20%)  ->  Return: $2,300
Investor B: $3,000 (30%)  ->  Return: $3,450
Investor C: $5,000 (50%)  ->  Return: $5,750
```

Each investor receives an NFT and proportional yield.

## Security

| Layer          | Protection                        |
| -------------- | --------------------------------- |
| Smart contract | Funds locked until conditions met |
| ERC-1155       | Audited token implementation      |
| Immutable      | Cannot alter after submission     |
| Automatic      | No manual intervention            |
