Giter VIP home page Giter VIP logo

blockatlas's Introduction

Block Atlas by Trust Wallet

Go Version GoDoc Build Status Codacy Badge Go Report Card Docker

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 and market data into a generic, easy to work with JSON format. It is in production use at the Trust Wallet app, the official cryptocurrency wallet of Binance. Also is in production at the BUTTON Wallet, Telegram based non-custodial wallet. The observer API watches the chain for new transactions and generates notifications by webhooks.

Supported Coins

Setup

Requirements

From Source

# Download source to $GOPATH
go get -u github.com/trustwallet/blockatlas
cd $(go env GOPATH)/src/github.com/trustwallet/blockatlas

# Start Observer with the path to the config.yml ./ 
go build -o observer-bin cmd/observer/main.go && ./observer-bin -c config.yml

# Start API server at port 8422 with the path to the config.yml ./ 
go build -o api-bin cmd/api/main.go  && ./api-bin -p 8422 -c config.yml

# Start sync worker for market prices and rates with the path to the config.yml ./ 
go build -o syncmarkets-bin cmd/syncmarkets/main.go && ./syncmarkets-bin -c config.yml  

Docker

From Docker Hub:

docker run -it -p 8420:8420 trustwallet/blockatlas

Build and run from local Dockerfile:

You should change config.yml:

redis: redis://redis:6379

Then build:

docker-compose build

For run api, observer and syncmarkets:

docker-compose up

If you need to start one service:

docker-compose start api redis
docker-compose start observer redis
docker-compose start syncmarkets redis

Heroku

Deploy

Configuration

Block Atlas can run just fine without configuration. By default, all coins offering public RPC/explorer APIs are enabled.

If you want to use custom RPC endpoints, or enable coins without public RPC (like Nimiq), you can configure Block Atlas over config.yml or environment variables.

Config File

Config is loaded from config.yml if it exists in the working directory. The repository includes a default config for reference with all available config options.

Example (config.yml):

nimiq:
  api: http://localhost:8648
#...

Environment

The rest gets loaded from environment variables. Every config option is available under the ATLAS_ prefix. Nested keys are joined via _ (Example nimiq.api => NIMIQ_API)

Example:

ATLAS_NIMIQ_API=http://localhost:8648

Docs

Swagger API docs provided at path /swagger/index.html

Updating Docs

  • After creating a new route, add comments to your API source code, See Declarative Comments Format.

  • Download Swag for Go by using:

    $ go get -u github.com/swaggo/swag/cmd/swag

  • Run the Swag in your Go project root folder.

    $ swag init

Metrics

The Blockatlas can collect and expose by expvar's, metrics about the application healthy and clients and server requests. Prometheus or another service can collect metrics provided from the /metrics endpoint.

To protect the route, you can set the environment variables METRICS_API_TOKEN, and this route starts to require the auth bearer token.

Contributing

If you'd like to add support for a new blockchain, feel free to file a pull request. Note that most tokens that run on top of other chains are already supported and don't require code changes (e.g. ERC-20).

The best way to submit feedback and report bugs is to open a GitHub issue. Please be sure to include your operating system, version number, and steps to reproduce reported bugs.

More resources for developers are in CONTRIBUTING.md.

blockatlas's People

Contributors

akinmail avatar artemgoryunov avatar cryptokat avatar dpereskokov avatar dustinxie avatar dvl-es avatar eddywm avatar enorage avatar fionera avatar hewigovens avatar kolya182 avatar krboktv avatar lorenzozanotto avatar madcake avatar pantani avatar prazd avatar ququzone avatar riptl avatar tolsi avatar vcoolish avatar vikmeup avatar vmtrue avatar yun-yeo avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.