THIS REPO IS NO LONGER MAINTAINED
BlockAtlas is a clean explorer API and transaction observer for cryptocurrencies.
BlockAtlas connects to nodes or explorer APIs of the supported coins and maps transaction data, account transaction history into a generic, easy to work with JSON format.
The observer API watches the chain for new transactions and generates notifications by guids.
Block Atlas supports more than 25 blockchains: Bitcoin, Ethereum, Binance Chain etc, The full feature matrix is here.
Blockatlas allows to:
Platform API is independent service and can work with the specific blockchain only (like Bitcoin, Ethereum, etc)
Notifications:
Subscriber Producer - Create new blockatlas.SubscriptionEvent [Not implemented at Atlas, write it on your own]
Subscriber - Get subscriptions from queue, set them to the DB
Parser - Parse the block, convert block to the transactions batch, send to queue
Notifier - Check each transaction for having the same address as stored at DB, if so - send tx data and id to the next queue
Notifier Consumer - Notify the user [Not implemented at Atlas, write it on your own]
New Subscriptions --(Rabbit MQ)--> Subscriber --> DB
|
Parser --(Rabbit MQ)--> Notifier --(Rabbit MQ)--> Notifier Consumer --> User
The whole flow is not available at Atlas repo. We will have integration tests with it. Also there will be examples of all instances soon.
Go Toolchain versions 1.14+
Depends on what type of Blockatlas service you would like to run will also be needed.
Download source to GOPATH
go get -u github.com/trustwallet/blockatlas
cd $(go env GOPATH)/src/github.com/trustwallet/blockatlas
Read configuration info
# Start Platform API server at port 8420 with the path to the config.yml ./
go build -o api-bin cmd/api/main.go && ./api-bin -p 8420
# Start parser with the path to the config.yml ./
go build -o parser-bin cmd/parser/main.go && ./parser-bin
# Start notifier with the path to the config.yml ./
go build -o notifier-bin cmd/notifier/main.go && ./notifier-bin
# Start subscriber with the path to the config.yml ./
go build -o subscriber-bin cmd/subscriber/main.go && ./subscriber-bin
Build and start all services:
make go-build
make start
Build and start individual service:
make go-build-api
make start
Build and run all services:
docker-compose build
docker-compose up
Build and run individual service:
docker-compose build api
docker-compose start api
When any of Block Atlas services started they look up inside default configuration. Most coins offering public RPC/explorer APIs are enabled, thus Block Atlas can be started and used right away, no additional configuration needed. By default starting any of the services will enable all platforms
To run a specific service only by passing environmental variable, e.g: ATLAS_PLATFORM=ethereum
:
ATLAS_PLATFORM=ethereum go run cmd/api/main.go
ATLAS_PLATFORM=ethereum binance bitcoin go run cmd/api/main.go # for multiple platforms
or change in config file
# Single
platform: [ethereum]
# Multiple
platform: [ethereum, binance, bitcoin]
This way you can one platform per binary, for scalability and sustainability.
To enable use of private endpoint:
nimiq:
api: http://localhost:8648
It works the same for worker - you can run all observer at 1 binary or 30 coins per 30 binaries
The rest gets loaded from environment variables.
Every config option is available under the ATLAS_
prefix. Nested keys are joined via _
.
Example:
ATLAS_NIMIQ_API=http://localhost:8648
make test
End-to-end tests with calls to external APIs has great value, but they are not suitable for regular CI verification, beacuse any external reason could break the tests.
# Start API server with mocked config, at port 8437 ./
go build -o api-bin cmd/api/main.go && ./api-bin -p 8437 -c configmock.yml
Therefore mocked API-level tests are used, whereby external APIs are replaced by mocks.
mockserver
. It listens locally, and returns responses to specific API paths, taken from json data files.make newman-mocked
).make start-platform-api-mock
.Swagger API docs provided at path /swagger/index.html
or you can install go-swagger
and render it locally (macOS example)
Install:
brew tap go-swagger/go-swagger
brew install go-swagger
Render:
swagger serve docs/swagger.yaml
After creating a new route, add comments to your API source code, See Declarative Comments Format.
Run $ make go-gen-docs
in root folder.