Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <script>
- var handleEthermineResult = function (err, data) {
- const payouts = getAllPayoutsTo(data.result, "0xea674fdde714fd979de3edf0f56aa9716b898ec8");
- console.log("all payouts", payouts)
- const totalPayouts = getTotalAmountFromWithTs(payouts);
- const eth = Number(totalPayouts[0] / BigInt("1000000000000000")) / 1000;
- console.log("Total profit during timeframe is: " + eth + " ETH (since:" + new Date(totalPayouts[1] * 1000) + ")")
- }
- var getJSON = function (url, callback) {
- var xhr = new XMLHttpRequest();
- xhr.open('GET', url, true);
- xhr.responseType = 'json';
- xhr.onload = function () {
- var status = xhr.status;
- if (status === 200) {
- callback(null, xhr.response);
- } else {
- callback(status, xhr.response);
- }
- };
- xhr.send();
- };
- getEthermineTx();
- function getEthermineTx() {
- return getJSON(
- "https://api.etherscan.io/api?module=account&action=txlist&address=0xf6da21e95d74767009accb145b96897ac3630bad&startblock=0&endblock=99999999&sort=asc&apikey=YourApiKeyToken",
- handleEthermineResult
- );
- }
- function getAllPayoutsTo(data, toAddress) {
- var result = [];
- for (var i = 0; i < data.length; i++) {
- const current = data[i];
- if (current.to == toAddress) {
- result.push(current);
- }
- }
- return result;
- }
- function getTotalAmountFromWithTs(data, timeframe) {
- var result = BigInt(0);
- earliestTimeStamp = 9999999999999;
- for (var i = 0; i < data.length; i++) {
- const current = data[i];
- if (timeframe && current.timeStamp < Date.now() / 1000 - timeframe) {
- continue;
- }
- if (current.timeStamp < earliestTimeStamp) earliestTimeStamp = current.timeStamp;
- result = BigInt(current.value) + result;
- }
- return [result, earliestTimeStamp];
- }
- </script>
- </head>
- <body>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement