---
# System prepended metadata

title: Fund

---

# Fund
eric's attempt at the model, assumes denomination in eth, always

## The Library
connects existing desks to the Fund agent (and later the Fund Contract/Escrow)

### `(fund & <data>)` instantiating the library

```hoon=
:: assume
::
+$  goals
  $:  total=@rd
      milestones=(list milestone)
  ==
+$  milestone
  $:  amt=@rd
      title=@t
      description=@t
      meta=json
  ==

::  then triggering fund looks like this:
::
%-  fund
:*  toggle-funding=?
    escrow=@p
    id=@t
    title=@t
    description=@t
    goals=goals
    meta=json
==
```

### watching escrow
when `toggle-funding` is `true`, the library will subscribe to an escrow agent (as specified) who will take pledges and record them and provide metadata back to subscribers. when `toggle-funding` is false, these subscriptions will be disposed of.

### `+on-watch`
Front ends can watch
- `/~/fundraising` to get a list of campaigns and their active state
    - `(list [campaign=id active=?])`
    - 
- `/~/fundraising/<campaign-id>` to get the data for the current campaign, as a json, for display on screen. The JSON should have elements that one would expect of a campaign and as is required by the FE to adequately display it. I assume a structure as follows:

    ```json=
    {
        campaign {
            id: 123, // some campaig id
            title: "Help Me Improve %app",
            description: "A paragraph of text",
            goals: {
                total: 1.5,  // in eth
                current: 1,  // total donations
                milestones: {
                    // some milestone data - descriptions, values
                }
            },
            contributors: [
                {
                    contributor: null || '~zod', // anonymous-maybe
                    amount: .01,
                    message: 'this is a limited character message',
                    signature: null || 0v123, // a signature
                }
            ],
            metadata: {
                // a flexible set of other metadata that YOU expect
                // but may not be used by other campaigns hoon side
                // we'll store this as a json.
            }
        }
    }
    ```

### Campaign Manager (escrow)
On receiving some subscriptions for a campaign ID, the agent will register this campaign id in a holding pen - you can accept this up to a live campaign. If you do not accept it, you will not accept any pledges and will return a `pending` state on subscription. Once accepted, the agent will start accepting signed pledges, tally them for a total and return that and a list of contributors, maybe anonymized per the preference of the pledger, to any subscribers, for displaying in the FE. They will be able to edit any part of the data, to change messages, contributor names, signatures, amounts, and they will be able to inject anonymous contributions with no signature that come in through other channels.

Escrow should also send a state of (unit ?(%active %stretch %finish))
