GithubHelp home page GithubHelp logo

tail-eth-events's Introduction

tail-eth-events

Overview

Small utility to tail events in the Ethereum log from the current block onward, in human readable(-ish) format. For example:

[Block 15454857] [Contract 0xDe07f45688cb6CfAaC398c1485860e186D55996D]  Transfer(indexed address sender=0x353d601aae0fc29908bb46a26cac562ad1a5bff2,indexed address receiver=0x0000000000000000000000000000000000000000,uint256 value=17268575233016576578)
[Block 15454857] [Contract 0x8eF11c51a666C53Aeeec504f120cd1435E451342]  Withdraw(indexed address owner=0x353d601aae0fc29908bb46a26cac562ad1a5bff2,uint256 shares=17268575233016576578,uint256 amount=18257840581989549385)
[Block 15454857] [Contract 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2]  Transfer(indexed address src=0x7685cd3ddd862b8745b1082a6acb19e14eaa74f3,indexed address dst=0xbeefbabeea323f07c59926295205d3b7a17e8638,uint256 wad=610600133740867388)
[Block 15454857] [Contract 0xba5BDe662c17e2aDFF1075610382B9B691296350, ProxiedTo 0x31acaaea0529894e7c3a5c70d3f9ee6d7804684f] Transfer(indexed address from=0xbeefbabeea323f07c59926295205d3b7a17e8638,indexed address to=0x7685cd3ddd862b8745b1082a6acb19e14eaa74f3,uint256 value=4724999999999999737856)
[Block 15454857] [Contract 0x7685cD3ddD862b8745B1082A6aCB19E14EAA74F3]  Anonymous/Unknown()
[Block 15454857] [Contract 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48]  Anonymous/Unknown()

It uses web3.py to get all log data in the current block. Then, for each log entry, it attempts to find the contract ABI, including for proxied contracts, using the Etherscan API. If it can find the ABI it will decode the event arguments using the ABI.

Short polling is used to check when a new block is mined.

Usage

Set the following environment variables:

ETH_NODE_WEBSOCKET= # wss url of your eth node provider
ETHERSCAN_API_KEY=

And run the script with:

python3 src/tail.py

Unit tests can we run with:

nosetest

Future Work

  • topic0 is a repository of event signatures, which could partially replace the current contract ABI lookup.
  • Contract ABIs could/should be persisted in some long-term storage. A lightweight approach is to use sqlitedict
  • Similarly, failed proxy lookups should also be persisted, so we don't do it each time we miss the event ABI.
  • Since log entries are independent, event processing should be done via multithreading.
  • Better testing, error handling, etc...

tail-eth-events's People

Contributors

dutycycle avatar

Stargazers

 avatar

Watchers

 avatar Kostas Georgiou avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.