Ethscriptions commited on
Commit
01adbf5
·
1 Parent(s): b86d00c

Delete data

Browse files
data/.DS_Store DELETED
Binary file (6.15 kB)
 
data/config.ini DELETED
@@ -1,2 +0,0 @@
1
- [thread_start_state]
2
- state = 0
 
 
 
data/eths_data.db DELETED
Binary file (8.19 kB)
 
data/ethscriptions_data.db DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:944108f6cb91e9cfe369f084ad89c32022a5eba06929d4f93e3e1f0e42e88d50
3
- size 400863232
 
 
 
 
data/huggingface_name_code.py DELETED
@@ -1,275 +0,0 @@
1
- # EthPen.com
2
- # 最后更新日期:2023 年 9 月 5 日
3
-
4
-
5
- # 导入运行代码所需要的库
6
- import streamlit as st # streamlit app
7
- from web3 import Web3 # 与以太坊交互的库
8
- import hashlib # 用于数据哈希
9
- import requests # 用于发送网络请求
10
- import re # 用于正则表达式
11
- import time # 用于时间相关
12
- import os # 用于操作系统文件
13
-
14
-
15
- # 许可使用开关
16
- approved_use = False
17
-
18
-
19
- # 检查 ETH 地址是否有效
20
- def is_valid_eth_address(address):
21
- if re.match("^0x[0-9a-fA-F]{40}$", address):
22
- return True
23
- return False
24
-
25
-
26
- # 检查 Ethereum 私钥是否有效
27
- def is_valid_eth_private_key(private_key):
28
- if re.match("^[0-9a-fA-F]{64}$", private_key):
29
- return True
30
- return False
31
-
32
-
33
- # 验证输入的铭文文本是否含有空格和换行符,而且字母全部为小写
34
- def validate_input(data_str):
35
- if re.search(r'[A-Z\s\n]', data_str): # 查找大写字母、空格或换行符
36
- return False
37
- return True
38
-
39
-
40
- # 分隔文本函数
41
- def split_and_append(ethscriptions_str, name_selected_option):
42
- separators = [' ', '\n', ',']
43
- split_texts = [ethscriptions_str] # 初始时只有一个完整文本
44
-
45
- for sep in separators:
46
- pieces = []
47
- for text in split_texts:
48
- pieces.extend(text.split(sep))
49
- split_texts = pieces
50
-
51
- # 移除空字符串
52
- split_texts = [text.strip() + name_selected_option for text in split_texts if text.strip() != '']
53
-
54
- return split_texts
55
-
56
-
57
- # 把文字转换成 16 进制
58
- def text_to_hex(text):
59
- return ''.join(format(byte, '02x') for byte in text.encode('utf-8'))
60
-
61
-
62
- # 使用sha256算法计算哈希
63
- def sha256(input_string):
64
- sha256 = hashlib.sha256()
65
- sha256.update(input_string.encode('utf-8'))
66
- return sha256.hexdigest()
67
-
68
-
69
- # 使用 Ethscriptions API(主网)检查某个铭文是否已题写
70
- def check_content_exists(sha):
71
- # 定义请求的网址
72
- endpoint = f"/ethscriptions/exists/{sha}"
73
- response = requests.get('https://mainnet-api.ethscriptions.com/api' + endpoint)
74
- # 如果返回状态码是200,说明请求成功,然后返回结果(Ture or False)
75
- if response.status_code == 200:
76
- return response.json()['result']
77
-
78
-
79
- # 发送自己到自己 0ETH 的交易
80
- def send_transaction(w3, account_address, private_key, chain_id, gas_price, input_data, current_nonce):
81
-
82
- # 设置交易的相关信息
83
- tx = {
84
- 'chainId': chain_id, # 网络 ID
85
- 'gas': 25000, # 如果交易 gas 过低,可适当调高
86
- 'gasPrice': gas_price, # gas 的价格
87
- 'nonce': current_nonce,
88
- 'to': account_address, # 接收地址为自己
89
- 'value': 0, # 金额为 0ETH
90
- 'data': text_to_hex(input_data), # 铭文内容
91
- }
92
-
93
- # 用私钥签名这个交易
94
- signed_tx = w3.eth.account.sign_transaction(tx, private_key)
95
- # 发送签名后的交易并获取交易哈希
96
- tx_hash = w3.eth.send_raw_transaction(signed_tx.rawTransaction)
97
- # 打印结果信息
98
- st.toast(f'{input_data}', icon='✅')
99
- # 返回铭文还有交易哈希
100
- return input_data, tx_hash.hex()
101
-
102
-
103
- # 网页前端显示
104
- st.set_page_config(page_title="EthPen - 批量题写域名铭文", page_icon="🆔", layout='centered', initial_sidebar_state='auto')
105
-
106
- # 网页标题
107
- st.subheader(r'🆔 :rainbow[EthPen - 域名铭文批量题写]', anchor=False, divider='rainbow')
108
-
109
- # 提醒
110
- st.markdown('### 在开始使用前,请仔细阅读相关说明,并在确认无误后打上 ✅。感谢您的理解与配合。')
111
-
112
- open_source = st.checkbox('我们已将网站代码完全开源。您可以访问并仔细阅读此页面的源码:[2_🆔_批量题写域名铭文.py](https://huggingface.co/spaces/Ethscriptions/eths/tree/main/pages)',)
113
-
114
- ask_ai = st.checkbox('如果你对此代码存有疑虑,建议你利用如 [OpenAI - ChetGPT](https://chat.openai.com/)、[Google - Bard](https://bard.google.com/)、[Anthropic - Claude](https://claude.ai/)、[抖音 - 豆包](https://www.doubao.com/)、[百度 - 文心一言](https://yiyan.baidu.com/)、[阿里 - 通义千问](https://qianwen.aliyun.com/) 等知名 AI 平台进行问询,这可以帮助你判断代码是否含有恶意内容。',)
115
-
116
- huggingface = st.checkbox('复制我们的代码,你同样可以在 [HuggingFace](https://HuggingFace.co) 上搭建专属于你的域名铭文批量题写工具。',)
117
-
118
- site = st.checkbox('请务必确保你正在访问的是 **[EthPen.com](https://ethpen.com)** 网站。我们保证站内代码不包含窃取私钥或其他恶意行为,你可以安心使用。',)
119
-
120
- use = st.checkbox('在使用过程中,请按照提示准确地填写信息,这样可以确保程序的顺畅运行。',)
121
-
122
- wallet = st.checkbox('为了安全起见,我们建议您使用备用账号(小号)并确保账号中不存放大额资金。',)
123
-
124
- test = st.checkbox('首次使用时,我们建议您先在测试网络中操作。确认一切无误后,再切换至主网络��用。',)
125
-
126
- feedback = st.checkbox('若您在使用过程中遇到问题,请及时向我们反馈。我们明白程序可能存在不完善之处,并且我们的能力也有限。真心希望得到各位程序员大佬的指导和交流。',)
127
-
128
- if open_source and ask_ai and huggingface and site and use and wallet and test and feedback:
129
- approved_use = True
130
- else:
131
- approved_use = False
132
-
133
- if approved_use:
134
-
135
- st.markdown('## 批量题写域名铭文')
136
-
137
- # 连接的网络 ID。比如说,1 代表主网络,5 代表 Goerli 测试网络,11155111 代表 Sepolia 测试网络,如果你不放心,可以先用测试网试试。
138
- net_options = {
139
- '1': 'Mainnet',
140
- '5': 'Goerli',
141
- '11155111': 'Sepolia'
142
- }
143
- selected_option = st.selectbox(
144
- '**网络 ID**',
145
- list(net_options.keys()),
146
- format_func=lambda x: f"{x} ({net_options[x]})"
147
- )
148
- chain_id = int(selected_option)
149
-
150
- # 这里配置 Ethereum PRC URL,如果你没有,请到 infura.io 或者 alchemy.com 申请一个免费的 API
151
- token_eth_prc_url = st.text_input(
152
- f'**Ethereum PRC 链接**:选填,你可以去 [infura.io](https://app.infura.io/) 或者 [alchemy.com](https://alchemy.com/) 免费申请一个',
153
- f'https://{net_options[str(chain_id)]}.infura.io/v3/eab7f935b9af45e1a54f7d7ed06c5206')
154
- w3 = Web3(Web3.HTTPProvider(f'{token_eth_prc_url}'))
155
- # 初始化当前账户索引为 0
156
- current_account_index = 0
157
- # 收集和显示所有交易的结果
158
- transaction_results = []
159
- # 创建账户列表
160
- accounts = []
161
- # 使用字典来跟踪每个地址的nonce
162
- nonces = {}
163
-
164
- # 启用多账户操作
165
- multipl_accounts = st.toggle('启用**多账户**操作')
166
- if multipl_accounts:
167
- # 多账户的文本框
168
- account_list = st.text_area(f'输入多个 **ETH 地址及其对应的私钥**,用英文逗号分隔(,),如下:地址,私钥')
169
- if account_list: # 如果账户列表有内容
170
- for line in account_list.split('\n'): # 根据换行符划分账户
171
- if ',' in line: # 检查是否包含逗号
172
- address, key = line.split(',') # 分开地址和私钥
173
- if is_valid_eth_address(address) and is_valid_eth_private_key(key): # 验证地址和私钥
174
- current_nonce = w3.eth.get_transaction_count(address) # 获取地址的 nonce
175
- nonces[address] = current_nonce # 记录地址的 nonce
176
- accounts.append((address.strip(), key.strip())) # 保存地址和私钥还有 nonce
177
- else:
178
- st.error(f"地址 {address} 或私钥 {key} 无效,请检查!")
179
- st.stop()
180
- else:
181
- st.error(f"输入格式错误,请确保每行包含一个地址和一个私钥,并使用英文逗号分隔(,)。错误行:**{line}**")
182
- st.stop()
183
- else:
184
- account_address = st.text_input('填写你的 **ETH 地址**:')
185
- private_key = st.text_input('填写你的 **ETH 地址对应的私钥**:', type="password")
186
- if account_address and private_key: # 如果地址和私钥有内容
187
- if is_valid_eth_address(account_address) and is_valid_eth_private_key(private_key): # 验证地址和私钥
188
- current_nonce = w3.eth.get_transaction_count(account_address) # 获取地址的 nonce
189
- nonces[account_address] = current_nonce # 记录地址的 nonce
190
- accounts.append((account_address.strip(), private_key.strip())) # 保存地址和私钥还有 nonce
191
- else:
192
- st.error("地址或私钥无效,请检查!")
193
- st.stop()
194
-
195
- # 配置铭文文本
196
- ethscriptions_str = st.text_area(f'输入**多个域名铭文或其他**,可以用`空格`、`换行符`、`英文逗号(,)`分开,不要带 `data:,` 前缀,不要带`域名后缀`:')
197
-
198
- name_selected_option = st.radio("选择域名后缀:", ['🎨 自定义', '🆔.eths', '🆔.eth', '🌲.tree', '🦛.honk', '🔄.etch', '🌐.com'], index=1, horizontal=True)
199
- if name_selected_option == '🎨 自定义':
200
- name_selected_option = st.text_input('输入**域名后缀**:')
201
-
202
- # 以空格、换行符、英文逗号分隔文本并加上后缀
203
- ethscription_list = split_and_append(ethscriptions_str, name_selected_option)
204
-
205
- # 判断铭文文本里是否包含空格、换行符,而且所有的字母都必须为小写。
206
- if not validate_input(''.join(ethscription_list)):
207
- st.warning("**请注意**:通常代币铭文文本里不能包含空格、换行符,而且所有的字母都必须为小写。")
208
-
209
- token_check = st.toggle('题写前**检查是否被题写** `主网` `查重`')
210
- # 题写铭文之前检查该铭文有没有被题写
211
- if token_check:
212
- token_check = True
213
- else:
214
- token_check = False
215
- sleep_3s = st.toggle('每次完成交易后暂停 3 秒')
216
- # 每次交易成功后暂停 3 秒
217
- if sleep_3s:
218
- sleep_3s = True
219
- else:
220
- sleep_3s = False
221
-
222
- # 点击发送交易开始
223
- if st.button(f'开始**发送交易**'):
224
- if not accounts or not ethscriptions_str or not name_selected_option: # 检查是否留空
225
- st.error(f'请正确谨慎地填写内容,每一项都**不应留空**。')
226
- st.stop()
227
- else:
228
- st.toast('看起来你输入的内容均无没有问题!', icon='🥳')
229
-
230
- st.toast(f'开始任务,需要题写的铭文总量为:{len(ethscription_list)}', icon='😎')
231
-
232
- # 对代币铭文 id 进行循环
233
- for name_str in ethscription_list:
234
- # 使用当前账户发送交易,获取当前账户的 nonce
235
- address, key = accounts[current_account_index]
236
- # 获取 gas
237
- gas_price = w3.eth.gas_price
238
- # 得到完整的铭文文本
239
- if not name_str.startswith('data:,'):
240
- input_data = f'data:,{name_str}'
241
-
242
- # 根据是否检查的开关进行
243
- if token_check:
244
- # 这里是开了检查后请求 Ethscriptions API
245
- if check_content_exists(sha256(input_data)):
246
- # 返回数据为 Ture,说明该铭文已经被题写,打印信息
247
- st.toast(f'{input_data} 已经被题写!', icon='☹️')
248
- else:
249
- # 返回数据为 False,说明该铭文还没被题写,发送交易
250
- # 使用 current_nonce 发送交易
251
- data, tx_hash = send_transaction(w3, address, key, chain_id, gas_price, input_data, nonces[address])
252
- # 记录最后输出的结果
253
- transaction_results.append(f"{address} | {data} | Transaction Hash: {tx_hash}")
254
- # 交易成功后,手动增加 nonce 值
255
- nonces[address] += 1
256
- else:
257
- # 这里是未开检查后直接发送交易
258
- # 使用 current_nonce 发送交易
259
- data, tx_hash = send_transaction(w3, address, key, chain_id, gas_price, input_data, nonces[address])
260
- # 记录最后输出的结果
261
- transaction_results.append(f"{address} | {data} | Transaction Hash: {tx_hash}")
262
- # 交易成功后,手动增加 nonce 值
263
- nonces[address] += 1
264
- # 更新当前账户索引,确保索引始终在账户列表的范围内
265
- current_account_index = (current_account_index + 1) % len(accounts)
266
- # 暂停 3 秒
267
- if sleep_3s:
268
- time.sleep(3) # 暂停三秒
269
- st.toast(f'所有任务已经完成。', icon='🎉')
270
- # 庆祝动画
271
- st.balloons()
272
- # 显示所有交易的结果
273
- st.code('\n'.join(transaction_results))
274
- else:
275
- st.error('# 阅读并打勾 ✅ 后方可使用。')
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
data/huggingface_token_code.py DELETED
@@ -1,259 +0,0 @@
1
- # EthPen.com
2
- # 最后更新日期:2023 年 9 月 5 日
3
-
4
-
5
- # 导入运行代码所需要的库
6
- import streamlit as st # streamlit app
7
- from web3 import Web3 # 与以太坊交互的库
8
- import hashlib # 用于数据哈希
9
- import requests # 用于发送网络请求
10
- import re # 用于正则表达式
11
- import time # 用于时间相关
12
- import os # 用于操作系统文件
13
-
14
-
15
- # 许可使用开关
16
- approved_use = False
17
-
18
-
19
- # 检查 ETH 地址是否有效
20
- def is_valid_eth_address(address):
21
- if re.match("^0x[0-9a-fA-F]{40}$", address):
22
- return True
23
- return False
24
-
25
-
26
- # 检查 Ethereum 私钥是否有效
27
- def is_valid_eth_private_key(private_key):
28
- if re.match("^[0-9a-fA-F]{64}$", private_key):
29
- return True
30
- return False
31
-
32
-
33
- # 验证输入的铭文文本是否含有空格和换行符,而且字母全部为小写
34
- def validate_input(data_str):
35
- if re.search(r'[A-Z\s\n]', data_str): # 查找大写字母、空格或换行符
36
- return False
37
- return True
38
-
39
-
40
- # 把文字转换成 16 进制
41
- def text_to_hex(text):
42
- return ''.join(format(byte, '02x') for byte in text.encode('utf-8'))
43
-
44
-
45
- # 使用sha256算法计算哈希
46
- def sha256(input_string):
47
- sha256 = hashlib.sha256()
48
- sha256.update(input_string.encode('utf-8'))
49
- return sha256.hexdigest()
50
-
51
-
52
- # 使用 Ethscriptions API(主网)检查某个铭文是否已题写
53
- def check_content_exists(sha):
54
- # 定义请求的网址
55
- endpoint = f"/ethscriptions/exists/{sha}"
56
- response = requests.get('https://mainnet-api.ethscriptions.com/api' + endpoint)
57
- # 如果返回状态码是200,说明请求成功,然后返回结果(Ture or False)
58
- if response.status_code == 200:
59
- return response.json()['result']
60
-
61
-
62
- # 发送自己到自己 0ETH 的交易
63
- def send_transaction(w3, account_address, private_key, chain_id, gas_price, input_data, current_nonce):
64
-
65
- # 设置交易的相关信息
66
- tx = {
67
- 'chainId': chain_id, # 网络 ID
68
- 'gas': 25000, # 如果交易 gas 过低,可适当调高
69
- 'gasPrice': gas_price, # gas 的价格
70
- 'nonce': current_nonce,
71
- 'to': account_address, # 接收地址为自己
72
- 'value': 0, # 金额为 0ETH
73
- 'data': text_to_hex(input_data), # 铭文内容
74
- }
75
-
76
- # 用私钥签名这个交易
77
- signed_tx = w3.eth.account.sign_transaction(tx, private_key)
78
- # 发送签名后的交易并获取交易哈希
79
- tx_hash = w3.eth.send_raw_transaction(signed_tx.rawTransaction)
80
- # 打印结果信息
81
- st.toast(f'{input_data}', icon='✅')
82
- # 返回铭文还有交易哈希
83
- return input_data, tx_hash.hex()
84
-
85
-
86
- # 网页前端显示
87
- st.set_page_config(page_title="EthPen - 批量题写代币铭文", page_icon="🪙", layout='centered', initial_sidebar_state='auto')
88
-
89
- # 网页标题
90
- st.subheader(r'🪙 :rainbow[EthPen - 代币铭文批量题写]', anchor=False, divider='rainbow')
91
-
92
- # 提醒
93
- st.markdown('### 在开始使用前,请仔细阅读相关说明,并在确认无误后打上 ✅。感谢您的理解与配合。')
94
-
95
- open_source = st.checkbox('我们已将网站代码完全开源。您可以访问并仔细阅读此页面的源码:[3_🪙_ 批量题写代币铭文.py](https://huggingface.co/spaces/Ethscriptions/eths/tree/main/pages)',)
96
-
97
- ask_ai = st.checkbox('如果你对此代码存有疑虑,建议你利用如 [OpenAI - ChetGPT](https://chat.openai.com/)、[Google - Bard](https://bard.google.com/)、[Anthropic - Claude](https://claude.ai/)、[抖音 - 豆包](https://www.doubao.com/)、[百度 - 文心一言](https://yiyan.baidu.com/)、[阿里 - 通义千问](https://qianwen.aliyun.com/) 等知名 AI 平台进行问询,这可以帮助你判断代码是否含有恶意内容。',)
98
-
99
- huggingface = st.checkbox('复制我们的代码,你同样可以在 [HuggingFace](https://HuggingFace.co) 上搭建专属于你的域名铭文批量题写工具。',)
100
-
101
- site = st.checkbox('请务必确保你正在访问的是 **[EthPen.com](https://ethpen.com)** 网站。我们保证站内代码不包含窃取私钥或其他恶意行为,你可以安心使用。',)
102
-
103
- use = st.checkbox('在使用过程中,请按照提示准确地填写信息,这样可以确保程序的顺畅运行。',)
104
-
105
- wallet = st.checkbox('为了安全起见,我们建议您使用备用账号(小号)并确保账号中不存放大额资金。',)
106
-
107
- test = st.checkbox('首次使用时,我们建议您先在测试网络中操作。确认一切无误后,再切换至主网络使用。',)
108
-
109
- feedback = st.checkbox('若您在使用过程中遇到问题,请及时向我们反馈。我们明白程序可能存在不完善之处,并且我们的能力也有限。真心希望得到各位程序员大佬的指导和交流。',)
110
-
111
- if open_source and ask_ai and huggingface and site and use and wallet and test and feedback:
112
- approved_use = True
113
- else:
114
- approved_use = False
115
-
116
- if approved_use:
117
-
118
- st.markdown('## 批量题写代币铭文')
119
-
120
- # 连接的网络 ID。比如说,1 代表 Mainnet,5 代表 Goerli 测试网络,11155111 代表 Sepolia 测试网络,如果你不放心,可以先用测试网试试。
121
- net_options = {
122
- '1': 'Mainnet',
123
- '5': 'Goerli',
124
- '11155111': 'Sepolia'
125
- }
126
- selected_option = st.selectbox(
127
- '**网络 ID**',
128
- list(net_options.keys()),
129
- format_func=lambda x: f"{x} ({net_options[x]})"
130
- )
131
- chain_id = int(selected_option)
132
-
133
- # 这里配置 Ethereum PRC URL,如果你没有,请到 infura.io 或者 alchemy.com 申请一个免费的 API
134
- token_eth_prc_url = st.text_input(
135
- f'**Ethereum PRC 链接**:选填,你可以去 [infura.io](https://app.infura.io/) 或者 [alchemy.com](https://alchemy.com/) 免费申请一个',
136
- f'https://{net_options[str(chain_id)]}.infura.io/v3/eab7f935b9af45e1a54f7d7ed06c5206')
137
- w3 = Web3(Web3.HTTPProvider(f'{token_eth_prc_url}'))
138
-
139
- # 初始化当前账户索引为 0
140
- current_account_index = 0
141
- # 收集和显示所有交易的结果
142
- transaction_results = []
143
- # 创建账户列表
144
- accounts = []
145
- # 使用字典来跟踪每个地址的nonce
146
- nonces = {}
147
-
148
- # 启用多账户操作
149
- multipl_accounts = st.toggle('启用**多账户**操作')
150
- if multipl_accounts:
151
- # 多账户的文本框
152
- account_list = st.text_area(f'输入多个 **ETH 地址及其对应的私钥**,用英文逗号分隔(,),如下:地址,私钥')
153
- if account_list: # 如果账户列表有内容
154
- for line in account_list.split('\n'): # 根据换行符划分账户
155
- if ',' in line: # 检查是否包含逗号
156
- address, key = line.split(',') # 分开地址和私钥
157
- if is_valid_eth_address(address) and is_valid_eth_private_key(key): # 验证地址和私钥
158
- current_nonce = w3.eth.get_transaction_count(address) # 获取地址的 nonce
159
- nonces[address] = current_nonce # 记录地址的 nonce
160
- accounts.append((address.strip(), key.strip())) # 保存地址和私钥还有 nonce
161
- else:
162
- st.error(f"地址 {address} 或私钥 {key} 无效,请检查!")
163
- st.stop()
164
- else:
165
- st.error(f"输入格式错误,请确保每行包含一个地址和一个私钥,并使用英文逗号分隔(,)。错误行:**{line}**")
166
- st.stop()
167
- else:
168
- account_address = st.text_input('填写你的 **ETH 地址**:')
169
- private_key = st.text_input('填写你的 **ETH 地址对应的私钥**:', type="password")
170
- if account_address and private_key: # 如果地址和私钥有内容
171
- if is_valid_eth_address(account_address) and is_valid_eth_private_key(private_key): # 验证地址和私钥
172
- current_nonce = w3.eth.get_transaction_count(account_address) # 获取地址的 nonce
173
- nonces[account_address] = current_nonce # 记录地址的 nonce
174
- accounts.append((account_address.strip(), private_key.strip())) # 保存地址和私钥还有 nonce
175
- else:
176
- st.error("地址或私钥无效,请检查!")
177
- st.stop()
178
-
179
- # 配置铭文文本
180
- token_protocol = st.text_input('填写需要题写代币铭文协议 **Protocol(p)**:', 'erc-20')
181
- token_operation = st.text_input('填写需要题写代币铭文操作 **Operation(op)**:', 'mint')
182
- token_ticker = st.text_input('填写需要题写代币铭文简称 **Ticker(tick)**:')
183
- token_min_id = st.number_input('填写需要题写代币铭文范围的**最小 ID(id)**:', min_value=1, value=1, step=1)
184
- token_max_id = st.number_input('填写需要题写代币铭文范围的**最大 ID(id)**:', value=21000, step=1)
185
- token_amount = st.number_input('填写需要题写代币铭文数量 **Amount(amt)**:', min_value=1, value=1000, step=1)
186
- st.markdown('###### 预览代币铭文:')
187
- st.code(
188
- f'data:,{{"p":"{token_protocol}","op":"{token_operation}","tick":"{token_ticker}","id":"{token_min_id}","amt":"{token_amount}"}}',
189
- language="json", line_numbers=False)
190
- # 判断铭文文本里是否包含空格、换行符,而且所有的字母都必须为小写。
191
- if not validate_input(
192
- f'data:,{{"p":"{token_protocol}","op":"{token_operation}","tick":"{token_ticker}","id":"{token_min_id}","amt":"{token_amount}"}}'):
193
- st.warning("**请注意**:通常代币铭文文本里不能包含空格、换行符,而且所有的字母都必须为小写。")
194
-
195
- token_check = st.toggle('题写前**检查是否被题写** `主网` `查重`')
196
- # 题写铭文之前检查该铭文有没有被题写
197
- if token_check:
198
- token_check = True
199
- else:
200
- token_check = False
201
- sleep_3s = st.toggle('每次完成交易后暂停 3 秒')
202
- # 每次交易成功后暂停 3 秒
203
- if sleep_3s:
204
- sleep_3s = True
205
- else:
206
- sleep_3s = False
207
-
208
- # 点击发送交易开始
209
- if st.button(f'开始**发送交易**'):
210
- if not accounts or not token_protocol or not token_operation or not token_ticker: # 检查是否留空
211
- st.error(f'请正确谨慎地填写内容,每一项都**不应留空**。')
212
- st.stop()
213
- else:
214
- st.toast('看起来你输入的内容均无没有问题!', icon='🥳')
215
-
216
- st.toast(f'开始任务,需要题写的铭文总量为:{token_max_id - token_min_id + 1}', icon='😎')
217
-
218
- # 对代币铭文 id 进行循环
219
- for the_id in range(token_min_id, token_max_id + 1):
220
- # 使用当前账户发送交易,获取当前账户的 nonce
221
- address, key = accounts[current_account_index]
222
- # 得到完整的铭文文本
223
- input_data = f'data:,{{"p":"{token_protocol}","op":"{token_operation}","tick":"{token_ticker}","id":"{the_id}","amt":"{token_amount}"}}'
224
- # 获取 gas
225
- gas_price = w3.eth.gas_price
226
- # 根据是否检查的开关进行
227
- if token_check:
228
- # 这里是开了检查后请求 Ethscriptions API
229
- if check_content_exists(sha256(input_data)):
230
- # 返回数据为 Ture,说明该铭文已经被题写,打印信息
231
- st.toast(f'{input_data} 已经被题写!', icon='☹️')
232
- else:
233
- # 返回数据为 False,说明该铭文还没被题写,发送交易
234
- # 使用 current_nonce 发送交易
235
- data, tx_hash = send_transaction(w3, address, key, chain_id, gas_price, input_data, nonces[address])
236
- # 记录最后输出的结果
237
- transaction_results.append(f"{address} | {data} | Transaction Hash: {tx_hash}")
238
- # 交易成功后,手动增加 nonce 值
239
- nonces[address] += 1
240
- else:
241
- # 这里是未开检查后直接发送交易
242
- # 使用 current_nonce 发送交易
243
- data, tx_hash = send_transaction(w3, address, key, chain_id, gas_price, input_data, nonces[address])
244
- # 记录最后输出的结果
245
- transaction_results.append(f"{address} | {data} | Transaction Hash: {tx_hash}")
246
- # 交易成功后,手动增加 nonce 值
247
- nonces[address] += 1
248
- # 更新当前账户索引,确保索引始终在账户列表的范围内
249
- current_account_index = (current_account_index + 1) % len(accounts)
250
- # 暂停 3 秒
251
- if sleep_3s:
252
- time.sleep(3) # 暂停三秒
253
- st.toast(f'所有任务已经完成。', icon='🎉')
254
- # 庆祝动画
255
- st.balloons()
256
- # 显示所有交易的结果
257
- st.code('\n'.join(transaction_results))
258
- else:
259
- st.error('# 阅读并打勾 ✅ 后方可使用。')
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
data/name_set.db DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:7c6df1a5d9ca13bfbbf154928baf0602f1103010dcbfb6601d3c511eff1fece7
3
- size 2383872
 
 
 
 
data/python_name_code.py DELETED
@@ -1,201 +0,0 @@
1
- # EthPen.com
2
- # 最后更新日期:2023 年 8 月 18 日
3
-
4
- # 在开始使用前,请仔细阅读相关说明。感谢您的理解与配合。
5
- # 我们已将网站代码完全开源。您可以访问并仔细阅读此页面的源码:[2_🆔_批量题写域名铭文.py](https://huggingface.co/spaces/Ethscriptions/eths/tree/main/pages)
6
- # 如果你对此代码存有疑虑,建议你利用如 [OpenAI - ChetGPT](https://chat.openai.com/)、[Google - Bard](https://bard.google.com/)、[Anthropic - Claude](https://claude.ai/)、[抖音 - 豆包](https://www.doubao.com/)、[百度 - 文心一言](https://yiyan.baidu.com/)、[阿里 - 通义千问](https://qianwen.aliyun.com/) 等知名 AI 平台进行问询,这可以帮助你判断代码是否含有恶意内容。
7
- # 复制我们的代码,你同样可以在 [HuggingFace](https://HuggingFace.co) 上搭建专属于你的域名铭文批量题写工具。
8
- # 请务必确保你正在访问的是 [EthPen.com](https://ethpen.com) 网站。我们保证站内代码不包含窃取私钥或其他恶意行为,你可以安心使用。
9
- # 在使用过程中,请按照提示准确地填写信息,这样可以确保程序的顺畅运行。
10
- # 为了安全起见,我们建议您使用备用账号(小号)并确保账号中不存放大额资金。
11
- # 首次使用时,我们建议您先在测试网络中操作。确认一切无误后,再切换至主网络使用。
12
- # 若您在使用过程中遇到问题,请及时向我们反馈。我们明白程序可能存在不完善之处,并且我们的能力也有限。真心希望得到各位程序员大佬的指导和交流。
13
-
14
- # 导入运行代码所需要的库
15
- from web3 import Web3 # 与以太坊交互的库,安装的命令是 pip install web3
16
- import hashlib # 用于数据哈希,安装的命令是 pip install hashlib
17
- import requests # 用于发送网络请求,安装的命令是 pip install requests
18
- import re # 用于正则表达式
19
- import time # 用于时间相关
20
-
21
- # ---------- 以下是基础配置 ----------
22
-
23
- # 填写你的多个 ETH 地址及私钥,建议填写新建的钱包,用英文逗号分隔(,),如下:地址,私钥。
24
- accounts_str = '''
25
- 账户1,私钥1
26
- 账户2,私钥2
27
- 账户3,私钥3
28
- '''
29
-
30
- # 需要题写的铭文内容,在三个单引号内输入多个域名铭文,可以用空格、换行符、英文逗号(,)分开,不要带 data:, 开头
31
- # 不要带 data:, 开头
32
- # 不要带 data:, 开头
33
- ethscription = '''
34
- 123
35
- abcedfg
36
- xyz 987
37
- 哈哈哈 你好
38
- 👋 😊
39
- ethpen.com
40
- '''
41
- # 你希望添加的后缀
42
- suffix = '.eths'
43
- # 以空格、换行符、英文逗号分隔文本,并加上后缀
44
- ethscription_list = [item.strip() + suffix for item in re.split(r'[\s,]+', ethscription) if item]
45
-
46
- # 决定是否在题写铭文之前检查该铭文有没有被题写过,如果需要检查就填写 Ture 如果不需要就填 False
47
- check = False
48
-
49
- # 每次交易成功后暂停 N 秒,0 为不暂停
50
- sleep_sec = 0
51
-
52
- # 这里配置 Ethereum PRC URL,如果你没有,请到 infura.io 或者 alchemy.com 申请一个免费的 API
53
- w3 = Web3(Web3.HTTPProvider('https://sepolia.infura.io/v3/eab7f935b9af45e1a54f7d7ed06c5206'))
54
-
55
- # 连接的网络 ID。比如说,1 代表 Mainnet,5 代表 Goerli 测试网络,11155111 代表 Sepolia 测试网络,如果你不放心,可以先用测试网试试。
56
- chain_id = 11155111
57
-
58
- # ---------- 以上是基础配置 ----------
59
-
60
-
61
- # 检查 ETH 地址是否有效
62
- def is_valid_eth_address(address):
63
- if re.match("^0x[0-9a-fA-F]{40}$", address):
64
- return True
65
- return False
66
-
67
-
68
- # 检查 Ethereum 私钥是否有效
69
- def is_valid_eth_private_key(private_key):
70
- if re.match("^[0-9a-fA-F]{64}$", private_key):
71
- return True
72
- return False
73
-
74
-
75
- # 验证输入的铭文文本是否含有空格和换行符,而且字母全部为小写
76
- def validate_input(data_str):
77
- if re.search(r'[A-Z\s\n]', data_str): # 查找大写字母、空格或换行符
78
- return False
79
- return True
80
-
81
-
82
- # 把文字转换成 16 进制
83
- def text_to_hex(text):
84
- return ''.join(format(ord(char), '02x') for char in text)
85
-
86
-
87
- # 使用sha256算法计算哈希
88
- def sha256(input_string):
89
- sha256 = hashlib.sha256()
90
- sha256.update(input_string.encode('utf-8'))
91
- return sha256.hexdigest()
92
-
93
-
94
- # 使用 Ethscriptions API(主网)检查某个铭文是否已存在
95
- def check_content_exists(sha):
96
- # 定义请求的网址
97
- endpoint = f"/ethscriptions/exists/{sha}"
98
- response = requests.get('https://mainnet-api.ethscriptions.com/api' + endpoint)
99
- # 如果返回状态码是200,说明请求成功,然后返回结果(Ture or False)
100
- if response.status_code == 200:
101
- return response.json()['result']
102
-
103
-
104
- # 发送自己到自己 0ETH 的交易
105
- def send_transaction(w3, account_address, private_key, chain_id, gas_price, input_data, current_nonce):
106
-
107
- # 设置交易的相关信息
108
- tx = {
109
- 'chainId': chain_id, # 网络 ID
110
- 'gas': 25000, # 如果交易 gas 过低,可适当调高
111
- 'gasPrice': gas_price, # gas 的价格
112
- 'nonce': current_nonce, # 账户的交易数
113
- 'to': account_address, # 接收地址为自己
114
- 'value': 0, # 金额为 0ETH
115
- 'data': text_to_hex(input_data), # 铭文内容
116
- }
117
-
118
- # 用私钥签名这个交易
119
- signed_tx = w3.eth.account.sign_transaction(tx, private_key)
120
- # 发送签名后的交易并获取交易哈希
121
- tx_hash = w3.eth.send_raw_transaction(signed_tx.rawTransaction)
122
- # 打印结果信息
123
- print(f'{account_address} | {input_data} | Transaction Hash: {tx_hash.hex()}')
124
-
125
-
126
- # 初始化当前账户索引为 0
127
- current_account_index = 0
128
- # 创建账户列表
129
- accounts = []
130
- # 使用字典来跟踪每个地址的nonce
131
- nonces = {}
132
-
133
-
134
- if accounts_str: # 如果账户列表有内容
135
- for line in accounts_str.strip().split('\n'): # 先去掉首尾的空白,然后根据换行符划分账户
136
- if ',' in line: # 检查是否包含逗号
137
- address, key = line.split(',') # 分开地址和私钥
138
- if is_valid_eth_address(address) and is_valid_eth_private_key(key): # 验证地址和私钥
139
- current_nonce = w3.eth.get_transaction_count(address) # 获取地址的 nonce
140
- nonces[address] = current_nonce # 记录地址的 nonce
141
- accounts.append((address.strip(), key.strip())) # 保存地址和私钥还有 nonce
142
- else:
143
- print(f"地址 {address} 或私钥 {key} 无效,请检查!")
144
- exit()
145
- else:
146
- print(f"输入格式错误,请确保每行包含一个地址和一个私钥,并使用英文逗号分隔(,)。错误行:**{line}**")
147
- exit()
148
-
149
- # 判断铭文文本里是否包含空格、换行符,而且所有的字母都必须为小写。
150
- if not validate_input(ethscription):
151
- print("请注意:通常代币铭文文本里不能包含空格、换行符,而且所有的字母都必须为小写。")
152
-
153
- # 检查是否留空
154
- if not accounts or not ethscription:
155
- print('请正确谨慎地填写内容,每一项都不应留空。')
156
- exit()
157
- else:
158
- print('看起来你输入的内容均无没有问题!')
159
-
160
- # 认真检查铭文内容,如果发现错误,输入 1 结束
161
- for i in ethscription_list:
162
- print(f'\033[44m{i}\033[m')
163
- if input('请预览铭文,输入任意内容继续,输入 1 退出程序:') == '1':
164
- exit()
165
- print(f'开始任务,需要题写的铭文总量为:{len(ethscription_list)}')
166
-
167
- # 对代币铭文 id 进行循环
168
- for name_str in ethscription_list:
169
- # 使用当前账户发送交易
170
- address, key = accounts[current_account_index]
171
- # 得到完整的铭文文本
172
- if not name_str.startswith('data:,'):
173
- input_data = f'data:,{name_str}'
174
- else:
175
- input_data = name_str
176
- # 获取 gas
177
- gas_price = w3.eth.gas_price
178
- # 根据是否检查的开关进行
179
- if check:
180
- # 这里是开了检查后请求 Ethscriptions API
181
- if check_content_exists(sha256(input_data)):
182
- # 返回数据为 Ture,说明该铭文已经被题写,打印信息
183
- print(f'{input_data} 已经被题写!')
184
- else:
185
- # 返回数据为 False,说明该铭文还没被题写,发送交易
186
- # 使用 current_nonce 发送交易
187
- send_transaction(w3, address, key, chain_id, gas_price, input_data, nonces[address])
188
- # 交易成功后,手动增加 nonce 值
189
- nonces[address] += 1
190
- else:
191
- # 这里是未开检查后直接发送交易
192
- # 使用 current_nonce 发送交易
193
- send_transaction(w3, address, key, chain_id, gas_price, input_data, nonces[address])
194
- # 交易成功后,手动增加 nonce 值
195
- nonces[address] += 1
196
- # 更新当前账户索引,确保索引始终在账户列表的范围内
197
- current_account_index = (current_account_index + 1) % len(accounts)
198
- # 暂停 sleep_sec 秒
199
- time.sleep(sleep_sec)
200
-
201
- print(f'所有任务已经完成。')
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
data/python_token_code.py DELETED
@@ -1,189 +0,0 @@
1
- # EthPen.com
2
- # 最后更新日期:2023 年 8 月 18 日
3
-
4
- # 在开始使用前,请仔细阅读相关说明。感谢您的理解与配合。
5
- # 我们已将网站代码完全开源。您可以访问并仔细阅读此页面的源码:[3_🪙_ 批量题写代币铭文.py](https://huggingface.co/spaces/Ethscriptions/eths/tree/main/pages)
6
- # 如果你对此代码存有疑虑,建议你利用如 [OpenAI - ChetGPT](https://chat.openai.com/)、[Google - Bard](https://bard.google.com/)、[Anthropic - Claude](https://claude.ai/)、[抖音 - 豆包](https://www.doubao.com/)、[百度 - 文心一言](https://yiyan.baidu.com/)、[阿里 - 通义千问](https://qianwen.aliyun.com/) 等知名 AI 平台进行问询,这可以帮助你判断代码是否含有恶意内容。
7
- # 复制我们的代码,你同样可以在 [HuggingFace](https://HuggingFace.co) 上搭建专属于你的域名铭文批量题写工具。
8
- # 请务必确保你正在访问的是 [EthPen.com](https://ethpen.com) 网站。我们保证站内代码不包含窃取私钥或其他恶意行为,你可以安心使用。
9
- # 在使用过程中,请按照提示准确地填写信息,这样可以确保程序的顺畅运行。
10
- # 为了安全起见,我们建议您使用备用账号(小号)并确保账号中不存放大额资金。
11
- # 首次使用时,我们建议您先在测试网络中操作。确认一切无误后,再切换至主网络使用。
12
- # 若您在使用过程中遇到问题,请及时向我们反馈。我们明白程序可能存在不完善之处,并且我们的能力也有限。真心希望得到各位程序员大佬的指导和交流。
13
-
14
-
15
- # 导入运行代码所需要的库
16
- from web3 import Web3 # 与以太坊交互的库,安装的命令是 pip install web3
17
- import hashlib # 用于数据哈希,安装的命令是 pip install hashlib
18
- import requests # 用于发送网络请求,安装的命令是 pip install requests
19
- import re # 用于正则表达式
20
- import time # 用于时间相关
21
-
22
- # ---------- 以下是基础配置 ----------
23
-
24
- # 填写你的多个 ETH 地址及私钥,建议填写新建的钱包,用英文逗号分隔(,),如下:地址,私钥。
25
- accounts_str = '''
26
- 账户1,私钥1
27
- 账户2,私钥2
28
- 账户3,私钥3
29
- '''
30
-
31
- # 需要题写的代币铭文内容,变动的部分文本如 id 请用 "@#" 代替,例如:'data:,{"p":"erc-20","op":"mint","tick":"eths","id":"@#","amt":"1000"}'
32
- ethscription = 'data:,{"p":"erc-20","op":"mint","tick":"eths","id":"@#","amt":"1000"}'
33
-
34
- # 设置代币铭文 id 的起始和结束范围
35
- min_id = 100 # 开始的整数
36
- max_id = 888 # 结束的整数
37
-
38
- # 决定是否在题写铭文之前检查该铭文有没有被题写过,如果需要检查就填写 Ture 如果不需要就填 False
39
- check = False
40
-
41
- # 每次交易成功后暂停 N 秒,0 为不暂停
42
- sleep_sec = 0
43
-
44
- # 这里配置 Ethereum PRC URL,如果你没有,请到 infura.io 或者 alchemy.com 申请一个免费的 API
45
- w3 = Web3(Web3.HTTPProvider('https://sepolia.infura.io/v3/eab7f935b9af45e1a54f7d7ed06c5206'))
46
-
47
- # 连接的网络 ID。比如说,1 代表 Mainnet,5 代表 Goerli 测试网络,11155111 代表 Sepolia 测试网络,如果你不放心,可以先用测试网试试。
48
- chain_id = 11155111
49
-
50
- # ---------- 以上是基础配置 ----------
51
-
52
-
53
- # 检查 ETH 地址是否有效
54
- def is_valid_eth_address(address):
55
- if re.match("^0x[0-9a-fA-F]{40}$", address):
56
- return True
57
- return False
58
-
59
-
60
- # 检查 Ethereum 私钥是否有效
61
- def is_valid_eth_private_key(private_key):
62
- if re.match("^[0-9a-fA-F]{64}$", private_key):
63
- return True
64
- return False
65
-
66
-
67
- # 验证输入的铭文文本是否含有空格和换行符,而且字母全部为小写
68
- def validate_input(data_str):
69
- if re.search(r'[A-Z\s\n]', data_str): # 查找大写字母、空格或换行符
70
- return False
71
- return True
72
-
73
-
74
- # 把文字转换成 16 进制
75
- def text_to_hex(text):
76
- return ''.join(format(ord(char), '02x') for char in text)
77
-
78
-
79
- # 使用sha256算法计算哈希
80
- def sha256(input_string):
81
- sha256 = hashlib.sha256()
82
- sha256.update(input_string.encode('utf-8'))
83
- return sha256.hexdigest()
84
-
85
-
86
- # 使用 Ethscriptions API(主网)检查某个铭文是否已题写
87
- def check_content_exists(sha):
88
- # 定义请求的网址
89
- endpoint = f"/ethscriptions/exists/{sha}"
90
- response = requests.get('https://mainnet-api.ethscriptions.com/api' + endpoint)
91
- # 如果返回状态码是200,说明请求成功,然后返回结果(Ture or False)
92
- if response.status_code == 200:
93
- return response.json()['result']
94
-
95
-
96
- # 发送自己到自己 0ETH 的交易
97
- def send_transaction(w3, account_address, private_key, chain_id, gas_price, input_data, current_nonce):
98
-
99
- # 设置交易的相关信息
100
- tx = {
101
- 'chainId': chain_id, # 网络 ID
102
- 'gas': 25000, # 如果交易 gas 过低,可适当调高
103
- 'gasPrice': gas_price, # gas 的价格
104
- 'nonce': current_nonce, # 账户的交易数
105
- 'to': account_address, # 接收地址为自己
106
- 'value': 0, # 金额为 0ETH
107
- 'data': text_to_hex(input_data), # 铭文内容
108
- }
109
-
110
- # 用私钥签名这个交易
111
- signed_tx = w3.eth.account.sign_transaction(tx, private_key)
112
- # 发送签名后的交易并获取交易哈希
113
- tx_hash = w3.eth.send_raw_transaction(signed_tx.rawTransaction)
114
- # 打印结果信息
115
- print(f'{account_address} | {input_data} | Transaction Hash: {tx_hash.hex()}')
116
-
117
-
118
- # 初始化当前账户索引为 0
119
- current_account_index = 0
120
- # 创建账户列表
121
- accounts = []
122
- # 使用字典来跟踪每个地址的nonce
123
- nonces = {}
124
-
125
-
126
- if accounts_str: # 如果账户列表有内容
127
- for line in accounts_str.strip().split('\n'): # 先去掉首尾的空白,然后根据换行符划分账户
128
- if ',' in line: # 检查是否包含逗号
129
- address, key = line.split(',') # 分开地址和私钥
130
- if is_valid_eth_address(address) and is_valid_eth_private_key(key): # 验证地址和私钥
131
- current_nonce = w3.eth.get_transaction_count(address) # 获取地址的 nonce
132
- nonces[address] = current_nonce # 记录地址的 nonce
133
- accounts.append((address.strip(), key.strip())) # 保存地址和私钥还有 nonce
134
- else:
135
- print(f"地址 {address} 或私钥 {key} 无效,请检查!")
136
- exit()
137
- else:
138
- print(f"输入格式错误,请确保每行包含一个地址和一个私钥,并使用英文逗号分隔(,)。错误行:**{line}**")
139
- exit()
140
-
141
- # 判断铭文文本里是否包含空格、换行符,而且所有的字母都必须为小写。
142
- if not validate_input(ethscription):
143
- print("请注意:通常代币铭文文本里不能包含空格、换行符,而且所有的字母都必须为小写。")
144
-
145
- # 检查是否留空
146
- if not accounts or not ethscription:
147
- print('请正确谨慎地填写内容,每一项都不应留空。')
148
- exit()
149
- else:
150
- print('看起来你输入的内容均无没有问题!')
151
-
152
- # 认真检查铭文内容,如果发现错误,输入 1 结束
153
- print(f'铭文文本:\033[44m{ethscription}\033[m,题写 id 范围为:{min_id} - {max_id}。')
154
- if input('请预览铭文,输入任意内容继续,输入 1 退出程序:') == '1':
155
- exit()
156
- print(f'开始任务,需要题写的铭文总量为:{max_id - min_id + 1}')
157
-
158
- # 对代币铭文 id 进行循环
159
- for the_id in range(min_id, max_id + 1):
160
- # 使用当前账户发送交易
161
- address, key = accounts[current_account_index]
162
- # 得到完整的铭文文本
163
- input_data = ethscription.replace('@#', str(the_id))
164
- # 获取 gas
165
- gas_price = w3.eth.gas_price
166
- # 根据是否检查的开关进行
167
- if check:
168
- # 这里是开了检查后请求 Ethscriptions API
169
- if check_content_exists(sha256(input_data)):
170
- # 返回数据为 Ture,说明该铭文已经被题写,打印信息
171
- print(f'{input_data} 已经被题写!')
172
- else:
173
- # 返回数据为 False,说明该铭文还没被题写,发送交易
174
- # 使用 current_nonce 发送交易
175
- send_transaction(w3, address, key, chain_id, gas_price, input_data, nonces[address])
176
- # 交易成功后,手动增加 nonce 值
177
- nonces[address] += 1
178
- else:
179
- # 这里是未开检查后直接发送交易
180
- # 使用 current_nonce 发送交易
181
- send_transaction(w3, address, key, chain_id, gas_price, input_data, nonces[address])
182
- # 交易成功后,手动增加 nonce 值
183
- nonces[address] += 1
184
- # 更新当前账户索引,确保索引始终在账户列表的范围内
185
- current_account_index = (current_account_index + 1) % len(accounts)
186
- # 暂停 sleep_sec 秒
187
- time.sleep(sleep_sec)
188
-
189
- print(f'所有任务已经完成。')