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 a short summary for each day (check the Smart Contract repository).
Use it as a scalable boilerplate for communication with the Ethereum network and/or a learning resource.
- TypeScript,
- Koa.js,
- Database: MongoDB: Mongoose,
- Config: Dotenv, Joi,
- Testing: Jest: SuperTest, MongoDBMemoryServer,
- Docker: MongoDB, Redis.
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.
- Event:
- Clone the repo,
- Duplicate
.env.examplefiles in [./,/docker/] to.env; modify as needed, - Have
Dockerinstalled, run the containers and your app (check the instructions below), - Add modules (routes, controllers, services, tests) to
/src, - List newly added modules (features) here (Readme.md) and in your POSTMAN collection.
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.
- Watches for block creation, stores it in the local DB,
- For every created block: pulls all transactions and stores them in the local DB,
- For every day that passes: storing [
totalBlockAmount,totalGasAmount] in a simple Smart Contract, using Solidity.
Modules
- Network: start/stop network observation, calling Summary.sync on block creation,
- Block: CRUD,
- Summary: Calculation, Syncing with the Ethereum Network,
All API routes are prefixed by API_PREFIX (defined in.env) (default: /api).
Docker
Docker provides isolated MongoDB and Redis 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
Using Jest Testing Framework.
Jest uses SuperTest and MongoDBMemoryServer.
npm run test
Pre-set environment variables:
hostadmin_password
Dynamic environment variables, automatically set in tests:
access_token
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
- Message[Create,Update,Delete],
- [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_PASSWORDis defined in.envfile. - It defaults to
secret.
If you use MongoDB Atlas: Uncomment and fill DB_URI in .env.
Andromeda
Hero image source: EthereumPrice.org.
π Ethereum Observer - Smart Contract - Hardhat, TypeScript
- Simple
Ethereum Smart Contractthat stores aDaily Summaryof Ethereum Observer API, - TypeScript,
- Hardhat,
- Solidity,
- Ethers.js,
- Waffle.
π 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.
Check Self-Aware Software Artisan before contributing.