Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Etherscan Backend

Overview

This project is a backend service for interacting with Ethereum blockchain data. It fetches block data and stores it in a MongoDB database for further analysis.

Features

  • Fetches the latest block from the Ethereum blockchain.
  • Provides details of the last ‘n’ blocks.
  • Retrieves account details of a particular address, including ETH balance and last ‘n’ transactions.
  • Fetches details of different ERC20 tokens provided their addresses.
  • All data is fetched from the Ethereum mainnet.
  • On server startup, it fetches the last 100 blocks and stores them in MongoDB. New blocks are added automatically to the database.
  • If the value of ‘n’ in the second requirement doesn’t exceed the number of blocks stored already in the database, data is fetched from the database itself.
  • Dockerized for easy deployment using docker-compose up.

Prerequisites

  • Node.js (version 14 or later)
  • npm (Node package manager)
  • MongoDB (for local development)
  • Docker (for containerized deployment)

Getting Started

Running Locally

  1. Clone the repository
  2. Install dependencies: npm install
  3. Create a .env file in the root directory with the following content:
  1. Start the application: npm run dev
  2. Access the application at http://localhost:3000.

Running with Docker

  1. Ensure Docker is installed and running on your machine.
  2. Build and start the containers: docker-compose up --build
  3. Access the application at http://localhost:3000.
  4. Connect to MongoDB using Compass at mongodb://localhost:27017/etherscan.

Testing Endpoints with Postman

You can test the following endpoints using Postman:

  1. Get Latest Block
  • Endpoint: GET /api/latest-block
  • Description: Retrieves the latest block information.
  1. Get Last n Blocks
  • Endpoint: GET /api/blocks/n
  • Description: Retrieves details of the last 'n' blocks.
  1. Get Account Details
  • Endpoint: GET /api/account/:address
  • Description: Retrieves account details including ETH balance and last 'n' transactions.
  1. Get ERC20 Token Details
  • Endpoint: GET /api/token/:address
  • Description: Retrieves details of a specific ERC20 token by its address.

Project Screenshots

  1. Application Running Locally:
1 2
  1. MongoDB Compass:
3
  1. Docker Logs:
4 5 6
  1. Docker Setup:
7
  1. Postman Testing:
8

About

Node.js server that acts as a backend to Etherscan

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages