This repo is meant as a sandbox for ideas in other backend applications. We are expirementing here with
- graph-ql like queries between using both the blockchain and postgres as a single datasource
- records as a way to separate the types used by the database from the rest of the API
See the Makefile for required environment variables
- postgres database
- access to a synced main-net node where you have permission to install filters
- an ERC20 address (the default is the OmiseGo token address)
first you want to start a postrgres instance and create the token_db
> create database token_db;
run the initial migration to setup the database
> docker exec -it -u postgres <PG_CONTAINER_ID> psql -c "create database token_db;"
> make create-token-db
populate the database with all relevant events from a given block number
> STARTING_BLOCK=5340979 NODE_URL=<YOUR_NODE> make token-indexer
This is a process which will sync the database then continue to monitor events. It should be able to resume from it's last known check in if you decide to turn it off and on.
finally, run the server
make token-server
This project consists of two smaller executables
-
token-indexer : This is one of our standard indexing pipelines that monitors erc20 transfer events from the given contract.
-
token-server : This is a standard postgres + servant + docs Rest service. It uses the composite packages for records. The reason is that they provide an interface for their records with most other packages we would like to use -- swagger, aeson, and opalaye (postgres).
Currently we have limited use of Haxl (just batch fetching token balances), but it is possible to create a DataSource
that uses both the blockchain and postgres as backends, potentially creating some really interesting queries.