Git Product home page Git Product logo

explorer-v2-backend's Introduction

Harmony Blockchain Data Indexer

Indexer scrapes blocks, transactions (staking, call traces, logs), tracks contracts, ERC20 (aka HRC20) and ERC721 (aka HRC721) operations and balances from Harmony blockchain and writes to postgres db.

API serves REST/JSON and websocket. Also, here is initial draft for GRPC. Will be implemented fully on community demand. Current data can be viewed at Harmony Block Explorer.

Possible to switch off API and keep active only Indexer and vice-versa.

Run

Define env variables

Copy ./mainnet.env.example to ./.env and define environment variables

Development mode

yarn
yarn start

Production mode

Docker

docker build .
# map ports
docker run -p 8000:8000 -p 3002:3002 -p 3001:3001

Indexer

Postgres scheme image info

API

REST API

Block

list (with filters) /v0/shard/0/block

By hash /v0/shard/0/block/hash/:hash

By number /v0/shard/0/block/number/:number

Approximate count /v0/shard/0/block/count

Transaction

list (with filters) /v0/shard/0/transaction

by ETH hash or Harmony hash /v0/shard/0/transaction/hash/:hash

by block number /v0/shard/0/transaction/block/number/:number

by block hash /v0/shard/0/transaction/block/hash/:blockHash

Approximate count /v0/shard/0/transaction/count

Staking Transaction

list (with filters) /v0/shard/0/stakingTransaction

by Harmony hash /v0/shard/0/stakingTransaction/hash/:txHash

by block number /v0/shard/0/stakingTransaction/block/number/:blockNumber

by block hash /v0/shard/0/stakingTransaction/block/hash/:blockHash

Approximate count /v0/shard/0/stakingTransaction/count

Address

related transactions (with filters) /v0/shard/0/address/:address/transactions

Filters

as GET params

orderBy: number for blocks | block_number for txs

orderDirection: asc | desc

offset: number

limit: number (max 100)

Composite filters (at the moment only single condition supported)

type: gt | gte | lt | lte

property: number | block_number (will be more in the future)

value: value

Example /v0/shard/0/block?limit=2&offset=0&orderBy=number&orderDirection=asc&type=gt&property=number&value=40

Websocket Socket.IO

Hit http://localhost:3001 for dev web page

Check the controllers files for method names and params

GRPC

Proto files

Query

Using GRPC CLI

Install

brew install grpc

Query

grpc_cli --protofiles=src/api/grpc/proto/api.proto call 127.0.0.1:5051 GetBlockByNumber "blockNumber: 1, shardID: 0"
grpc_cli --protofiles=src/api/grpc/proto/api.proto call 127.0.0.1:5051 GetBlockByHash "shardID:0, blockHash:'0xb4d158b82ac8a653c42b78697ab1cd0c6a0d9a15ab3bc34130f0b719fb174d2a'"

TODO

Indexer

  • Index Blocks
  • Index Transactions
  • Index Staking Transactions
  • Index Events
  • Track transactions for Address
  • Index Transactions Trace Calls
  • Index Internal Transactions
  • Detect Contracts
  • Track HRC20
  • Track HRC721
  • Track Balances
  • Contract Verification
  • Methods/Events signature db

REST

  • Blocks
  • Transactions
  • Staking Transactions
  • Internal Transactions
  • Addresses
  • Metrics
  • ERC20 tokens
  • ERC721 tokens
  • Documentation

Misc

  • Docker image

explorer-v2-backend's People

Contributors

artemkolodko avatar hypnagonia avatar onecasey avatar diego1q2w avatar aishlia 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.