Arweave Setup

In the following guide, we will cover all the necessary steps to set up an Arweave gateway, add it to Media Network and then serve its content to end-users through it.

Requirements

  1. A Unix OS (Debian 10 preferable)

  2. Docker and Docker Compose LTS

Suggested Hardware

There are several million transactions on the Arweave chain. In order to effectively serve content on the gateway you'll need a decent sized computer. The ideal specs for a Gateway should have the following:

  1. 16GB RAM (ideally 32GB RAM)

  2. ~4TB of SSD storage available

  3. Intel i5 / AMD FX or greater, +4 vCPUs should be more than enough, these are typically Intel Xeon CPUs.

Install Tools

sudo apt update; \
sudo apt -y install tmux curl nano apt-transport-https ca-certificates curl gnupg2 software-properties-common

Add Docker’s official GPG key:

Import Docker GPG key used for signing Docker packages.

curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -

Add the Docker repository to Debian 10

Add Docker repository which contain the latest stable releases of Docker CE.

sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/debian \
$(lsb_release -cs) \
stable"

Install Docker

sudo apt update; \
sudo apt -y install docker-ce docker-ce-cli containerd.io

This installation will add docker group to the system without any users. Add your user account to the group to run docker commands as non-privileged user.

sudo usermod -aG docker $USER
newgrp docker

Check docker and compose version

$ docker version
Client: Docker Engine - Community
Version: 19.03.2
API version: 1.40
Go version: go1.12.8
Git commit: 6a30dfc
Built: Thu Aug 29 05:29:29 2019
OS/Arch: linux/amd64
Experimental: false
Server: Docker Engine - Community
Engine:
Version: 19.03.2
API version: 1.40 (minimum version 1.12)
Go version: go1.12.8
Git commit: 6a30dfc
Built: Thu Aug 29 05:28:05 2019
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.2.6
GitCommit: 894b81a4b802e4eb2a91d1ce216b8817763c29fb
runc:
Version: 1.0.0-rc8
GitCommit: 425e105d5a03fabd737a126ad93d62a9eeede87f
docker-init:
Version: 0.18.0
GitCommit: fec3683

Log out and log back in so that your group membership is re-evaluated.

exit

Clone gateway repo

git clone https://github.com/mediafoundation/arweave-gateway.git

Environment

By default, there is a default environment you can use located at .env.docker in the repository.

ARWEAVE_NODES=["https://arweave.net"]
DATABASE_HOST=postgres
DATABASE_PORT=5432
DATABASE_USER=arweave
DATABASE_PASSWORD=arweave
DATABASE_NAME=arweave
ENVIRONMENT=public
MANIFESTS=0
BIP39=0
PORT=3000
PARALLEL=4
INDICES=["App-Name", "app", "domain", "namespace"]
CACHING=1
CACHE_FOLDER=/gateway/cache
CACHE_OFFSET=0

Make sure you copy this configuration to .env.

cp .env.docker .env

Compilation

You can start the server with docker-compose.

# with npm
npm run docker:start
# with yarn
yarn docker:start
# with pure docker-compose
docker-compose up --build -d

You can spin down the docker-compose cluster with.

# with npm
npm run docker:stop
# with yarn
yarn docker:stop
# with pure docker-compose
docker-compose down

Adding files to Arweave

You can add any type of content to Arweave. In this case we will put some text content into a .txt file called mytextfile.txt and put the text "ARWEAVE TEST - VERSION 1" in it. Make sure you first install arweave-deploy and load your Arweave wallet with AR tokens to be able to add files to the Arweave Network. You can buy AR in the following markets. In this specific case, the price to deploy a txt file was 0.000001824540 AR

echo "ARWEAVE TEST - VERSION 1" > mytextfile.txt

You can read the file's contents using the cat command:

cat mytextfile.txt
ARWEAVE TEST - VERSION 1

Upload mytextfile.txt to Arweave:

arweave deploy mytextfile.txt
Enter your encryption passphrase to decrypt mcCDEo4G6F5QkHPtouxm64__djLfKr6las39rpKSAOc
File
Path: mytextfile.txt
Size: 25.00 Bytes
Transaction
ID: 6KZ2ok0JV21mtzUdo5WT_ErcuoLk9-MZcPWLX5LPmK8
Price: 0.000001824540 AR
Tags:
- Content-Type:text/plain
- User-Agent:ArweaveDeploy/1.9.1
Wallet
Address: mcCDEo4G6F5QkHPtouxm64__djLfKr6las39rpKSAOc
Current balance: 2.480000000000 AR
Balance after uploading: 2.479998175460 AR
Carefully check the above details are correct, then Type CONFIRM to complete this upload CONFIRM
Your file is deploying! 🚀
Once your file is mined into a block it'll be available on the following URL
https://arweave.net/6KZ2ok0JV21mtzUdo5WT_ErcuoLk9-MZcPWLX5LPmK8
You can check its status using 'arweave status 6KZ2ok0JV21mtzUdo5WT_ErcuoLk9-MZcPWLX5LPmK8'

Local Testing

You can now access any content hosted on the Arweave network, for example the file we've just deployed mytextfile.txt using Arweave's txID:

curl http://localhost:3000/6KZ2ok0JV21mtzUdo5WT_ErcuoLk9-MZcPWLX5LPmK8
ARWEAVE TEST - VERSION 1

You can test if the server and the GraphQL queries are working locally by navigating with a browser to:

http://localhost:3000/graphql

This webpage should look similar to.

https://arweave.dev/graphql