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.
Copy ./mainnet.env.example
to ./.env
and define environment variables
yarn
yarn start
docker build .
# map ports
docker run -p 8000:8000 -p 3002:3002 -p 3001:3001
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
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
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
related transactions (with filters)
/v0/shard/0/address/:address/transactions
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
Hit http://localhost:3001 for dev web page
Check the controllers files for method names and params
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'"