Git Product home page Git Product logo

ethereum-observer-api's Introduction

Ethereum Observer API

Ethereum Observer API

Simple tracker for Ethereum Network
https://ethereum-observer-api.andromeda.technology

Simple block and transaction tracker for Ethereum network.

Uses a Smart Contract to save short summary for each day.

1. Technology

Blockchain

  • Ethereum,
  • Smart Contract: Solidity,
    • only this app can write to the Contract,
    • anyone can read it's state.

Communication with the Ethereum Network

  • Using ethers.js for calls to Ethereum network,
  • Subscribing to events,
    • Event: block: new block is mined.

2. Usage

  1. Clone the repo,
  2. Duplicate .env.example files in [./,/docker/] to .env; modify as needed,
  3. Have Docker installed, run the containers and your app (check the instructions below),
  4. Add modules (routes, controllers, services, tests) to /src,
  5. List newly added modules (features) here (Readme.md) and in your POSTMAN collection.

2.1. Starting/stopping the observer

Observed data will be saved to the local database, and later - to a Smart Contract, as a daily summary.

  • Start: POST [API_PREFIX]/network
  • Stop: DELETE [API_PREFIX]/network

[API_PREFIX] is defined in .env; defaults to /api .

Note: Use the Postman Collection linked below.

3. Features

  1. Watches for block creation, stores it in the local DB,
  2. For every created block: pulls all transactions and stores them in the local DB,
  3. For every day that passes: storing [totalBlockAmount,totalGasAmount] in a simple Smart Contract, using Solidity.

Modules

  1. Network: start/stop network observation,
  2. Block,

All API routes are prefixed by API_PREFIX (defined in.env) (default: /api).

4. Setup

Docker

Docker provides isolated MongoDB for your project.

cd ./docker

# Duplicate example env file, modify as needed
cp .env.example .env

docker-compose up -d

Application

# Return from `docker` to root dir
# cd ..

# Duplicate example env file, modify if needed
cp .env.example .env

# Install packages
npm i

# Run
npm run dev

5. Tests

Using Jest Testing Framework.

Jest uses SuperTest and MongoDBMemoryServer.

npm run test

6. Postman

Postman Documentation

Pre-set environment variables:

  • host
  • admin_password

Dynamic environment variables, automatically set in tests:

  • access_token

7. Admin Routes

Routes can be protected with jwtCheck middleware, requiring admin rights.

Requests going to these routes require Authorization: Bearer {access_token} header.

List of protected, i.e. Admin Routes

  1. Message[Create,Update,Delete],
  2. [Add your protected routes here]

Getting access_token for the Admin user

  • Request endpoint: POST /auth/token,
  • Pass your password in the request body: { password: ADMIN_PASSWORD },
  • Response will return created token.

Note: Postman collection will automatically set access_token environment variable, so you can immediately call admin routes, without copy-pasting it or setting the env variable manually.

Getting the ADMIN_PASSWORD

  • Your ADMIN_PASSWORD is defined in .env file.
  • It defaults to secret.

8. Deployment

If you use MongoDB Atlas: Uncomment and fill DB_URI in .env.

9. Social

Andromeda

10. Rest

Hero image source: EthereumPrice.org.

11. Related

๐Ÿš€ FireStarter API - Progressive Startup API Boilerplate

  • Easy to extend, Progressive and Scalable API boilerplate to power your startup,
  • TypeScript,
  • Koa.js,
  • MongoDB,
  • Jest,
  • Docker.

๐Ÿ„ Habitus - Journal, Habit, Emotion tracker

  • State-of-the-art tracker for emotions, habits and thoughts,
  • Healthiest version of you,
  • Gamified,
  • Anonymous and open source.

12. Contribute

Check Self-Aware Software Artisan before contributing.


Crafted with โค๏ธ
by contributors around the ๐ŸŒ World and ๐ŸŒŒ Andromeda.

ethereum-observer-api's People

Contributors

moltouni avatar

Watchers

 avatar  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.