I have a geth node running on a server. I want my Ruby app to take action every time a contract emits an event. The app cannot miss any events.

One way would be to poll for transactions to that address every x seconds, and scan the TX receipts for log data. Are there any Ruby tools to help with that? Is there a better way to do it?

  • did you try filter methods defined here with web3 implementation of Ruby Commented Nov 2, 2017 at 1:33

1 Answer 1


You can use Eth::Client.eth_get_filter_changes from the eth gem. See api.rb#L130.

geth = Eth::Client.create ""
# => #<Eth::Client::Http:0x000055d54c9c8f20>
contract = Eth::Address.new "0x6B175474E89094C44Da98b954EedeAC495271d0F"
# => #<Eth::Address:0x000055d54ca08e40 @address="0x6B175474E89094C44Da98b954EedeAC495271d0F">
filter = { fromBlock: 0, toBlock: 9999, address: contract.to_s }
# => {:fromBlock=>0, :toBlock=>9999, :address=>"0x6B175474E89094C44Da98b954EedeAC495271d0F"}
geth.eth_new_filter filter
# => {"jsonrpc"=>"2.0", "id"=>2, "result"=>"0xc6deb76fb676738465dd4b9418364f6"}
geth.eth_get_filter_changes "0xc6deb76fb676738465dd4b9418364f6"
# => {"jsonrpc"=>"2.0", "id"=>3, "result"=>[]}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.