Project Setup
Host your website on EarthFast
EarthFast is currently in Testnet, and its Smart Contracts live on Sepolia Testnet
For most projects, the no-code Dashboard is the simplest and quickest way to get setup. Continue to the docs below if you want a more involved, custom setup
Prerequisites
Your website
Must contain an
index.html
entrypointall 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 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 policies or domain allowlists
Ethereum
An Ethereum wallet (
OwnerWallet
) to manage EarthFast resources on-chainETH 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 – 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
[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
– you can see the code here.
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
Prequisites – OwnerWallet
must hold sufficient ETH to execute tx, and sufficient USDC to pay for hosting. For Testnet, use Sepolia ETH & USDC
Create the project
If successful, you should see the below output. Save your projectId
for later.
Deposit escrow
Deposit some USDC into your project's escrow. These tokens will be used to pay Content Nodes for hosting your project site.
If successful, you should see the below output.
Make a reservation with a Content Node
Find an available Content Node:
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.
If successful, you should see the below output.
Step 3: Bundle your site assets
Option 1: via GitHub Actions (recommended)
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, or you can follow the demo project at github.com/earthfast/demo-project for a complete example.
Option 2: Manual
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”).
Build your site as you normally would into a final output directory (i.e. dist, build, etc.).
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 above):
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:
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:
Publicly accessible
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
Now that your bundle is hosted publicly, you need to publish it to instruct your newly reserved Content Nodes to begin serving your site.
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
Last updated