Coder Social home page Coder Social logo

go-ethereum-event-subscribe's Introduction

Go Ethereum Event Subscribe

Methods to subscribe on events with go-ethereum

With Compiled ABI

Example with ChainLink Oracle compile the ABI

  • Copy the abi from Etherscan to the folder ABIs in a .abi file
  • Compile the abi with abigen CLI
abigen --abi=./abis/AccessControlledOffchainAggregator.abi --pkg=abis --out=./abis/AccessControlledOffchainAggregator.go

change the smart contract in main.go

contractAddress := common.HexToAddress("0xAe74faA92cB67A95ebCAB07358bC222e33A34dA7")

Without Compiled ABI

Example with ChainLink Oracle in code folder

  • Need to find the Topics[0] of the event we are looking for
  • As we are filter all logs to matche the topics we need
if log.Topics[0] == common.HexToHash("0xf6a97944f31ea060dfde0566e4167c1a1082551e64b60ecb14d599a9d023d451") {

update/change the smart contract in main.go

  • contractAddress
  • description
  • decimals
contractAddress := common.HexToAddress("0xAe74faA92cB67A95ebCAB07358bC222e33A34dA7")
description := "BTC/USD"
decimals := int32(8)*-1

Usage

go run main.go

go-ethereum-event-subscribe's People

Contributors

rmsrob avatar

Stargazers

 avatar  avatar  avatar

Watchers

 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.