Giter VIP home page Giter VIP logo

mintscan-binance-dex-backend's Introduction

All Contributors

Cosmostation logo

Mintscan Explorer's Backend for Binance Chain

⭐ Developed / Developing by Cosmostation

Overview

This project is sponsored by Binance X Fellowship Program. The program supports talented developers and researchers in creating free and open-source software that would enable new innovations and businesses in the crypto community.

This repository provides backend code for Mintscan Block Explorer for Binance Chain, and you can find frontend code in this repository.

Note that this repository has just transitioned from the actively developing phase to the maintaining phase starting from the first official version v1.0.0. All intended functionality is implemented; however, it can always go back when there is a reason to go back.

Prerequisite

Folder Structure

/
|- chain-exporter
|- mintscan
|- stats-exporter

Chain Exporter

chain-exporter watches a full node of Binance Chain and export chain data into PostgreSQL database.

Mintscan

mintscan provides any necesarry custom APIs.

Stats Exporter

stats-exporter creates cron jobs to export market data to build chart history API.

Configuration

For configuration, it uses human readable data-serialization configuration file format called YAML.

To configure chain-exporter | mintscan | stats-exporter, you need to configure config.yaml file in each folder. Reference example.yaml.

Note that the configuration needs to be passed in via config.yaml file, so make sure to change the name to config.yaml.

Install

Git clone this repo

git clone https://github.com/cosmostation/mintscan-binance-dex-backend.git

Build by Makefile

cd mintscan-binance-dex-backend/chain-exporter
make build

cd mintscan-binance-dex-backend/mintscan
make build

cd mintscan-binance-dex-backend/stats-exporter
make build

Database

This project uses Golang ORM with focus on PostgreSQL features and performance. Once chain-exporter begins to run, it creates the following database tables if not exist already.

  • Block
  • PreCommit
  • Transaction
  • Validator

Contributing

We encourage and support an active, healthy community of contributors — any contribution, improvements, and suggestions are always welcome! Details are in the contribution guide

Contributors ✨

Thanks goes to these wonderful people (emoji key):


JayB

💻 📖 📆 ⚠️ 🚧

fl-y

💻 🤔

hyeryeong-lim

🎨

This project follows the all-contributors specification. Contributions of any kind welcome!

Our Services and Community

License

Released under the Apache 2.0 License.

mintscan-binance-dex-backend's People

Contributors

allcontributors[bot] avatar carameleon avatar jaybxyz avatar jeongseup avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

mintscan-binance-dex-backend's Issues

Build custom API for asset

Summary

At the time of this writing, there are 181 tokens listed on Binance Chain. In order to build "Asset" page in our Mintscan, custom API is needed to be built which provide necessary data following how it is designed.

This API returns tokens list and it has only the following parameters:

  • Mintable
  • Name
  • Original Symbol
  • Owner
  • Symbol
  • Total Supply

Params that further needed

  • Asset Price
  • Asset Detail Info like social profiles and description (if possible)
  • Asset Holders
  • Asset Image / Logo

Note: asset image can be found from this repo

Decision

For now, we decided to use an official explorer asset API although it is not for public use I believe.
We will need to find a way to gather necessary data to build our own custom API for this.

Performance Issue when counting all txs saved in DB

Issue

There is performance Issue when counting all transactions which are saved in database.
As there will be more transactions to count as time goes, this problem needs to be solved.

Possible solution

  1. Create a cron job that counts transactions and save it in other table.

Support Documenting APIs with Swagger

Summary

Having a meaningful documentation of APIs is important for other users; however, this is not an imminent issue right now. This feature will be supported later.

Generate Swagger docs for Documenting Mintscan APIs.

Migrating the APIs that rely on Binance Explorer API

Migrating the APIs that rely on Binance Explorer API

Migration for the below APIs is needed since their explorer API is not public.

  • Asset API
  • Assets API
  • AssetHolders API
  • AccountTxs API

We decided to use those APIs at first because of the following reasons.

  • We had hard time getting some of the data from HTTP API and API Server.
  • We simply thought why not using Explorer API since HTTP API itself is also controlled and operated by Binance team.

In the long run, these APIs should be migrated. It is good for our Mintscan for Binance Chain and Binance Explorer API server.

Improve single point of failure for RPC node

Summary

The title itself is self-explanatory. Chain Exporter needs to be prevented from a single point of failure meaning that when one RPC node is down, it should try to connect to other RPC nodes.

Problem Definition

A public RPC node that is available by Binance team is sometimes down for handling heavy traffic.

Describe the solution you'd like

Add support to reconnect to other RPC nodes when one it down.

Cannot start chain-exporter

config.yaml

network_type: "testnet"

mainnet:
  node: 
    rpc_node: "tcp://localhost:26657/" # tcp://dataseed1.binance.org:80
    accelerated_node: "http://localhost:1317/" # https://dex-asiapacific.binance.org/api/v1
    api_server_endpoint: "http://localhost:1317/"
    explorer_server_endpoint: "https://explorer.binance.org/api/v1" # https://explorer.binance.org/api/v1
  database:
    host: "localhost"
    port: 5432
    user: "postgres"
    password: "1234"
    table: ""
  market:
    coingecko_endpoint: ""

testnet:
  node: 
    rpc_node: "tcp://localhost:26657" # tcp://dataseed1.binance.org:80
    accelerated_node: "http://192.168.1.112:1317" # https://dex-asiapacific.binance.org/api/v1
    api_server_endpoint: "http://192.168.1.112:1317"
    explorer_server_endpoint: "https://explorer.binance.org/api/v1"
  database:
    host: "localhost"
    port: 5432
    user: "postgres"
    password: "1234"
    table: ""
  market:
    coingecko_endpoint: ""

error

Chain Exporter 2022/03/02 00:50:37 exporter.go:76: Starting Chain Exporter...
Chain Exporter 2022/03/02 00:50:37 exporter.go:77: Version: 1.2.0-16-g9ae4ea1 | Commit Hash: 9ae4ea1dd0babbdda46ebade497156f47cee413b
Chain Exporter 2022/03/02 00:50:37 exporter.go:81: start - sync blockchain
panic: http: invalid pattern

goroutine 61 [running]:
net/http.(*ServeMux).Handle(0x51311e0, {0x0, 0x0}, {0x4b62960, 0xc000611dd0})
        /usr/local/go/src/net/http/server.go:2435 +0x24c
net/http.Handle(...)
        /usr/local/go/src/net/http/server.go:2484
github.com/cosmostation/mintscan-binance-dex-backend/chain-exporter/prometheus.StartMetricsScraping({{0x0, 0x0}, {0x0, 0x0}, {0x0, 0x0}})
        /Users/jarupaksrisuchat/Documents/github/mintscan-binance-dex-backend/chain-exporter/prometheus/metrics.go:38 +0x65
created by github.com/cosmostation/mintscan-binance-dex-backend/chain-exporter/exporter.NewExporter
        /Users/jarupaksrisuchat/Documents/github/mintscan-binance-dex-backend/chain-exporter/exporter/exporter.go:63 +0x32b

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.