go-ethereum-event-subscribe

command module
v0.0.0-...-37c67ed Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 29, 2022 License: GPL-2.0 Imports: 9 Imported by: 0

README

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

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL