Files: f1521af2d73e96acaa4e96dfc60dbfc50373845a / ethereum2ledger
1008 bytesRaw
1 | |
2 | addr="${1?missing address}" |
3 | |
4 | acct_gas='Expenses:Broker:Miner Fees' |
5 | acct_eth='Assets:Ethereum' |
6 | eth=1000000000000000000 |
7 | |
8 | curl -s "https://api.etherscan.io/api?module=account&action=txlist&address=$addr&sort=asc" |\ |
9 | jq -r '.result[] | .hash + " " + .timeStamp + " " + .from + " " + .to + " " + .value + " " + .gasUsed + " " + .gasPrice | @text' |\ |
10 | while read hash time from to value gas_used gas_price; do |
11 | if [ "$to" = "$addr" ] |
12 | then |
13 | type=Deposit |
14 | acct_from="$acct_eth" |
15 | acct_to=Income |
16 | else |
17 | type=Withdraw |
18 | acct_from="$acct_eth" |
19 | acct_to=Expenses |
20 | value="-$value" |
21 | fi |
22 | gas_eth="$(echo "($gas_used * $gas_price)/$eth" | bc -l)" |
23 | sent_eth="$(echo "-($value)/$eth" | bc -l)" |
24 | value_eth="$(echo "($value - ($gas_used * $gas_price))/$eth" | bc -l)" |
25 | date --date=@$time +"%Y/%m/%d $type" |
26 | echo " ; txid: $hash" |
27 | printf " %-32s %12.8f ETH\n" "$acct_to" "$sent_eth" |
28 | printf " %-32s %12.8f ETH\n" "$acct_gas" "$gas_eth" |
29 | printf " %-32s %12.8f ETH\n\n" "$acct_from" "$value_eth" |
30 | done |
31 |
Built with git-ssb-web