ethereumhistory

ethereumhistory.com

A historical archive and analysis tool for Ethereum smart contracts, with a focus on the 2015-2017 era when standards were still forming.

This is not a trading site, block explorer, or dashboard. It is a long-term preservation effort — part museum, part research terminal, part Wikipedia for Ethereum’s earliest code.

Philosophy

Features

Contract Analysis

Bytecode Similarity

Historical Context

Tech Stack

Frontend

Backend

Analysis Pipeline

Project Structure

ethereumhistory/
├── src/
│   ├── app/                    # Next.js App Router pages
│   │   ├── page.tsx           # Homepage
│   │   ├── contract/
│   │   │   └── [address]/     # Contract detail page
│   │   └── api/               # API routes
│   ├── components/            # React components
│   ├── lib/                   # Utilities and DB queries
│   └── types/                 # TypeScript types
├── pipeline/
│   └── similarity/            # Python bytecode analysis
│       ├── normalize.py       # Bytecode normalization
│       ├── fingerprint.py     # Fingerprint generation
│       ├── similarity.py      # Similarity computation
│       ├── export.py          # Export to PostgreSQL
│       └── main.py            # CLI entry point
├── db/
│   └── schema.sql             # Database schema
├── seeds/
│   ├── sample_contracts.json  # Sample contract data
│   └── seed_database.sql      # Seed SQL
└── README.md

Getting Started

Prerequisites

Installation

  1. Clone and install dependencies
cd ethereumhistory
npm install
  1. Set up environment variables
cp .env.example .env.local
# Edit .env.local with your database URL

By default, if POSTGRES_URL is set the app will only use Postgres (and will not parse the large data/*.json files). If you explicitly want JSON fallback even when Postgres is configured, set:

ALLOW_JSON_FALLBACK=1
  1. Start PostgreSQL (recommended: Docker)
docker compose up -d

The Docker database listens on localhost port 5433 (so it won’t conflict with an existing local Postgres on 5432).

This will create a local database and run:

  1. Import the full dataset into PostgreSQL
npm run db:import

If you need to re-run init scripts:

docker compose down -v
docker compose up -d
  1. Run the development server
npm run dev

Open http://localhost:3000.

Bytecode Similarity Pipeline

The similarity pipeline runs offline to precompute relationships between contracts.

Setup

cd pipeline
python -m venv venv
source venv/bin/activate  # or venv\Scripts\activate on Windows
pip install -r requirements.txt

Running the Pipeline

From JSON file:

python -m similarity.main --input ../seeds/sample_contracts.json --output ./results

From database:

export POSTGRES_URL="postgresql://..."
python -m similarity.main --from-db --output ./results

Custom thresholds:

python -m similarity.main --input contracts.json --threshold 0.7 --max-matches 5 --output ./results

Output Files

Import to Database

psql "$POSTGRES_URL" -f results/contract_similarity.sql

Or use COPY:

COPY contract_similarity FROM 'results/contract_similarity.csv' WITH (FORMAT csv, HEADER true);

Similarity Algorithm

The similarity score is computed as:

similarity_score =
    0.70 * jaccard(opcode_ngrams)      # Primary: structural similarity
  + 0.20 * control_flow_similarity      # Secondary: behavioral similarity
  + 0.10 * shape_similarity             # Tertiary: size/complexity match

Thresholds

Why This Approach?

  1. Deterministic: Same input always produces same output
  2. Explainable: “These contracts share 87% of their opcode trigrams”
  3. Fast: O(n²) comparison, but n-gram sets are small
  4. Robust: Works even with different compiler versions or constants

API Routes

GET /api/contract/[address]

Returns full contract data including analysis and similar contracts.

GET /api/search?q=[address]

Quick lookup for an address.

GET /api/featured

Returns featured historical contracts for the homepage.

Database Schema

Key tables:

Contributing

Adding Historical Context

The most valuable contribution is adding historical narratives to contracts. These require research and should be:

Improving Detection

Pattern detection heuristics can always be improved. All heuristics should:

TODO

License

MIT

Acknowledgments


Ethereum has a history worth preserving.