You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
Diego Nava d72816143d
Merge pull request #111 from ArtemKolodko/add_total_fee_metrics
1 year ago
data 1.01 3 years ago
doc Add total fee daily metrics 1 year ago
src Restore blocks indexer 1 year ago
.dockerignore 1.01 3 years ago
.eslintrc 1.01 3 years ago
.gitignore fix gaps script 3 years ago
.prettierrc 1.01 3 years ago
Dockerfile Add python to Dockerfile (#55) 3 years ago
README.md Add link to Explorer 2 years ago
mainnet.env.example shard1 contract indexer, delete old internal transactions over 7 days (#93) 2 years ago
nodemon.json 1.01 3 years ago
package.json Add fix-missing-internal script 2 years ago
price-abi.json shard1 contract indexer, delete old internal transactions over 7 days (#93) 2 years ago
testnet.env.example 1.01 3 years ago
tsconfig.json Remove x00 characters on contract create; Update typescript version (#53) 3 years ago
webpack.config.js 1.01 3 years ago
yarn.lock Revert lru cache update (#71) 2 years ago

README.md

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