All Projects → getamis → Eth Indexer

getamis / Eth Indexer

Licence: lgpl-3.0
An Ethereum project to crawl blockchain states into database

Programming Languages

go
31211 projects - #10 most used programming language
golang
3204 projects

Projects that are alternatives of or similar to Eth Indexer

Go Ethereum Hdwallet
Ethereum HD Wallet derivations in Go (golang)
Stars: ✭ 178 (+81.63%)
Mutual labels:  blockchain, ethereum, geth
Nethereum
Ethereum .Net cross platform integration library
Stars: ✭ 1,191 (+1115.31%)
Mutual labels:  blockchain, ethereum, geth
Go Ethereum
Official Go implementation of the Ethereum protocol
Stars: ✭ 34,169 (+34766.33%)
Mutual labels:  blockchain, ethereum, geth
Ethnode
Run an Ethereum node (Geth or Openethereum) for development
Stars: ✭ 74 (-24.49%)
Mutual labels:  blockchain, ethereum, geth
Ethermint Archive
Ethereum on Tendermint using Cosmos-SDK!
Stars: ✭ 667 (+580.61%)
Mutual labels:  blockchain, ethereum, geth
Ethereumdb
Stars: ✭ 21 (-78.57%)
Mutual labels:  blockchain, ethereum, database
Ethdroid
Easy-to-use Ethereum Geth wrapper for Android
Stars: ✭ 47 (-52.04%)
Mutual labels:  blockchain, ethereum, geth
Use Dai
💸 A curated, community compiled list of everywhere you can use the decentralized Dai stablecoin
Stars: ✭ 74 (-24.49%)
Mutual labels:  blockchain, ethereum
Portis Sdk
Portis Web SDK [DEPRECATED, PLEASE USE OUR NEW SDK: https://github.com/portis-project/web-sdk]
Stars: ✭ 78 (-20.41%)
Mutual labels:  blockchain, ethereum
Marketprotocol
Ethereum based derivatives trading protocol creating digital tokens for any asset
Stars: ✭ 78 (-20.41%)
Mutual labels:  blockchain, ethereum
Trust Wallet Ios
📱 Trust - Ethereum Wallet and Web3 DApp Browser for iOS
Stars: ✭ 1,228 (+1153.06%)
Mutual labels:  blockchain, ethereum
Smart Contracts
Ethereum smart contracts for security and utility tokens
Stars: ✭ 1,187 (+1111.22%)
Mutual labels:  blockchain, ethereum
Cava
ConsenSys core libraries for Java & Kotlin
Stars: ✭ 71 (-27.55%)
Mutual labels:  blockchain, ethereum
Epirus Free
Ethereum, Hyperledger Besu and Quorum private blockchain explorer
Stars: ✭ 79 (-19.39%)
Mutual labels:  blockchain, ethereum
Whale
🐋 Show Ethereum and Bitcoin price in command line interface (CLI).
Stars: ✭ 81 (-17.35%)
Mutual labels:  blockchain, ethereum
Colonyjs
The Colony JavaScript client
Stars: ✭ 72 (-26.53%)
Mutual labels:  blockchain, ethereum
Istanbul Tools
Istanbul BFT tools
Stars: ✭ 80 (-18.37%)
Mutual labels:  blockchain, ethereum
Uniswap Interface
🦄 An open source interface for the Uniswap protocol
Stars: ✭ 1,337 (+1264.29%)
Mutual labels:  blockchain, ethereum
Blockchain Parser
The simpliest script for parsing Bitcoin blockchain. It made convertion of blk*****.dat files to the simple text.
Stars: ✭ 84 (-14.29%)
Mutual labels:  blockchain, database
Awesome Privacy On Blockchains
A curated list of privacy on blockchains resources
Stars: ✭ 86 (-12.24%)
Mutual labels:  blockchain, ethereum

eth-indexer

eth-indexer is an Ethereum blockchain indexer project to crawl blocks, transactions & state difference per block/address into MySQL database.

travis codecov Go Report Card

Getting Started

There are 3 main components in the project:

  1. geth: modified geth to get state difference per block/address
  2. idx-database: MySQL to store all indexed data
  3. indexer: indexer to crawl from geth then push to database

Prerequisites

  • docker
  • docker-compose

Before Building

Before building, please make sure environment variables MYSQL_DATA_PATH and GETH_DATA_PATH are setup properly, which are used to mount local data folder to MySQL and Geth containers for data persistence. One way to set this up is to have a .env file in the same folder of the docker-compose.yml

Example .env file:

MYSQL_DATA_PATH=~/indexer-data/mysql
GETH_DATA_PATH=~/indexer-data/geth

Configs and Flags

eth_indexer supports two kinds of input:

  1. static config YAML files
  2. dynamic flags through command line

You can either define your configs/config.yml or pass flags (e.g., indexer --eth.port 1234) from command line to start eth_indexer. If you use both settings, eth_indexer will load configs/config.yaml as default and overwrite the corresponding values with specified flags from command line.

Build

$ git clone [email protected]:getamis/eth-indexer.git
$ cd eth-indexer
$ # Set MYSQL_DATA_PATH and GETH_DATA_PATH environment variables
$ docker-compose build

Usage

We use docker-compose for testing and developing. MYSQL_DATA_PATH & GETH_DATA_PATH environment variables are necessary, create them out of eth-indexer directory to store database and geth data.

first time to run indexer you need to create the database schema

$ mkdir -p ~/indexer-data/mysql ~/indexer-data/geth
# Create database sechema
MYSQL_DATA_PATH="$HOME/indexer-data/mysql" docker-compose up idx-database idx-migration
# press Ctrl + C when see `eth-indexer_idx-migration_1 exited with code 0`

then use docker-compose up with environment variables to start indexer:

$ MYSQL_DATA_PATH="$HOME/indexer-data/mysql" GETH_DATA_PATH="$HOME/indexer-data/geth" docker-compose up

wait few minutes, then you can see indexing messages from indexer:

Inserted TD for block                    number=0       TD=17179869184 hash=0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3

Example

Once there are some data in MySQL, you can query specific data from it, e.g., you can get data from block_headers and transactions table. Balance is slightly different, and you can take a look at example folder to see how to query them.

package main

import (
	"context"
	"fmt"

	"github.com/ethereum/go-ethereum/common"
	"github.com/getamis/eth-indexer/model"
	"github.com/getamis/eth-indexer/store/account"
	"github.com/getamis/eth-indexer/store/sqldb"
	"github.com/getamis/sirius/database"
	"github.com/getamis/sirius/database/mysql"
)

func main() {
	db, _ := sqldb.New("mysql",
		database.DriverOption(
			mysql.Database("ethdb"),
			mysql.Connector(mysql.DefaultProtocol, "127.0.0.1", "3306"),
			mysql.UserInfo("root", "my-secret-pw"),
		),
	)
	addr := common.HexToAddress("0x756f45e3fa69347a9a973a725e3c98bc4db0b5a0")
	store := account.NewWithDB(db)

	account, err := store.FindAccount(context.Background(), model.ETHAddress, addr)
	if err != nil {
		fmt.Printf("Failed to find account: %v\n", err)
	} else {
		fmt.Printf("Find account, block_number: %v, balance: %v, \n", account.Balance, account.BlockNumber)
	}
}

ERC20 is similar, and you can see the test case for ERC20 to know how to use it.

Contributing

There are several ways to contribute to this project:

  1. Find bug: create an issue in our Github issue tracker.
  2. Fix a bug: check our issue tracker, leave comments and send a pull request to us to fix a bug.
  3. Make new feature: leave your idea in the issue tracker and discuss with us then send a pull request!

License

This project is licensed under the LGPL 3 - see the LICENSE file for details

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].