Skip to content

Go tool to extract all USDC token transfers in a given Ethereum mainnet block and save them into an SQLite DB

License

Notifications You must be signed in to change notification settings

SashaZezulinsky/block-scout

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Block Scout

Block Scout is a Go-based application that allows you to interact with the Ethereum blockchain to extract and store data related to USDC transfers in a SQLite database

Project Structure

The project is organized as follows:

block-scout/
├── cmd/                     # Main application entry point
│   └── main.go              # Main executable code for running the application
├── internal/
│   ├── db/                  # DB package for interacting with SQLite
│   │   ├── db.go            # DB connection and operations
│   │   ├── db_test.go       # DB connection and operations tests
│   ├── eth/                 # Ethereum client package for blockchain interaction
│   │   ├── eth.go           # Ethereum client to connect and fetch tx data
│   │   ├── eth_test.go      # Ethereum client connection and data fetching tests
│   ├── models/              # Models representing the data structure
│   │   ├── transfer.go      # Transfer model representing a USDC transfer
├── go.mod                   # Go module dependencies
├── go.sum                   # Go module checksums
├── LICENSE                  # License file
├── README.md                # Project documentation (this file)

Prerequisites

  • Go 1.16 or higher
  • Ethereum node RPC URL (Infura, Alchemy, or self-hosted)

Installation

Clone the repository:

git clone https://github.com/SashaZezulinsky/block-scout.git
cd block-scout

Install the necessary Go modules:

go mod tidy

Usage

To run the application, use the following command:

export ETH_RPC_URL=https://mainnet.infura.io/v3/YOUR_INFURA_PROJECT_ID
go run cmd/main.go -block <block_number> -db <path_to_database_file>

Command Line Arguments

  • -block (required): The block number to fetch real USDC transfers from.
  • -db (optional): Path to the SQLite database file. Default is ./transfers.db.

Environment Variables

  • ETH_RPC_URL (required): The URL of your Ethereum node RPC (e.g., from Infura or Alchemy).

Example

Run the following command to get USDC transfers for a specific block number and save them to a database:

ETH_RPC_URL=https://mainnet.infura.io/v3/YOUR_INFURA_PROJECT_ID go run cmd/main.go -block 12345678 -db transfers.db

This will connect to the Ethereum node, extract the USDC transfers from the specified block, store them in the specified database, and print out the stored data.

Testing

To run the unit tests:

make test

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

Go tool to extract all USDC token transfers in a given Ethereum mainnet block and save them into an SQLite DB

Resources

License

Stars

Watchers

Forks

Packages

No packages published