通过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看看. 手上就几个桌面支持的兄弟,要弄一百台多电脑 ...
随机推荐
- ComWin’ round 11部分题解
https://vjudge.net/contest/325913#overview A.Threehouses 题意:一直二维平面上的$n$个点中,前$e$个点落在小岛周围,并且有$p$条边已经连接 ...
- Mac OS 如何批量转换图片格式
在苹果电脑中,如何快速批量地转换图片的格式.苹果电脑的预览程序,可以实现PNG.JPEG.JPEG-2000.PDF.TIFF格式之间的互换.这里以将PNG格式转换为JPEG格式为例. 工具/原料 ...
- CH582m模拟JoyStick使用USB与电脑通信
目录 本程序改编自沁恒官网2022年1月更新的CH583EVT中的CompoundDev例程.这里只贴了main.c中的程序.能够实现:①直接接电脑,在设备管理器中能够查到被电脑识别为HID-comp ...
- 074_Wrapper_Class
https://developer.salesforce.com/page/Wrapper_Class http://www.sfdcpoint.com/salesforce/wrapper-clas ...
- Curl 命令举例
curl是一个强大的网络请求lib,虽然强大,但是参数太多哈,不得不吐槽,下面列举一下常用使用方法,供大家CV POST 请求 入门: curl -X POST "http://localh ...
- ANSI/Unicode字符串简单介绍
1.1.wchar_t.char区别 ANSI:char,可以用strcat().strcpy().strlen()等str开头的函数处理char*字符串: UNICODE:wchar_t是Unico ...
- JavaScript&TypeScript学习总结
目录 一.JavaScript学习总结 1.什么是JavaScript 2.变量 3.变量命名 4.操作符 5.遍历语句 6.函数 7.对象 8.数组 二.TypeScript学习总结 1.什么是Ty ...
- http如何全站301重定向到https
对于301重定向这一概念玩SEO的同志们都不陌生了,近些年来https协议越来越火,谷歌已经明确了使用https相对http来说会有更好的排名,再加上百度大大已经明确了对https的扶持政策,老威现在 ...
- transform2d转换、transition过渡、animation动画效果、@keyframes定义动画关键帧
transform:translate( 0 , 0 ); -ms-transform:translate( 0 , 0 ); /* IE 9 */ -webkit-transform:transla ...
- 003. html篇之《表单》
html篇之<表单> 一.结构 <form action="url" method="post" name=""> ...