/*内部交易*/------------

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持有大户地址获取正常交易和内部交易的更多相关文章

  1. C# HttpWebRequest 绝技 根据URL地址获取网页信息

    如果要使用中间的方法的话,可以访问我的帮助类完全免费开源:C# HttpHelper,帮助类,真正的Httprequest请求时无视编码,无视证书,无视Cookie,网页抓取 1.第一招,根据URL地 ...

  2. 腾讯新浪通过IP地址获取当前地理位置(省份)的接口

    腾讯新浪通过IP地址获取当前地理位置(省份)的接口  腾讯的接口是 ,返回数组 http://fw.qq.com/ipaddress 返回值 var IPData = new Array(" ...

  3. Java实现Internet地址获取

    Java实现Internet地址获取 代码内容 输入域名输出IPV4地址 输入IP地址输出域名 支持命令行输入 支持交互式输入 代码实现 /* nslookup.java */ import java ...

  4. 运用百度开放平台接口根据ip地址获取位置

    使用百度开放平台接口根据ip地址获取位置 今天无意间发现在百度开放平台接口,就把一段代码拿了下来,有需要的可以试试看:http://opendata.baidu.com/api.php?query=5 ...

  5. Java根据ip地址获取Mac地址,Java获取Mac地址

    Java根据ip地址获取Mac地址,Java获取Mac地址 >>>>>>>>>>>>>>>>>&g ...

  6. PHP:根据IP地址获取所在城市

    文件目录: ipLocation -----qqwry ----------QQWry.Dat -----ipCity.class.php ipCity.class.php文件代码: <?php ...

  7. 根据URL地址获取对应的HTML,根据对应的URL下载图片

    核心代码(获取HTML): #region 根据URL地址获取信息GET public static String GetResult(string url) { return GetResult(u ...

  8. java根据地址获取百度API经纬度

    java根据地址获取百度API经纬度(详细文档) public void getLarLng(String address) throws Exception { String ak = " ...

  9. 根据第三方提供的webservice地址获取文件信息

    import org.apache.axis.client.Call; import org.apache.axis.client.Service; import org.apache.axis.en ...

  10. 小工具-IP地址获取和设置及端口访问验证(windows)

    技术部在业务部门眼里就是后勤部门,业务部门要搬到新大楼去 领导要求去帮忙调试业务人员的电脑,要保证这些大爷们周一上班来,就喝着茶打开新浪,然后打开OA看看. 手上就几个桌面支持的兄弟,要弄一百台多电脑 ...

随机推荐

  1. JS学习-Web Workers API接口

    Web Workers API接口 通过使用Web Workers,Web应用程序可以在独立于主线程的后台线程中,运行一个脚本操作.这样做的好处是可以在独立线程中执行费时的处理任务,从而允许主线程(通 ...

  2. python win32 microsoft excel 类range的copyPictrue方法无效

    这个报错也是可以的,不明不白,只是提示:microsoft excel 类range的copyPictrue方法无效 网上找了好多博客,对我的情况没有效果,无奈我想打开excel看看到底是咋回事,结果 ...

  3. css实现一个冰墩墩

    一墩难求,花了一两个小时自己画了一个,HTML结构很简单,CSS上主要就是将各个位置定位,肚子上的logo就只有发挥啦 以下是HTML代码 <div class="container& ...

  4. Android图表控件MPAndroidChart——BarChart实现多列柱状图和LineChart多曲线 (完结)

    首先才接触Android,目前自学一个月,花了一星期,做出了柱状图和曲线图,踩过坑也不少,上代码(主要提供思路,大部分代码可直接用). 参考代码地址:①曲线:https://blog.csdn.net ...

  5. MySQL Workbench部分出错及可能解决方案

    出错一:8.0.23.0版本,在workbench内建立表eg1,select * from eg1无返回结果,无法向表内导入数据,在如下图的下一步,workbench会直接闪退 可行的办法:(不建议 ...

  6. grafana+prometheus+tomcat 监控tomcat

    一.前提 1.tomcat作为java项目首选的部署容器.但是,在做测试,或者是在运维管理生产服务器的时候,想要监控tomcat的实时运行情况,却不是那么容易的 2.grafana(已安装和prome ...

  7. mysql创建存储过程造数据

    delimiter $$$ DROP PROCEDURE zqtest6; create procedure zqtest6() begin declare i int default 0; set ...

  8. node 内存全局配置(--max-old-space-size)

    安装完了node和angular之后,使用powershell 窗口进行 ng build --prod打包,会提示内存溢出:JavaScript heap out of memory. 项目内打包解 ...

  9. C# 海康威视网络半球摄像头回调YV12取画面

    海康网络摄像头回调取画面,网口最好用千兆的网卡来做,开始用笔记本的百兆网口,不管怎么优化都是卡顿的, 后来用千兆网卡台式机的,基本就没有卡顿了,取图再加上运动检测处理,基本上十几毫秒每帧. 用回调方式 ...

  10. 2021-1-31 group class note

    Lesson aim By the end of this lesson, Ss will be able to talk about restaurant food using verbs of p ...