Skip to content
A BAT-based micropayments system for users and publishers
Branch: master
Clone or download
maikelmclauflin Cascade migration (#620)
* added cascading for migrations

* added tests for migrations
Latest commit 168c999 May 16, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
.git-hooks removed merge and rewrite hooks to prevent continuous hook triggering… Jan 29, 2019
balance added type to grant content subset (#614) Apr 24, 2019
bat-utils setup prom as plugin (#611) May 14, 2019
bin Cascade migration (#620) May 16, 2019
documentation Update Sep 13, 2017
eyeshade Cascade migration (#620) May 16, 2019
grafana/provisioning added grafana and prometheus... unable to login (#406) Oct 18, 2018
prometheus added grafana and prometheus... unable to login (#406) Oct 18, 2018
test Cascade migration (#620) May 16, 2019
.buildpacks switch to binary cmake buildpack Aug 31, 2017
.dockerignore don't use babel-node in production Oct 31, 2017
.env.example setup prom as plugin (#611) May 14, 2019
.gitignore added endpoint for account ad viewing transactions (#415) Nov 29, 2018
.nsprc Bringup CI (#195) Apr 16, 2018
.travis.yml Wallet cooldown (#597) Apr 5, 2019
Dockerfile transaction table, balance and transaction apis (#356) Aug 22, 2018
LICENSE Initial commit Jul 26, 2017
Procfile procfile env var interp Aug 30, 2017 Update README instructions to run migrations before tests (#504) Jan 16, 2019
base.yml setup prom as plugin (#611) May 14, 2019
docker-compose.captcha.yml Runtime currency swap (#388) Nov 5, 2018
docker-compose.yml setup prom as plugin (#611) May 14, 2019
package.json setup prom as plugin (#611) May 14, 2019


BAT back-end servers (ledger, eyeshade, and balance)

Running locally with docker-compose

First, install docker and docker compose.

Check out

You can add any environment variables that need to be set by creating a .env file at the top of the repo. Docker compose will automatically load from this file when launching services.

e.g. you might have the following in .env:

# Build the base image:
docker-compose build

# (Optional) Build the bat-go image according to instructions @

# 1. If you built bat-go you can then bring up all services (ledger, eyeshade, balance and grant)
docker-compose up

# 2. If you did not build bat-go, limit the services being brought up to exclude the grant service
docker-compose up ledger-web ledger-worker eyeshade-web eyeshade-worker balance-web

# Logs from all services presented interleaved, you can press ctrl-c to stop.
# Ledger listens on port 3001, eyeshade on 3002, and balance on 3003

# Note you can run any subset of services (e.g. only eyeshade)
docker-compose up eyeshade-web eyeshade-worker

# You can also launch and run services in the background
docker-compose up -d eyeshade-web eyeshade-worker

# And stop running background services with
docker-compose stop


Configuration variables are stored as environment preferences. See config.js for a list of these variables for ledger, eyeshade, and balance respectively.

If you intend to run eyeshade in communication with the publisher's website, you will need to set the UPHOLD_CLIENT_ID and UPHOLD_CLIENT_SECRET environment variables to the same as those used on your copy of the publishers site.


For linting we use StandardJS. It's recommended that you install the necessary IDE plugin. Since this repo uses ES7 features, you'll need a global install of both the standard and babel-eslint packages.

Running tests

Please note: Some tests access live APIs and require auth tokens which are not stored in the repo.

Prepare .env file

  1. Copy example over: cp .env.example .env.
  2. Confirm .env vars match the contents of .travis.yml section
  3. Fill in the remaining {CHANGE_ME} .env vars appropriately; please consult your local BAT dev to find the answers.

Build local servers

npm run docker-build

Start local servers

npm run docker-up

Postgres migrations

You can run all migrations to upgrade the schema to the latest version using:

npm run docker-migrate-up

You can reverse a particular migration by running:

npm run docker-migrate-down -- migrations/0001_transactions/down.sql

Run tests

best to do in another terminal

npm run docker-test

Testing contribution

If you are testing contributions locally (not with e2e automated tests) you need to add surveyors manually. You can do this by running bellow command when ledger service is running.

curl -X POST --header 'Authorization: Bearer foobarfoobar' --header 'Content-Type: application/json' --header 'Accept: application/json' -d '{"adFree":{"fee":{"USD":5},"votes":50,"altcurrency":"BAT","probi":"27116311373482831368"}}' ''


docker-compose run --rm -p 9229:9229 eyeshade-web npm run start-eyeshade -- --inspect=
You can’t perform that action at this time.