Skip to content

Instantly share code, notes, and snippets.

@fluiddrop
Created April 1, 2021 10:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fluiddrop/7dca9ead571b3e021a522a37616d4139 to your computer and use it in GitHub Desktop.
Save fluiddrop/7dca9ead571b3e021a522a37616d4139 to your computer and use it in GitHub Desktop.
import requests
import pandas as pd
from tabulate import tabulate
# Etherscan API Token. See: https://etherscan.io/apis
TOKEN = 'xxx'
# Parameters
START_BLOCK = 11565019 # Mined Jan-01-2021 12:00:00 AM +UTC
END_BLOCK = 12150244 # Mined Mar-31-2021 11:59:57 PM +UTC
# Multi-sig address
multi_sig = '0x5F239a6671BC6d2bAEf6D7Cd892296e678810882'
# Owners of the multi-sig
ms_owners = [
'0x91628ddc3A6ff9B48A2f34fC315D243eB07a9501',
'0xC4a69FBf4511A1377161834Cb7a3B8766953dB02',
'0x734C242BA2d6A47644093F874FA4dad15005CF19',
'0x08EEc580AD41e9994599BaD7d2a74A9874A2852c',
'0x462384d457aCE0E5702f8B2a6734F599E0E96809',
'0x87C308B70AD9eacbef0Cb43514a104684eDB8A5D',
'0x56E9dF04a965f9E85cfC27F823210a7C94E70AD8',
]
refund_amounts = []
def get_tx(start_block, end_block=999999999999):
# Get txs sent to multi-sig from each owner
for a in ms_owners:
req = requests.get(f'https://api.etherscan.io/api?module=account&action=txlist&address={a}&startblock={start_block}&endblock={end_block}&sort=asc&apikey={TOKEN}')
if req.json()['status'] == "1":
txs = pd.DataFrame(req.json()['result'])
# Filter only txs sent to the multi-sig
txs = txs[txs['to'] == multi_sig.lower()]
txs.gasUsed = txs.gasUsed.astype('int')
txs.gasPrice = txs.gasPrice.astype('int')
# Calculate gas expenditure
txs['gasETH'] = txs.gasUsed * txs.gasPrice / 1E+18
refund = txs.gasETH.sum()
refund_amounts.append([a, refund])
else:
print("Request error.")
get_tx(START_BLOCK, END_BLOCK)
# Print to console in markdown
print(tabulate(refund_amounts, headers=['Address', 'ETH Amount'], tablefmt="github"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment