通过nft持有大户地址获取正常交易和内部交易
/*内部交易*/------------ CREATE TABLE `internal_txlist` (
`blockNumber` varchar(255) DEFAULT NULL,
`tx_timeStamp` varchar(255) DEFAULT NULL,
`hash` varchar(255) DEFAULT NULL,
`tx_from` varchar(255) DEFAULT NULL,
`tx_to` varchar(255) DEFAULT NULL,
`tx_value` varchar(255) DEFAULT NULL,
`contractAddress` varchar(255) DEFAULT NULL,
`input` varchar(255) DEFAULT NULL,
`type` varchar(255) DEFAULT NULL,
`gas` varchar(255) DEFAULT NULL,
`gasUsed` varchar(255) DEFAULT NULL,
`traceId` varchar(255) DEFAULT NULL,
`isError` varchar(255) DEFAULT NULL,
`errCode` varchar(255) DEFAULT NULL,
`address` varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 /*正常交易*/------------
CREATE TABLE `txlist` (
`address` varchar(255) DEFAULT NULL,
`tx_type` varchar(100) DEFAULT NULL,
`blockNumber` varchar(255) DEFAULT NULL,
`tx_timeStamp` varchar(255) DEFAULT NULL,
`hash` varchar(255) DEFAULT NULL,
`nonce` varchar(255) DEFAULT NULL,
`blockHash` varchar(255) DEFAULT NULL,
`transactionIndex` varchar(255) DEFAULT NULL,
`tx_from` varchar(255) DEFAULT NULL,
`tx_to` varchar(255) DEFAULT NULL,
`tx_value` varchar(255) DEFAULT NULL,
`gas` varchar(255) DEFAULT NULL,
`gasPrice` varchar(255) DEFAULT NULL,
`isError` varchar(255) DEFAULT NULL,
`txreceipt_status` varchar(255) DEFAULT NULL,
`input` varchar(255) DEFAULT NULL,
`contractAddress` varchar(255) DEFAULT NULL,
`cumulativeGasUsed` varchar(255) DEFAULT NULL,
`gasUsed` varchar(255) DEFAULT NULL,
`confirmations` varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 /*基本数据统计* 粗略统计,详细数据需要查eth签名库识别出哪些是mint nft操作/ SELECT * FROM (
SELECT address,CONVERT((SUM(tx_value)/ POWER(10,18)),DECIMAL(10,3)) total_eth,CONVERT((SUM(gasPrice*gasUsed)/ POWER(10,18)),DECIMAL(10,3)) gas_eth,COUNT(1) num, 'all' tx_type FROM txlist WHERE 1=1 GROUP BY address
UNION ALL
SELECT address,CONVERT((SUM(tx_value)/ POWER(10,18)),DECIMAL(10,3)) total_eth,CONVERT((SUM(gasPrice*gasUsed)/ POWER(10,18)),DECIMAL(10,3)) gas_eth,COUNT(1) num, 'in' tx_type FROM txlist WHERE tx_to = address AND input = '0x' GROUP BY address
UNION ALL
SELECT address,CONVERT((SUM(tx_value)/ POWER(10,18)),DECIMAL(10,3)) total_eth,CONVERT((SUM(gasPrice*gasUsed)/ POWER(10,18)),DECIMAL(10,3)) gas_eth,COUNT(1) num, 'out' tx_type FROM txlist WHERE tx_from = address AND input = '0x' GROUP BY address
UNION ALL
SELECT address,CONVERT((SUM(tx_value)/ POWER(10,18)),DECIMAL(10,3)) total_eth,CONVERT((SUM(gasPrice*gasUsed)/ POWER(10,18)),DECIMAL(10,3)) gas_eth,COUNT(1) num, 'free_call' tx_type FROM txlist WHERE tx_from = address AND input != '0x' AND tx_value=0 GROUP BY address
UNION ALL
SELECT address,CONVERT((SUM(tx_value)/ POWER(10,18)),DECIMAL(10,3)) total_eth,CONVERT((SUM(gasPrice*gasUsed)/ POWER(10,18)),DECIMAL(10,3)) gas_eth,COUNT(1) num, 'eth_call' tx_type FROM txlist WHERE tx_from = address AND input != '0x' AND tx_value!=0 GROUP BY address
) A WHERE 1=1 AND address = '0xc0ac56cf556b41da25354cc0199200bf36f79ccc'
/*内部交易简单统计 统计内部交易获利eth数量,粗略统计 详细获利需要筛选 from:
opensea:0x7f268357A8c2552623316e2562D90e642bB538E5等 或者来源是x2y2等nft交易平台
*/
SELECT A.address,A.total_eth,A.total, CONVERT((A.total_eth/A.total) , DECIMAL(10,6)) avg_sell FROM (
SELECT
address,
SUM(tx_value)/POWER(10, 18) total_eth,
COUNT(1) total FROM
internal_txlist
WHERE 1=1 AND address = '0xc0ac56cf556b41da25354cc0199200bf36f79ccc' GROUP BY address ) A ORDER BY avg_sell DESC
#coding=utf-8
import requests
import time
import json
import math
import datetime
from requests.packages.urllib3 import disable_warnings
from selenium_chrome.MySqlUtils import getMysql
from termcolor import colored
disable_warnings()
#正常交易数据
if __name__ == '__main__':
select_sql = "SELECT address,COUNT(1) num ,SUM(balance) total FROM nft_analytics WHERE time_type = '1d' GROUP BY address ORDER BY COUNT(1) DESC, SUM(balance) DESC LIMIT 100;"
mysql = getMysql()
sql_rep = mysql.select_db(select_sql)
num = 0
for one in sql_rep:
try:
address = one['address']
print(colored(address,'green'))
tx_url = f'https://api.etherscan.io/api?module=account&action=txlist&address={address}&startblock=0&endblock=99999999&page=1&offset=10000&sort=asc&apikey=65AM1ATEMHUTF1KAY454C1KWIY9I7JXG1K'
txlist_resp = requests.get(tx_url,timeout=60,verify=False)
if txlist_resp.status_code == 200 :
resp = json.loads(txlist_resp.text)
if resp['message'] == 'OK':
for tx in resp['result']:
'''
"blockNumber": "14903204",
"timeStamp": "1654344938",
"hash": "0x9888d4c16e3bb9265730c93f1fd08bf0254816c6ce4d335469943632d4445908",
"nonce": "0",
"blockHash": "0x710051cfa3bb48c7eabdf53b92fe4b0dc857f7659adb53f2345a41f16b0ad97e",
"transactionIndex": "21",
"from": "0x51cb9c51e003d5b885f2446a048d664b91f44d6c",
"to": "0x56197a6ef508d6cb6b24dc2afd6d594b4260e2a7",
"value": "80000000000000000",
"gas": "21000",
"gasPrice": "32294834880",
"isError": "0",
"txreceipt_status": "1",
"input": "0x",
"contractAddress": "",
"cumulativeGasUsed": "1407082",
"gasUsed": "21000",
"confirmations": "50652"
'''
values = {}
values['blockNumber'] = tx['blockNumber']
values['timeStamp'] = tx['timeStamp']
values['hash'] = tx['hash']
values['nonce'] = tx['nonce']
values['blockHash'] = tx['blockHash']
values['transactionIndex'] = tx['transactionIndex']
values['from'] = tx['from']
values['to'] = tx['to']
values['value'] = tx['value']
values['gas'] = tx['gas']
values['gasPrice'] = tx['gasPrice']
values['isError'] = tx['isError']
values['txreceipt_status'] = tx['txreceipt_status']
values['input'] = tx['input'][0:10]
values['contractAddress'] = tx['contractAddress']
values['cumulativeGasUsed'] = tx['cumulativeGasUsed']
values['gasUsed'] = tx['gasUsed']
values['confirmations'] = tx['confirmations']
values['address'] = address
values_list = []
values_str = ''
for k in values:
v = values[k]
values_list.append(f"'{v}'")
if values_list:
values_str = ','.join(values_list)
insert_sql = f'insert into txlist (blockNumber,tx_timeStamp,hash,nonce,blockHash,transactionIndex,tx_from,tx_to,tx_value,gas,gasPrice,isError,txreceipt_status,input,contractAddress,cumulativeGasUsed,gasUsed,confirmations,address) values ({values_str})'
mysql.execute_db(insert_sql)
num+=1
print(colored(str(num)+':数据获取完成!!!','red'))
except BaseException as e:
print(e)
#coding=utf-8
import requests
import time
import json
import math
import datetime
from requests.packages.urllib3 import disable_warnings
from selenium_chrome.MySqlUtils import getMysql
from termcolor import colored
disable_warnings()
#内部交易数据
if __name__ == '__main__':
select_sql = "SELECT address,COUNT(1) num ,SUM(balance) total FROM nft_analytics WHERE time_type = '1d' GROUP BY address ORDER BY COUNT(1) DESC, SUM(balance) DESC LIMIT 100;"
mysql = getMysql()
sql_rep = mysql.select_db(select_sql)
num = 0
for one in sql_rep:
try:
address = one['address']
print(colored(address,'green'))
tx_url = f'https://api.etherscan.io/api?module=account&action=txlistinternal&address={address}&startblock=0&endblock=99999999&page=1&offset=10000&sort=asc&apikey=65AM1ATEMHUTF1KAY454C1KWIY9I7JXG1K'
txlist_resp = requests.get(tx_url,timeout=60,verify=False)
if txlist_resp.status_code == 200 :
resp = json.loads(txlist_resp.text)
if resp['message'] == 'OK':
for tx in resp['result']:
'''
"blockNumber": "14909063",
"timeStamp": "1654431441",
"hash": "0x7f70c67f0f892cb96c168f44eaf942af241434315822e909e2490e1c47585787",
"from": "0x7f268357a8c2552623316e2562d90e642bb538e5",
"to": "0x51cb9c51e003d5b885f2446a048d664b91f44d6c",
"value": "9081000000000000",
"contractAddress": "",
"input": "",
"type": "call",
"gas": "2300",
"gasUsed": "0",
"traceId": "7_2",
"isError": "0",
"errCode": ""
'''
values = {}
values['blockNumber'] = tx['blockNumber']
values['timeStamp'] = tx['timeStamp']
values['hash'] = tx['hash']
values['from'] = tx['from']
values['to'] = tx['to']
values['value'] = tx['value']
values['contractAddress'] = tx['contractAddress']
values['input'] = tx['input'][0:10]
values['type'] = tx['type']
values['gas'] = tx['gas']
values['gasUsed'] = tx['gasUsed']
values['traceId'] = tx['traceId']
values['isError'] = tx['isError']
values['errCode'] = tx['errCode']
values['address'] = address
values_list = []
values_str = ''
for k in values:
v = values[k]
values_list.append(f"'{v}'")
if values_list:
values_str = ','.join(values_list)
insert_sql = f'insert into internal_txlist (blockNumber,tx_timeStamp,hash,tx_from,tx_to,tx_value,contractAddress,input,type,gas,gasUsed,traceId,isError,errCode,address) values ({values_str})'
mysql.execute_db(insert_sql)
num+=1
print(colored(str(num)+':数据获取完成!!!','red'))
except BaseException as e:
print(e)
通过nft持有大户地址获取正常交易和内部交易的更多相关文章
- C# HttpWebRequest 绝技 根据URL地址获取网页信息
如果要使用中间的方法的话,可以访问我的帮助类完全免费开源:C# HttpHelper,帮助类,真正的Httprequest请求时无视编码,无视证书,无视Cookie,网页抓取 1.第一招,根据URL地 ...
- 腾讯新浪通过IP地址获取当前地理位置(省份)的接口
腾讯新浪通过IP地址获取当前地理位置(省份)的接口 腾讯的接口是 ,返回数组 http://fw.qq.com/ipaddress 返回值 var IPData = new Array(" ...
- Java实现Internet地址获取
Java实现Internet地址获取 代码内容 输入域名输出IPV4地址 输入IP地址输出域名 支持命令行输入 支持交互式输入 代码实现 /* nslookup.java */ import java ...
- 运用百度开放平台接口根据ip地址获取位置
使用百度开放平台接口根据ip地址获取位置 今天无意间发现在百度开放平台接口,就把一段代码拿了下来,有需要的可以试试看:http://opendata.baidu.com/api.php?query=5 ...
- Java根据ip地址获取Mac地址,Java获取Mac地址
Java根据ip地址获取Mac地址,Java获取Mac地址 >>>>>>>>>>>>>>>>>&g ...
- PHP:根据IP地址获取所在城市
文件目录: ipLocation -----qqwry ----------QQWry.Dat -----ipCity.class.php ipCity.class.php文件代码: <?php ...
- 根据URL地址获取对应的HTML,根据对应的URL下载图片
核心代码(获取HTML): #region 根据URL地址获取信息GET public static String GetResult(string url) { return GetResult(u ...
- java根据地址获取百度API经纬度
java根据地址获取百度API经纬度(详细文档) public void getLarLng(String address) throws Exception { String ak = " ...
- 根据第三方提供的webservice地址获取文件信息
import org.apache.axis.client.Call; import org.apache.axis.client.Service; import org.apache.axis.en ...
- 小工具-IP地址获取和设置及端口访问验证(windows)
技术部在业务部门眼里就是后勤部门,业务部门要搬到新大楼去 领导要求去帮忙调试业务人员的电脑,要保证这些大爷们周一上班来,就喝着茶打开新浪,然后打开OA看看. 手上就几个桌面支持的兄弟,要弄一百台多电脑 ...
随机推荐
- windwos11没有Hyper-V的解决方法
我的系统是windows11家庭版,程序添加这就没有hyper-v,但是可以手动添加,把下面这个脚本修改后缀.cmd即可(如:hyper-v.cmd),不会的可以直接下载我这个文件. Hyper-v执 ...
- Flutter 登录与list列表demo
import 'package:flutter/material.dart'; void main() => runApp(DemoApp()); class DemoApp extends S ...
- 粉色的猫MISC(bugku)
一 题目描述 ps:本题特别感谢树叶大佬给的一些提示以及WP!欢迎大家关注树木有点绿~~ 二 解题过程 下载附件得到zip压缩包 根据作者提示,压缩包注释应该为压缩包密码. 1.压缩包密码 一开始看 ...
- Unity3D使用脚本动态创建、调用动画(转)
原文链接: https://blog.csdn.net/pigautumn/article/details/81781403 需求场景:由若干个数量不确定的物体从上到下排列,需要间隔0.1s依次从左到 ...
- Software_Programming_bootstrap_book
2019-10-25 HTML index 11 p24 主页布局.
- pytorch学习笔记(9)--神经网络模型的保存与读取
一.网络模型的保存和加载 1.网络模型保存方法1 import torch import torchvision vgg16 = torchvision.models.vgg16(weights=Fa ...
- kafka集群under replicated分析
近期随着业务消息量增大,现网几套kafka集群频繁收到under repliacted告警,集合近期定位分析过程,主要有以下几个方面:1. 查看是否有主机挂掉,或近期是否有主机重启,通过kafdrop ...
- DUT:Device Uder Test 被测设备
半导体测试的专业术语 1. DUT 需要被实施测试的半导体器件通常叫做DUT(Device Under Test,我们常简称"被测器件"),或者叫UUT(Unit Under Te ...
- 「postOI」Lost Array
题意 有一个序列 \(A=\{a_1, a_2, ..., a_n\}\),按如下方式构造一个 \((n + 1) \times (n + 1)\) 的矩阵 \(B\): \(B_{i0}=0\)(\ ...
- ElasticSearch (Es) 分组查询 记录
首先表对应的实体类型: public class bm_info{ /// <summary> /// 单位 /// </summary> public string sou ...