通过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看看. 手上就几个桌面支持的兄弟,要弄一百台多电脑 ...
随机推荐
- ES搜索- term与match区别&bool查询
term属于精确匹配,只能查单个词,tems可以匹配多个词(满足其中之一词的都会被搜索出来),多个词如果要同时匹配使用bool的must(must中带多个term): match进行搜索的时候,会先进 ...
- element的upload手动submit前动态设置上传请求地址
标签地址绑定一个变量 动态修改上传请求地址代码: nextTick是DOM更新后触发,不使用nextTick直接submit,上传地址仍然会使用初始url地址 _this = this; this.u ...
- Qt头文件引用其他类,主类头文件报错(1)invalid use of incomplete type 'class xx::yy' (2)forward declaration of 'class xx::yy'
其实这个错误很蠢,由于代码是从cpp文件直接copy过来的就没仔细看,但是他这个报错很有迷惑性,我们来看图: 就这行代码,从cpp文件中复制过来的: 本来目的呢就是提升这个变量的作用域,但是呢!!!在 ...
- PDF.JS 预览pdf文件,中文不显示问题
pdf.js 下载路径 http://mozilla.github.io/pdf.js/ pdf.js的使用不多说,网上都有 讲一下,.NET CORE MVC的使用遇到的问题 1. 将下载文件解压放 ...
- 推荐一个 python学习网站
kaggle python课程: https://www.kaggle.com/learn/python 知乎有个博主在专栏放了课程的中文版: https://www.zhihu.com/people ...
- 使用ms17-010对win7进行渗透(445永恒之蓝)
永恒之蓝是指2017年4月14日晚,黑客团体Shadow Brokers(影子经纪人)公布一大批网络攻击工具,其中包含"永恒之蓝"工具,"永恒之蓝"利用Wind ...
- webpack的加载器兼容配置一览
"devDependencies": { "css-loader": "^3.2.1", "file-loader": ...
- 路飞前台全局css 全局配置文件,安装axios,安装vue-cookies,安装elementui,安装bootstrap和jq,后台主页模块表设计,后台主页模块轮播图接口,录入数据,跨域问题详解
目录 路飞前台全局css 全局配置文件,安装axios,安装vue-cookies,安装elementui,安装bootstrap和jq,后台主页模块表设计,后台主页模块轮播图接口,录入数据,跨域问题 ...
- go-使用 vscore 调试 go 语言
{ // 使用 IntelliSense 了解相关属性. // 悬停以查看现有属性的描述. // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linki ...
- ApexSQLDBA 2019.02.1245[破解补丁]
ApexSQL DBA 2019.02.1245 破解补丁 支持ApexSQL Log.ApexSQL Plan.ApexSQL Recover 该版本支持SQLSERVER 2019 开源地址: h ...