# Project Setup

{% hint style="warning" %}
EarthFast is currently in Testnet, and its Smart Contracts live on Sepolia Testnet
{% endhint %}

{% hint style="warning" %}
For most projects, the [no-code Dashboard](https://dashboard.earthfast.com/) is the simplest and quickest way to get setup. Continue to the docs below if you want a more involved, custom setup
{% endhint %}

## Prerequisites <a href="#h.mc7gv8qkzki6" id="h.mc7gv8qkzki6"></a>

* Your website
  * Must contain an `index.html` entrypoint
  * all rendering/logic should be run in browser (ie. no server-side rendering)
  * Supports client-side frameworks like React, Vue, Svelte, etc., and static site generators like Gatsby
  * If using Next.js, follow [static export](https://nextjs.org/docs/pages/building-your-application/deploying/static-exports) docs
* A subdomain on which your site will be hosted
* Access permissions – if your site makes API calls to backend or API services (eg. Infura, Alchemy), ensure your new EarthFast subdomain is added to any [CORS](https://en.wikipedia.org/wiki/Cross-origin_resource_sharing) policies or domain allowlists

Ethereum

* An Ethereum wallet (`OwnerWallet`) to manage EarthFast resources on-chain
* ETH for tx execution. For Testnet, use Sepolia ETH
* USDC for paying Content Nodes. for Testnet, we will fund your `OwnerWallet` with Sepolia USDC

## Step 1 – Setup [EarthFast CLI](https://github.com/earthfast/earthfast-cli) <a href="#id-1-install-earthfast-cli" id="id-1-install-earthfast-cli"></a>

<https://github.com/earthfast/earthfast-cli> – You will use this CLI to manage all EarthFast resources.

Below commands instruct you to use this cli via `npx`, which means you don't have to install anything.

For all available commands and options run `npx earthfast-cli --help`. For help on individual commands append `--help` to a command, eg. `npx earthfast-cli project create --help`.

#### Where to run CLI

This is intended to run in your dev environment, not your node VM, although you can run it wherever you like. Currently supported on MacOS + Debian.

#### If running on Debian, install deps

```sh
> sudo apt-get install libsecret-1-dev gnome-keyring dbus-x11
```

#### \[Optional] Alias

For brevity, consider setting up a shell alias like `alias ef="npx earthfast-cli"`

### Decide how you will sign Eth transactions

The CLI can sign transactions for you if you import your wallet into its keystore. This is done locally using [`keytar`](https://github.com/atom/node-keytar) – you can see the [code here](https://github.com/earthfast/earthfast-cli/blob/main/src/keystore.ts).

```sh
> npx earthfast-cli key import
```

Alternatively, you can set the optional `signer` flag to `--signer=ledger` for use with a Ledger, or `--signer=raw` to export transaction info for external signing.

## Step 2 – Setup your project onchain

{% hint style="info" %}
Prequisites – `OwnerWallet` must hold sufficient ETH to execute tx, and sufficient USDC to pay for hosting. For Testnet, use Sepolia ETH & USDC
{% endhint %}

### Create the project

```sh
> npx earthfast-cli project create project-name contact-email
```

If successful, you should see the below output. Save your `projectId` for later.

```sh
> npx earthfast-cli project create ProjectName contact@project.com

...
- Submitting transaction... done
> https://sepolia.etherscan.io/tx/0x...
- Processing transaction... done
[
  {
    event: 'ProjectCreated',
    args: {
      projectId: '0x...',
      owner: 'OwnerWallet',
      name: 'ProjectName',
      email: 'contact@project.com',
      content: '',
      checksum: '0x0000000000000000000000000000000000000000000000000000000000000000',
      metadata: ''
    }
  }
]
```

### Deposit escrow

Deposit some USDC into your project's escrow. These tokens will be used to pay Content Nodes for hosting your project site.

{% code fullWidth="false" %}

```sh
> npx earthfast-cli project deposit ProjectId 100.0
```

{% endcode %}

If successful, you should see the below output.

```sh
> npx earthfast-cli project deposit projectId 100.0

...
- Requesting signature... done
- Submitting transaction... done
> https://sepolia.etherscan.io/tx/0x...
- Processing transaction... done
[
  [
    {
      event: 'ProjectEscrowChanged',
      args: {
        projectId: 'projectId',
        oldEscrow: 'BigNumber 0 / 0.0 / 0.0',
        newEscrow: 'BigNumber 100000000 / 100.0 / 0.0000000001'
      }
    }
  ]
]
```

### Make a reservation with a Content Node <a href="#h.2urvg3z7vw9" id="h.2urvg3z7vw9"></a>

Find an available Content Node:

```sh
> npx earthfast-cli node list --enabled --vacant

# --vacant = lists nodes available in the current and next epoch
# To see all available flags, run:
> npx earthfast-cli node list --help
```

Using node IDs returned from above (the value for `id` key), make your reservation. See `npx earthfast-cli reservation create --help` to set the flags per your preferences.

```sh
> npx earthfast-cli reservation create --spot --renew projectId nodeId

# or reserve multiple nodes at once by passing a comma separated list of nodeIDs
> npx earthfast-cli reservation create --spot --renew projectId nodeId1,nodeId2,nodeId3
```

If successful, you should see the below output.

```shell
> npx earthfast-cli reservation create --spot --renew projectId nodeId

...
- Submitting transaction... done
> https://sepolia.etherscan.io/tx/0x...
- Processing transaction... done
[
  {
    event: 'ReservationCreated',
    args: {
      nodeId: '0x...',
      operatorId: '0x...',
      projectId: '0x...',
      lastPrice: 'BigNumber 1000000 / 1.0 / 0.000000000001',
      nextPrice: 'BigNumber 0 / 0.0 / 0.0',
      slot: [ true, true ]
    }
  }
]
```

## Step 3: Bundle your site assets <a href="#h.ny2k2oq1t1us" id="h.ny2k2oq1t1us"></a>

### Option 1: via GitHub Actions (recommended) <a href="#h.obf202kdn5or" id="h.obf202kdn5or"></a>

If your project is hosted on GitHub, this option greatly simplifies the integration by taking care of both (1) bundling the site into an EarthFast-compatible artifact and (2) leveraging the binary asset serving capability of GitHub Releases to host that artifact.

The GitHub Action itself can be found at [github.com/earthfast/armada-release-action](https://www.google.com/url?q=https://github.com/armada-network/armada-release-action\&sa=D\&source=editors\&ust=1682009597643952\&usg=AOvVaw1gYhOrP1eP9CQbIDdz0nLL), or you can follow the demo project at [github.com/earthfast/demo-project](https://www.google.com/url?q=https://github.com/armada-network/demo-project\&sa=D\&source=editors\&ust=1682009597644419\&usg=AOvVaw1Sdi1jpYUrzpNZWIRZxKUh) for a complete example.

### Option 2: Manual  <a href="#h.gsecmjpmqpmt" id="h.gsecmjpmqpmt"></a>

**Building the Site**

EarthFast is designed to be able to be easily integrated into your existing build pipeline. With the help of the CLI, you will package your site’s production build into an artifact that can be served by the network (i.e. the “EarthFast bundle”).

1. Build your site as you normally would into a final output directory (i.e. dist, build, etc.).
2. Create the EarthFast bundle by running the following command, replacing the placeholders with appropriate values (archive-name-and-version can be anything you want, build-dir should be the directory from [Step 2: Signing Up](#h.ou0iut15uw75) above):

```sh
> npx earthfast-cli bundle create <archive-name-and-version> <build-dir>

# Example:
> npx earthfast-cli bundle create my-site-v1.0.1 ./dist
```

3. The previous command will print the final bundle filename, which you’ll need now. Run the following to obtain the checksum of the bundle, which you’ll need later:

```sh
> npx earthfast-cli bundle checksum <bundle-filename>

# Example:
> npx earthfast-cli bundle checksum my-site-v1.0.1.tgz
```

#### **Hosting the bundle**

Once your site has been bundled for use on EarthFast, it needs to be published somewhere on the Internet where it’s:

1. Publicly accessible
2. Will remain available as long as it’s the live version

Both of the above are necessary because the nodes that operate the EarthFast network will fetch your site from this location throughout their serving lifetimes. However, the content is heavily cached so the request rate for the bundle should be extremely low.

Suggested locations for hosting your bundle:

* GitHub Release Assets
* AWS S3 / Google Cloud Storage / Azure Blob

Not recommended locations that would still work:

* IPFS – you’ll need to pin the file, fetching performance will likely be poor, and you’ll need to use an IPFS gateway to get a publicly accessible URL.

## Step 4: Publish Bundle to EarthFast <a href="#h.ny2k2oq1t1us" id="h.ny2k2oq1t1us"></a>

Now that your bundle is hosted publicly, you need to publish it to instruct your newly reserved Content Nodes to begin serving your site.

```sh
> npx earthfast-cli project publish <project-id> <bundle-url> <bundle-checksum>
```

If successful, you should be able to curl this url and get a 200 JSON response: `https://<node-url>?project_id=<project-id>&resource=earthfast.json`

## Custom Domain

Your project is now live on the EarthFast network, but you most likely want to set up a custom domain.

### Option 1 – \[Coming Soon] Use EarthFast's Domain Node as a Service

### Option 2 – Set up a serverless domain node

Follow the instructions on this repo to get setup – <https://github.com/earthfast/earthfast.com-on-earthfast>


---

# Agent Instructions: 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:

```
GET https://docs.earthfast.com/projects/project-setup.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
