Skip to content
Clean and lightweight cross-chain transaction API
Go Makefile Dockerfile
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github Update issue templates Aug 30, 2019
cmd avoid try to save empty addresses for xpub (#362) Sep 16, 2019
coin Add min confirmations (#351) Sep 13, 2019
config Change all logs to new log package (#335) Sep 10, 2019
observer Add min confirmations (#351) Sep 13, 2019
pkg Fix integration tests (#336) Sep 10, 2019
platform create collectionId field (#363) Sep 17, 2019
services/assets Add validators list to Tron platform (#341) Sep 12, 2019
test Change all logs to new log package (#335) Sep 10, 2019
util [Vechain] Increaase blockTime and add address checksum (#258) Aug 13, 2019
.editorconfig Add .editorconfig Mar 13, 2019
.gitignore Refactor Bitcoin transactions API (#260) Aug 15, 2019
CODE_OF_CONDUCT.md Add CODE_OF_CONDUCT Apr 14, 2019
Dockerfile Remove redundant default configs in favore of config.yml. Update read… Sep 7, 2019
LICENSE Create LICENSE Mar 17, 2019
Makefile Add integration tests (#304) Sep 9, 2019
Procfile Update Heroku settings Jun 19, 2019
README.md Add structured logs and sentry support (#324) Sep 10, 2019
api.go Tron token transactions (#349) Sep 12, 2019
app.json Update Heroku settings Jun 19, 2019
azure-pipelines.yml Add integration tests (#304) Sep 9, 2019
block.go Reformatted sources to standard output with gofmt (#185) Jul 28, 2019
client.go remove headers for cliente request (#365) Sep 17, 2019
coins.yml Add min confirmations (#351) Sep 13, 2019
collectibles.go create collectionId field (#363) Sep 17, 2019
config.yml Add missing sentry config (#356) Sep 14, 2019
errors.go Start refactoring: Interfaces for platforms Jun 19, 2019
go.mod Add structured logs and sentry support (#324) Sep 10, 2019
go.sum Add structured logs and sentry support (#324) Sep 10, 2019
marshal.go [Observer] Add Cosmos support for BlockAPI (#226) Aug 13, 2019
marshal_test.go Reformatted sources to standard output with gofmt (#185) Jul 28, 2019
staking.go Adopt Tezos platform to new client + add validators list to staking (#… Sep 4, 2019
tx.go create the Tx `TransactionType` (#332) Sep 10, 2019
txset.go [BlockAtlas#175] Add bitcoin support (#195) Aug 5, 2019

README.md

Block Atlas by Trust Wallet

Build Status Codacy Badge Go Report Card

Clean explorer API and events observer for crypto currencies.

Supported Coins

Setup

Quick start

Deploy it in less than 30 seconds!

Prerequisite

  • GO 1.12+
  • Locally running Redis or url to remote instance (required for Observer only)

From Source (Go Toolchain required)

go get -u github.com/trustwallet/blockatlas
cd blockatlas

// Start API server
go build -o blockatlas ./cmd && ./blockatlas api

//Start Observer
go build -o blockatlas ./cmd && ./blockatlas observer

Docker

Using Docker Hub:

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

Build and run from local Dockerfile: docker build -t blockatlas . docker run -p 8420:8420 blockatlas

Tools

  • Setup Redis
brew install redis // Install Redis using Homebrew
ln -sfv /usr/local/opt/redis/*.plist ~/Library/LaunchAgents  // Enable Redis autostart
  • Running in the IDE ( GoLand )
  1. Run
  2. Edit configuration
  3. New Go build configuration
  4. Select directory as configuration type
  5. Set api as program argument and -i as Go tools argument

Deploy

Supported platforms

Deploy

Docker

Block Atlas can run just fine without configuration.

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

By default, config.yml is loaded from the working directory.

Example (config.yml):

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

Environment

The rest gets loaded from the environment variables. Every config option is available under the ATLAS_ prefix.

Example:

ATLAS_NIMIQ_API=http://localhost:8648 \
blockatlas

Tests

Unit

To run the unit tests: make test

Integration

All integration tests are generated automatically. You only need to set the environment to your coin in the config file. The tests use a different build constraint, named integration.

To run the integration tests: make integration

or you can run manually: TEST_CONFIG=$(TEST_CONFIG) TEST_COINS=$(TEST_COINS) go test -tags=integration -v ./pkg/integration

Fixtures
  • If you need to change the parameters used in our tests, update the file pkg/integration/testdata/fixtures.json

  • To exclude an API from integration tests, you need to add the route inside the file pkg/integration/testdata/exclude.json

    E.g.:

[
  "/v2/ethereum/collections/:owner",
  "/v2/ethereum/collections/:owner/collection/:collection_id"
]

Logs

Use the package pkg/logger for logs.

E.g.:

  • Log message: logger.Info("Loading Observer API")

  • Log message with params: logger.Info("Running application", logger.Params{"bind": bind})

  • Fatal with error: logger.Fatal("Application failed", err)

  • The method parameters don't have a sort. You just need to pass them to the method: logger.Fatal(err, "Application failed")

  • Create a simple error log: logger.Error(err)

  • Create an error log with a message: logger.Error("Failed to initialize API", err)

  • Create an error log, with error, message, and params:

p := logger.Params{
	"platform": handle,
	"coin":     platform.Coin(),
}
err := platform.Init()
if err != nil {
	logger.Error("Failed to initialize API", err, p)
}
  • Debug log: logger.Debug("Loading Observer API") or logger.Debug("Loading Observer API", logger.Params{"bind": bind})

  • Warning log: logger.Warn("Warning", err) or logger.Warn(err, "Warning") or logger.Warn("Warning", err, logger.Params{"bind": bind})

Authors

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.

You can’t perform that action at this time.