Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
I
inscription-trade-py
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
haojie
inscription-trade-py
Commits
4e060829
Commit
4e060829
authored
Jul 03, 2023
by
haojie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initial commit
parent
07b88604
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
124 additions
and
9 deletions
+124
-9
.gitignore
+2
-0
Helper.py
+13
-8
config/__pycache__/env.cpython-38.pyc
+0
-0
config/env.example.py
+11
-0
recharge.py
+1
-1
transfer.py
+97
-0
No files found.
.gitignore
View file @
4e060829
...
@@ -4,3 +4,4 @@
...
@@ -4,3 +4,4 @@
/callback.py
/callback.py
/.idea
/.idea
/__pycache__
/__pycache__
/config/env.py
\ No newline at end of file
Helper.py
View file @
4e060829
...
@@ -7,8 +7,9 @@ from fake_useragent import UserAgent
...
@@ -7,8 +7,9 @@ from fake_useragent import UserAgent
from
aredis
import
StrictRedis
,
ConnectionPool
from
aredis
import
StrictRedis
,
ConnectionPool
from
web3
import
Web3
from
web3
import
Web3
from
web3.eth
import
AsyncEth
from
web3.eth
import
AsyncEth
from
config.env
import
redis_password
,
redis_host
uni256Max
=
2
**
256
uni256Max
=
2
**
256
class
RedisConnSingleton
(
object
):
class
RedisConnSingleton
(
object
):
...
@@ -22,7 +23,8 @@ class RedisConnSingleton(object):
...
@@ -22,7 +23,8 @@ class RedisConnSingleton(object):
:param kwargs:
:param kwargs:
"""
"""
if
cls
.
_instance
is
None
:
if
cls
.
_instance
is
None
:
cls
.
_instance
=
redis
.
ConnectionPool
(
max_connections
=
1000
,
host
=
'127.0.0.1'
,
port
=
6379
,
db
=
0
,
password
=
'12345678'
)
cls
.
_instance
=
redis
.
ConnectionPool
(
max_connections
=
1000
,
host
=
redis_host
,
port
=
6379
,
db
=
0
,
password
=
redis_password
)
return
cls
.
_instance
return
cls
.
_instance
...
@@ -37,7 +39,8 @@ class RedisConnectionPoolSingleton(object):
...
@@ -37,7 +39,8 @@ class RedisConnectionPoolSingleton(object):
:param kwargs:
:param kwargs:
"""
"""
if
cls
.
_instance
is
None
:
if
cls
.
_instance
is
None
:
cls
.
_instance
=
ConnectionPool
(
max_connections
=
1000
,
host
=
'127.0.0.1'
,
port
=
6379
,
db
=
0
,
password
=
'12345678'
)
cls
.
_instance
=
ConnectionPool
(
max_connections
=
1000
,
host
=
redis_host
,
port
=
6379
,
db
=
0
,
password
=
redis_password
)
return
cls
.
_instance
return
cls
.
_instance
...
@@ -181,13 +184,15 @@ class RedisCon:
...
@@ -181,13 +184,15 @@ class RedisCon:
class
Helper
:
class
Helper
:
"""公共基础类"""
"""公共基础类"""
@staticmethod
@staticmethod
def
getProxyLst
():
def
getProxyLst
():
"""获取代理列表"""
"""获取代理列表"""
proxy_lst
=
list
()
proxy_lst
=
list
()
for
i
in
range
(
5
):
for
i
in
range
(
5
):
try
:
try
:
response
=
requests
.
get
(
"https://proxy.webshare.io/api/v2/proxy/list/download/pgewrawzvvqtzwdzjfdfswvkwcjasmofoucnfyyq/-/any/username/direct/-/"
)
.
text
response
=
requests
.
get
(
"https://proxy.webshare.io/api/v2/proxy/list/download/pgewrawzvvqtzwdzjfdfswvkwcjasmofoucnfyyq/-/any/username/direct/-/"
)
.
text
a
=
response
.
split
(
'
\r\n
'
)
a
=
response
.
split
(
'
\r\n
'
)
proxy_lst
=
a
[:
-
1
]
proxy_lst
=
a
[:
-
1
]
proxy_lst
=
list
(
map
(
lambda
x
:
x
.
split
(
":"
),
proxy_lst
))
proxy_lst
=
list
(
map
(
lambda
x
:
x
.
split
(
":"
),
proxy_lst
))
...
@@ -309,10 +314,10 @@ class Helper:
...
@@ -309,10 +314,10 @@ class Helper:
@staticmethod
@staticmethod
def
getWeb3Eth
():
def
getWeb3Eth
():
eth_list
=
[
"https://eth-mainnet.g.alchemy.com/v2/fH-3go199OKvbKSovc84gAC6xa5Givlb"
,
eth_list
=
[
"https://eth-mainnet.g.alchemy.com/v2/fH-3go199OKvbKSovc84gAC6xa5Givlb"
,
"https://eth-mainnet.g.alchemy.com/v2/V3-I2bBqYoA_DfOZrhaWx-t4-6LTZawj"
,
"https://eth-mainnet.g.alchemy.com/v2/V3-I2bBqYoA_DfOZrhaWx-t4-6LTZawj"
,
"https://eth-mainnet.g.alchemy.com/v2/D2l8IHN-2UUYcZpzXDY5FvZlcDF7eb0Q"
,
"https://eth-mainnet.g.alchemy.com/v2/D2l8IHN-2UUYcZpzXDY5FvZlcDF7eb0Q"
,
"https://eth-mainnet.g.alchemy.com/v2/tvHBgnSsj41XjKC9Rqv_Hl-rQJ-VupbD"
,
"https://eth-mainnet.g.alchemy.com/v2/tvHBgnSsj41XjKC9Rqv_Hl-rQJ-VupbD"
,
"https://eth-mainnet.g.alchemy.com/v2/6nk8lAti4uVJ6WnqadrrPsx2mUxYM8rW"
]
"https://eth-mainnet.g.alchemy.com/v2/6nk8lAti4uVJ6WnqadrrPsx2mUxYM8rW"
]
eth
=
eth_list
[
0
]
eth
=
eth_list
[
0
]
# proxy = Helper.aiohttp_proxy_pool()
# proxy = Helper.aiohttp_proxy_pool()
# request_kwargs={"proxy": proxy}
# request_kwargs={"proxy": proxy}
...
...
config/__pycache__/env.cpython-38.pyc
0 → 100644
View file @
4e060829
File added
config/env.example.py
0 → 100644
View file @
4e060829
# 登录接口
login_api
=
''
# 用户名密码
login_params
=
''
# 获取任务接口
task_api
=
''
# redis
redis_host
=
'127.0.0.1'
redis_password
=
''
recharge.py
View file @
4e060829
...
@@ -68,7 +68,7 @@ async def rechargeList(web3, data):
...
@@ -68,7 +68,7 @@ async def rechargeList(web3, data):
# json转list
# json转list
result
=
json
.
loads
(
result
)
result
=
json
.
loads
(
result
)
# 检测5次
# 检测5次
for
i
in
range
(
0
,
5
):
for
i
in
range
(
5
):
for
item
in
result
:
for
item
in
result
:
# 判断是否存在
# 判断是否存在
if
item
[
'transaction_hash'
]
==
inscription_hash
:
if
item
[
'transaction_hash'
]
==
inscription_hash
:
...
...
transfer.py
0 → 100644
View file @
4e060829
import
asyncio
import
json
import
time
import
traceback
import
requests
from
Helper
import
RedisCon
,
Helper
import
logging
from
config.env
import
login_params
,
login_api
,
task_api
logging
.
basicConfig
(
level
=
logging
.
ERROR
,
filename
=
'recharge_error.log'
,
datefmt
=
'
%
Y/
%
m/
%
d
%
H:
%
M:
%
S'
,
format
=
'
%(asctime)
s -
%(name)
s -
%(levelname)
s -
%(lineno)
d -
%(module)
s -
%(message)
s'
)
logger
=
logging
.
getLogger
(
__name__
)
logger
.
setLevel
(
level
=
logging
.
DEBUG
)
# 登录的token
login_token
=
''
def
login
():
res
=
requests
.
post
(
login_api
,
data
=
login_params
)
.
text
res
=
json
.
loads
(
res
)
if
res
[
'code'
]
==
0
:
login_token
=
res
[
'data'
][
'access_token'
]
return
True
# 获取任务
def
get_admin_task
():
res
=
requests
.
get
(
task_api
,
headers
=
{
'authorization'
:
'Bearer '
+
login_token
,
})
.
text
res
=
json
.
loads
(
res
)
if
res
[
'code'
]
==
0
:
return
res
[
'data'
]
def
pay_order_status
(
status
,
url
,
data
):
header
=
{
'User-Agent'
:
'Apipost client Runtime/+https://www.apipost.cn/'
,
'authorization'
:
'Bearer '
+
login_token
,
}
data
[
'status'
]
=
status
print
(
'准备回调'
,
data
)
result
=
requests
.
post
(
url
,
headers
=
header
,
data
=
data
)
print
(
result
)
# if result.text == 'success':
# print("请求成功!")
# else:
# print("请求失败!")
logger
.
debug
(
f
">>>>tx_hash:{data['hash']} status:{status} url:{url}"
f
" 请求状态码:{result.status_code}"
)
async
def
rechargeList
(
web3
,
data
):
url
=
data
[
'notify_url'
]
to_address
=
data
[
'to'
]
from_address
=
data
[
'from'
]
# 交易类型
tran_type
=
data
[
'type'
]
status
=
3
# 默认转账失败
print
(
data
)
try
:
if
tran_type
==
1
:
# 铭文转移
pass
elif
tran_type
==
2
:
# 转账
pass
pay_order_status
(
status
,
url
,
data
)
except
Exception
as
e
:
print
(
e
)
def
main
():
while
True
:
tasks
=
list
()
loop
=
asyncio
.
get_event_loop
()
for
i
in
range
(
5
):
# 获取任务
task
=
get_admin_task
()
if
task
:
web3
=
Helper
.
getWeb3Eth
()
task
=
json
.
loads
(
task
)
# task
tasks
.
append
(
rechargeList
(
web3
,
task
))
loop
.
run_until_complete
((
asyncio
.
wait
(
tasks
,
timeout
=
30
)))
if
__name__
==
'__main__'
:
if
not
login_token
:
login_status
=
login
()
print
(
login_status
)
if
login_status
:
# 可以执行
main
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment