async function const request await fetch https api etherscan io api mo

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
(async function() {
const request = await fetch('https://api.etherscan.io/api?module=proxy&action=eth_blockNumber')
const {result: lastBlock} = await request.json()
let currentBlock = parseInt(lastBlock)
const transactions = []
const addresses = new Map();
for (let i = 0; i < 100; i++) {
const block = currentBlock.toString(16)
const request = await fetch(`https://api.etherscan.io/api?module=proxy&action=eth_getBlockByNumber&tag=0x${block}&boolean=true`)
const {result: {transactions: blockTransactions}} = await request.json()
transactions.push(...blockTransactions)
currentBlock--
}
for (const transaction of transactions) {
if (addresses.has(transaction.to)) {
const transfer = addresses.get(transaction.to)
addresses.set(transaction.to, transfer + parseInt(transaction.value))
} else {
addresses.set(transaction.to, parseInt(transaction.value))
}
if (addresses.has(transaction.from)) {
const transfer = addresses.get(transaction.from)
addresses.set(transaction.from, transfer - parseInt(transaction.value))
} else {
addresses.set(transaction.from, -parseInt(transaction.value))
}
}
let maxTransfer = -Infinity
let maxTransferAddress = null
for (const [address, value] of addresses.entries()) {
maxTransferAddress = maxTransfer < value ? address : maxTransferAddress
maxTransfer = maxTransfer < value ? value : maxTransfer
}
console.log(maxTransferAddress, maxTransfer / 10e18)
})()