Skip to content

Romanafanasyev/blockchain-gateway

Repository files navigation

Blockchain Gateway

HTTP API на NestJS, которое проксирует запросы к узлам EVM и Cosmos.

Быстрый старт

Требования: Node 18.20.4, npm, git.

git clone https://github.com/Romanafanasyev/blockchain-gateway.git
cd blockchain-gateway
npm install
cp .env.example .env
npm run start:dev

Swagger: http://localhost:3000/docs
Health:

curl http://localhost:3000/health

Эндпоинты

  • GET /evm/block/:height
    Вход: height целое число >= 0
    Выход: height, hash, parentHash, gasLimit, gasUsed, size

  • GET /evm/transactions/:hash
    Вход: 0x + 64 hex
    Выход: hash, to, from, value, input, maxFeePerGas, maxPriorityFeePerGas, gasPrice

  • GET /cosmos/block/:height
    Вход: height целое число >= 0
    Выход: height, time, hash, proposedAddress

  • GET /cosmos/transactions/:hash
    Вход: 64 hex без 0x Выход: hash, height, time, gasUsed, gasWanted, fee, sender

Примеры

EVM:

curl http://localhost:3000/evm/block/175136924
curl http://localhost:3000/evm/transactions/0x1b14ec07580efe24d4c040481164be74656294ce276639c88b02d9d46e824120

Cosmos:

curl http://localhost:3000/cosmos/block/175140829
curl http://localhost:3000/cosmos/transactions/137004447D9D62246A396371C32B85B2C2B299DB7B156408D7A2E33A5C9E8BF7

Структура проекта

/
  README.md
  .env.example
  package.json
  tsconfig*.json
  nest-cli.json

/src
  main.ts              - bootstrap, ValidationPipe, Swagger
  app.module.ts        - сборка модулей

  /common
    common.module.ts   - общие провайдеры
    logger/            - winston + ротация, http-лог
    filters/           - формат ошибок
    pipes/             - PositiveInt, Evm/Cosmos hash
    utils/             - evm hex utils

  /evm
    evm.controller.ts      - /evm/* + swagger
    evm.service.ts         - маппинг, 1 rpc на блок
    evm.rpc.service.ts     - JSON-RPC клиент
    types/                 - rpc/view типы, константы

  /cosmos
    cosmos.controller.ts   - /cosmos/* + swagger
    cosmos.service.ts      - маппинг
    cosmos.rpc.service.ts  - /block (+fallback /commit), tx REST
    types/                 - rpc типы

  /health
    health.controller.ts   - /health

/test
  unit/                - pipes, evm, cosmos
  e2e/                 - health, evm, cosmos

Тесты

npm run test
npm run test:e2e

Ссылки

About

Единое HTTP API к EVM и Cosmos для блоков и транзакций

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors