-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Creates new package for rest api explorer endpoints
Signed-off-by: Konstantina Blazhukova <[email protected]>
- Loading branch information
1 parent
11e1f1e
commit 7f366e5
Showing
3 changed files
with
142 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
# Hedera HTTP Explorer Server | ||
|
||
This package provides REST API endpoints for exposing EVM-centric data from the Hedera network, similar to Etherscan's API. It supports querying token transfers for ERC20, ERC721, and ERC1155 tokens, as well as fetching tokens owned by an address. | ||
|
||
## Features | ||
|
||
- ERC20 token transfer events | ||
- ERC721 NFT transfer events | ||
- ERC1155 multi-token transfer events | ||
- Tokens owned by an address | ||
- Pagination support | ||
- Block range filtering | ||
- Address filtering | ||
- Contract filtering | ||
|
||
## API Endpoints | ||
|
||
### Token Transfers | ||
|
||
Get ERC20 token transfers: | ||
``` | ||
GET /api?module=account&action=tokentx&address={address}&contractaddress={contractaddress}&startblock={startblock}&endblock={endblock}&page={page}&offset={offset}&sort={asc|desc} | ||
``` | ||
|
||
Get ERC721 (NFT) token transfers: | ||
``` | ||
GET /api?module=account&action=tokennfttx&address={address}&contractaddress={contractaddress}&startblock={startblock}&endblock={endblock}&page={page}&offset={offset}&sort={asc|desc} | ||
``` | ||
|
||
Get ERC1155 token transfers: | ||
``` | ||
GET /api?module=account&action=token1155tx&address={address}&contractaddress={contractaddress}&startblock={startblock}&endblock={endblock}&page={page}&offset={offset}&sort={asc|desc} | ||
``` | ||
|
||
### Account Tokens | ||
|
||
Get tokens owned by an address: | ||
``` | ||
GET /api/account/{address}/tokens?page={page}&offset={offset} | ||
``` | ||
|
||
## Installation | ||
|
||
```bash | ||
npm install | ||
npm run build | ||
``` | ||
|
||
## Usage | ||
|
||
```bash | ||
npm start | ||
``` | ||
|
||
## Configuration | ||
|
||
The server can be configured through environment variables: | ||
|
||
- `PORT` - Server port (default: 3000) | ||
- `HOST` - Server host (default: localhost) | ||
- `RATE_LIMIT` - Rate limiting configuration | ||
- `PAGINATION_DEFAULT_SIZE` - Default page size (default: 100) | ||
- `PAGINATION_MAX_SIZE` - Maximum page size (default: 1000) | ||
- `MAX_BLOCK_RANGE` - Maximum block range for queries (default: 1000) | ||
- `REDIS_URL` - Redis connection URL for caching | ||
|
||
## Development | ||
|
||
```bash | ||
# Install dependencies | ||
npm install | ||
|
||
# Build | ||
npm run build | ||
|
||
# Run tests | ||
npm test | ||
|
||
# Lint | ||
npm run lint | ||
|
||
# Fix linting issues | ||
npm run lint:fix | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{ | ||
"name": "@hashgraph/http-explorer-server", | ||
"version": "0.1.0", | ||
"description": "HTTP server exposing Etherscan-like REST APIs for Hedera network", | ||
"main": "dist/index.js", | ||
"scripts": { | ||
"build": "tsc", | ||
"clean": "rimraf dist/", | ||
"start": "node dist/index.js", | ||
"lint": "eslint . --ext .ts", | ||
"lint:fix": "eslint . --ext .ts --fix" | ||
}, | ||
"dependencies": { | ||
"@hashgraph/json-rpc-relay": "file:../relay", | ||
"@koa/cors": "^4.0.0", | ||
"koa": "^2.14.2", | ||
"koa-bodyparser": "^4.4.1", | ||
"koa-router": "^12.0.0", | ||
"pino": "^8.15.0", | ||
"pino-pretty": "^10.2.0", | ||
"prom-client": "^14.2.0" | ||
}, | ||
"devDependencies": { | ||
"@types/koa": "^2.13.8", | ||
"@types/koa__cors": "^4.0.0", | ||
"@types/koa-bodyparser": "^4.3.10", | ||
"@types/koa-router": "^7.4.4", | ||
"@types/node": "^20.5.7", | ||
"@typescript-eslint/eslint-plugin": "^6.5.0", | ||
"@typescript-eslint/parser": "^6.5.0", | ||
"eslint": "^8.48.0", | ||
"rimraf": "^5.0.1", | ||
"typescript": "^5.2.2" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"compilerOptions": { | ||
"composite": true, | ||
"target": "es6", | ||
"lib": [ | ||
"es6" | ||
], | ||
"module": "commonjs", | ||
"rootDir": "src/", | ||
"moduleResolution": "node", | ||
"outDir": "./dist", | ||
"esModuleInterop": true, | ||
"allowSyntheticDefaultImports": true, | ||
"forceConsistentCasingInFileNames": true, | ||
"noImplicitAny": false, | ||
"declaration": true, | ||
"strict": true, | ||
"sourceMap": true | ||
}, | ||
"include": [ | ||
"src" | ||
] | ||
} |