Expo is the first application built on top of the Townhall technology. It uses the publicly deployed Menlo One Token as the utility token with which to post messages and win lottery rewards for contributing the most upvoted content.
To use Expo on the Kovan Test Network, visit the site curerntly running here: https://expo.menlo.one which includes a Menlo One Kovan Faucet for those who don't have Menlo ONE tokens.
Menlo One is about to have a Public Token Sale. Find out more here:
#For Developers:
To develop and run Expo locally, install the following prerequisites and dependencies before running the app.
We assume brew
for package management to install IPFS
and other dependencies:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
TownHall uses IPFS for storage of messages.
Menlo specific setup of IPFS can be installed and configured via:
./scripts/install-ipfs.sh
Metamask should be used for interacting with the town hall dApp.
Install Metamask extensions into your browser of choice, Chrome or Brave supported: http://metamask.io
- Install nvm and node:
brew install nvm && nvm install
- Clone the repo:
git clone git@github.com:MenloOne/expo-demo.git
- Install dependencies:
cd expo-demo && nvm use && yarn install
Run a local dev blockchain in a separate window:
truffle develop
Run IPFS daemon in a separate window:
ipfs daemon
Deploy the contracts:
truffle deploy --network develop --reset
Run the app:
yarn start
Import this private key into MetaMask for use with truffle develop
:
388c684f0ba1ef5017716adb5d21a053ea8e90277d0868337519f97bede61418
If you see in the Chrome Console Metamask RPC Errors - it means your contract deploys didn't work.
A browser window should open after starting: http://localhost:3000/
Ensure you are logged into MetaMask and switch to your imported account.
Add a Custom RPC in MetaMask with URL http://127.0.0.1:9545/
:
If for some reason Truffle doesn't work for you or you want a different environment the first thing you will
need is to fill out the .env
file with the following accounts that you create in your chain. For Ganache,
you can just copy some of the precreated accounts:
- MENLO_ROOT: Address of pre-configured account on chain.
Menlo Root should be the first created account w/ some ETH which we can then use to create the accounts below on chains such as Parity.
- MENLO_TENET_1: Address for first tenet account.
- MENLO_TENET_2: Address for second tenet account.
- MENLO_TENET_3: Address for third tenet account.
- MENLO_ROOT: Address for the account used to interact with town hall.
To get ETH in your account once on Ropsten, go to the Ropsten ETH Faucet
yarn start kovan
-
Install Parity
brew install parity
-
Run Parity
parity --geth --chain kovan
-
Install and Run Parity UI
-
Create a Root Parity Account in Parity UI and get ETH
-
Create a new
chain/kovan.env
file and paste the Root Parity Account in it:MENLO_ROOT=0x004ccE088463Eb2DC7ab23952d5744410000000
-
Create Kovan accounts for use in contracts.
node scripts/create-accounts kovan
-
Deploy the contracts
truffle deploy --network kovan
For a light, easy to use private chain with a visual and cli interface, try Ganache.
You can deploy and test using network ganache:
truffle deploy --network ganache
Note: Ganache and truffle develop are transitory. Once you shut them down, you will have to redeploy the contracts and redo any needed transactions.
For a persistent local testing environment to test before deploying to testnet or mainnet, use a Dev chain with Parity or Geth.
To run a private dev chain with Parity, first run a dev chain, setup Menlo accounts, and then deploy contracts.
Installing Parity:
brew install parity
For testing the TownHall dapp:
yarn test
For testing the town hall contracts:
dapp update
dapp test
Set the following environment variables:
1. MENLO_DEPLOYMENT_KEY:
2. MENLO_DEPLOYMENT_SERVER:
Deploy to server using shipit
:
node scripts/shipit staging deploy
- Launch an EC2 box with Ubuntu
- Setup security groups appropriately
You can follow the IPFS AWS Tutorial
sudo yum install -y golang
wget https://dist.ipfs.io/go-ipfs/v0.4.15/go-ipfs_v0.4.15_linux-amd64.tar.gz
tar -xvf go-ipfs_v0.4.15_linux-amd64.tar.gz
sudo mv go-ipfs/ipfs /usr/local/bin
rm -rf go-ipfs
sudo vi /etc/systemd/system/ipfs.service
echo 'export IPFS_PATH=/data/ipfs' >>~/.bash_profile
source ~/.bash_profile
sudo mkdir -p $IPFS_PATH
sudo chown ubuntu:ubuntu $IPFS_PATH
ipfs init -p server
ipfs config Datastore.StorageMax 20GB
ipfs config Addresses.API /ip4/127.0.0.1/tcp/5001
ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin '["*"]'
ipfs config --json API.HTTPHeaders.Access-Control-Allow-Methods '["PUT", "GET", "POST"]'
ipfs config --json Addresses.Swarm '["/ip4/0.0.0.0/tcp/4001", "/ip4/0.0.0.0/tcp/8081/ws", "/ip6/::/tcp/4001"]'
ipfs config --bool Swarm.EnableRelayHop true
ipfs config Addresses.Gateway /ip4/0.0.0.0/tcp/8080
sudo bash -c 'cat >/lib/systemd/system/ipfs.service <<EOL
[Unit]
Description=ipfs daemon
[Service]
ExecStart=/usr/local/bin/ipfs daemon --enable-gc
Restart=always
User=ubuntu
Group=ubuntu
Environment="IPFS_PATH=/data/ipfs"
[Install]
WantedBy=multi-user.target
EOL'
sudo systemctl daemon-reload
sudo systemctl enable ipfs
sudo systemctl start ipfs.service
You can now reboot your instance and make sure IPFS is running by:
sudo systemctl restart ipfs
sudo systemctl status ipfs
sudo apt-get update
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:certbot/certbot
sudo apt-get update
sudo apt-get install python-certbot-nginx
First point ipfs.menlo.one (or your domain) to your AWS box. Then:
sudo certbot --nginx -d ipfs.menlo.one
sudo bash -c 'cat >/etc/console-setup/renew-cert <<EOL
#!/bin/bash
certbot renew --noninteractive
EOL'
sudo chmod +x /etc/console-setup/renew-cert
sudo bash -c 'cat >/etc/nginx/sites-available/default <<EOL
server {
server_name ipfs.menlo.one;
listen [::]:4002 ssl ipv6only=on;
listen 4002 ssl;
ssl_certificate /etc/letsencrypt/live/ipfs.menlo.one/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/ipfs.menlo.one/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
location / {
proxy_pass http://127.0.0.1:8081;
proxy_http_version 1.1;
proxy_set_header Upgrade \$http_upgrade;
proxy_set_header Connection "upgrade";
}
}
server {
server_name ipfs.menlo.one; # managed by Certbot
location / {
proxy_pass http://127.0.0.1:5001;
proxy_set_header Host \$host;
proxy_cache_bypass \$http_upgrade;
}
listen [::]:443 ssl ipv6only=on; # managed by Certbot
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/ipfs.menlo.one/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/ipfs.menlo.one/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
if (\$host = ipfs.menlo.one) {
return 301 https://\$host\$request_uri;
} # managed by Certbot
listen 80 ;
listen [::]:80 ;
server_name ipfs.menlo.one;
return 404; # managed by Certbot
}
EOL'
You can test this config by doing:
curl -H "Origin: http://expo.menlo.com" \
-H "Access-Control-Request-Method: POST" \
-H "Access-Control-Request-Headers: X-Requested-With" \
--verbose \
http://0.0.0.0:5001/api/v0/swarm/peers; echo
sudo systemctl restart nginx
brew tap ethereum/ethereum
brew install ethereum