Sign inSign up

nodechain/eth-transactions-indexer

By nodechain

•Updated about 4 years ago

ETH-Transaction-Indexer

Image
0

420

nodechain/eth-transactions-indexer repository overview

⁠ETH-Transactions-Indexer

ETH-Transactions-Indexer is a service that allows you to store ETH and ERC20 transactions in a Postgres database to get insights of them.

This repository only contains the python code that indexs the transactions into the Postgres database. ETH node and Postgres database management is out of this container. To fully understand how the container works check the GitHub repository⁠

⁠Workflow

Application workflow

  1. Node connection using Web.py⁠
  2. Postgres database connection using psycopg2⁠
  3. Wait until node is fully synchronised
  4. Indexing proccess from the selected block or if it had been started previously and some transactions were already indexed into the database, from the previous last indexed block

⁠Stored information

Indexed transactions included the following information:

  • time is transaction timestamp.
  • txfrom sender's Ethereum address.
  • txto recipient's Ethereim address.
  • value is the amount of Ethreum transferred.
  • gas is the gas used.
  • gasPrice is the gas price.
  • block is the block number.
  • txhash is the transaction hash.
  • contract_to recipient's Ethereum address in case of contract.
  • contract_value is the amount transfered of ERC20 tranction in its token.
  • status is the transaction status introduce in the Byzantium fork of Ethereum, it indicates if the top-level call succeded or failed. For Pre-bizantium transactions value is null

⁠Setup

ETH-Transactions-Indexer can be configured with the following environment varibles:

  • DB_NAME: Postgres url of the database with the neccesary schema⁠. It's mandatory.
  • NODE_URL: Ethereum node url. It's mandatory. The following providers are suppoorted:
    • IPC: Uses local file system, it is the fastest and the most secure.
    • WS: Works remotely, it faster than the HTTP
    • HTTP: More nodes supoport it
  • START_BLOCK: First block to index. It's optional annd default value is 1.
  • CONFIRMATIONS: Number of blocks to leave out of the indexing process from the last block. It's optional and default value is 0.
  • PERIOD: Number of seconds between requesting the node which is the last block. It's optional and default value is 20 seconds.

⁠Dependencies

  • Python 3.6
  • Web3.py
  • Psycopg2

⁠Example

docker run --name ethindexer --env DB_NAME=postgres://user:password@hostname:port/dbname --env NODE_URL=ws://urlnode:8546 nodechain/eth-transactions-indexer

Tag summary

Content type

Image

Digest

sha256:5b1e1683f…

Size

200.9 MB

Last updated

about 4 years ago

docker pull nodechain/eth-transactions-indexer