All Projects → trustwallet → Blockatlas

trustwallet / Blockatlas

Licence: mit
Clean and lightweight cross-chain transaction API

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to Blockatlas

Covenantsql
A decentralized, trusted, high performance, SQL database with blockchain features
Stars: ✭ 1,148 (+579.29%)
Mutual labels:  blockchain, crypto
Blockchain golang
Blockchain demo based on golang 基于golang编写的区块链公链demo
Stars: ✭ 80 (-52.66%)
Mutual labels:  blockchain, crypto
Cava
ConsenSys core libraries for Java & Kotlin
Stars: ✭ 71 (-57.99%)
Mutual labels:  blockchain, crypto
Crypto Supplies
Cryptocurrency circulating, maximum and total supplies
Stars: ✭ 26 (-84.62%)
Mutual labels:  blockchain, crypto
Eostracker
🗄EOS Tracker: Real time block explorer for EOS Blockchain
Stars: ✭ 166 (-1.78%)
Mutual labels:  blockchain, crypto
Pocket Core
Official implementation of the Pocket Network Protocol
Stars: ✭ 50 (-70.41%)
Mutual labels:  blockchain, crypto
Mailchain
Using Mailchain, blockchain users can now send and receive rich-media HTML messages with attachments via a blockchain address.
Stars: ✭ 74 (-56.21%)
Mutual labels:  blockchain, crypto
Awesome Blockchain
Curated list of blockchain services and exchanges 🔥🏦🔥🏦🔥🏦🔥
Stars: ✭ 604 (+257.4%)
Mutual labels:  blockchain, crypto
Esteem Surfer
Ecency desktop formerly known as Esteem Surfer - reimagined desktop social wallet, contribute and get rewarded (for Windows, Mac, Linux)
Stars: ✭ 100 (-40.83%)
Mutual labels:  blockchain, crypto
Etherwalletkit
Ethereum Wallet Toolkit for iOS - You can implement an Ethereum wallet without a server and blockchain knowledge.
Stars: ✭ 96 (-43.2%)
Mutual labels:  blockchain, crypto
Aeternity
æternity: solving scalability problems by making sense of state-channels
Stars: ✭ 923 (+446.15%)
Mutual labels:  blockchain, crypto
Coco
The fastest crypto online
Stars: ✭ 103 (-39.05%)
Mutual labels:  blockchain, crypto
Maskbook
The portal to the new, open internet. ([I:b])
Stars: ✭ 691 (+308.88%)
Mutual labels:  blockchain, crypto
The Journal Of Blockchain
区块链自媒体、专注区块链技术学习和实践、IPFS/Filecoin、Bitcoin、Ethereum、EOS、Cosmos、区块链、白皮书、Coinmarketcap、Coindesk、Safe Network、Telegram、Docker、社会治理、经济激励
Stars: ✭ 63 (-62.72%)
Mutual labels:  blockchain, crypto
Wallet Core
Cross-platform, cross-blockchain wallet library.
Stars: ✭ 657 (+288.76%)
Mutual labels:  blockchain, crypto
Use Dai
💸 A curated, community compiled list of everywhere you can use the decentralized Dai stablecoin
Stars: ✭ 74 (-56.21%)
Mutual labels:  blockchain, crypto
Scatterdesktop
Connect to applications on EOS, Ethereum, and Tron. Exchange tokens with ease. Manage your assets safely. All in a simple to use interface.
Stars: ✭ 459 (+171.6%)
Mutual labels:  blockchain, crypto
Iotex Core
Official implementation of IoTeX blockchain protocol in Go.
Stars: ✭ 505 (+198.82%)
Mutual labels:  blockchain, crypto
Dapp
Censorship resistant democracies.
Stars: ✭ 1,326 (+684.62%)
Mutual labels:  blockchain, crypto
Ecency Mobile
Ecency Mobile - reimagined social blogging, contribute and get rewarded (for Android and iOS)
Stars: ✭ 103 (-39.05%)
Mutual labels:  blockchain, crypto

Block Atlas by Trust Wallet

Go Version CI codecov Go Report Card Dependabot Status

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. 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 guids.

Supported Coins

Block Atlas supports more than 25 blockchains: Bitcoin, Ethereum, Binance Chain etc, The full feature matrix is here.

Architecture

NOTE

Currently Block Atlas is under active development and is not well documented. If you still want to run it on your own or help to contribute, please pay attention that currently integration, nemwan, functional tests are not working locally without all endpoints. We are fixing that issue and soon you will be able to test all the stuff locally

Blockatlas allows to:

  • Get information about transactions, tokens, staking details, collectibles for supported coins.
  • Subscribe for price notifications via Rabbit MQ

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.

Setup

Prerequisite

  • Go Toolchain versions 1.14+

    Depends on what type of Blockatlas service you would like to run will also be needed.

  • Postgres to store user subscriptions and latest parsed block number

  • Rabbit MQ to pass subscriptions and send transaction notifications

Quick Start

Get source code

Download source to GOPATH

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

Build and run

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

make command

Build and start all services:

make go-build
make start

Build and start individual service:

make go-build-api
make start

Docker

Build and run all services:

docker-compose build
docker-compose up

Build and run individual service:

docker-compose build api
docker-compose start api

Configuration

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

Environment

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

Tests

Unit tests

make test

Mocked tests

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.

  • External mocks are implemented as a simple, own, golang mockserver. It listens locally, and returns responses to specific API paths, taken from json data files.
  • There is a file where API paths and corresponding data files are listed.
  • Tests invoke into blockatlas through public APIs only, and are executed using newman (Postman cli -- make newman-mocked).
  • Product code, and even test code should not be aware whether it runs with mocks or the real external endpoints.
  • See Makefile for targets with 'mock'; platform can be started locally with mocks using make start-platform-api-mock.
  • The newman tests can be executed with unmocked external APIs as well, but verifications may fail, because some APIs return variable responses. Unmocked tests are not intended for regular CI execution, but as ad-hoc development tests.
  • General steps for creating new mocked tests: replace endpoint to localhost:3347, observe incoming calls (visible in mockserver's output), obtain real response from external API (with exact same parameters), place response in a file, add path + file to data file list. Restart mock, and verify that blockatlas provides correct output. Also, add verifications of results to the tests.

Docs

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

Updating Docs

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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].