Skip to content

Instantly share code, notes, and snippets.

@dallasmarlow
Created November 19, 2017 20:09
Show Gist options
  • Save dallasmarlow/f26c66e73e524de5c125784b52d920cb to your computer and use it in GitHub Desktop.
Save dallasmarlow/f26c66e73e524de5c125784b52d920cb to your computer and use it in GitHub Desktop.
etherscan sender summary
require 'json'
# data src:
# https://etherscan.io/exportData?type=address&a=<addr>
abort 'usage: ./eth_summary.rb <from addr> <csv filename>' unless ARVG.size == 2
address = ARGV.first
filename = ARGV.last
def process(input)
input.chomp.split(',').map {|k| k.gsub('"', '')}
end
entries = File.read(filename).lines
keys = process(entries.first)
summary = entries.last(entries.size - 1).reduce(Hash.new(0)) do |s, l|
entry = Hash[keys.zip(process(l))]
if entry['From'] == address
s['total'] += entry['Value_IN(ETH)'].to_f
s['transactions'] += 1
end
s
end
puts summary.to_json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment