import streamlit as st
import requests
import re
import json
import hashlib
import pandas as pd
import base64
import sqlite3
import os
infura_api_key = "9bbc614b8a1d49d59869e97d0ee3bf61"
# Ethscriptions Mainnet API 的基础 URL
BASE_URL = "https://mainnet-api.ethscriptions.com/api"
# 获取当前文件目录
current_dir = os.path.dirname(os.path.abspath(__file__))
# 构造数据库文件路径
eths_db_file = os.path.join(current_dir, 'data', 'eths_data.db')
# Initialize connection to SQLite database
conn = sqlite3.connect(eths_db_file)
c = conn.cursor()
# Create table to store ETHS data
c.execute('''
CREATE TABLE IF NOT EXISTS eths_data
(date text,
eth_price real,
eths_price real,
eths_market_cap integer,
eths_owners integer,
eths_volume24h real,
eths_totalLocked integer,
eths_stakers integer,
eths_tvl real)
''')
# 查询地址所属代币铭文的 token 列表
token_list = [{'p': 'erc-20', 'tick': 'eths', 'id': 21000, 'amt': '1000'},
{'p': 'erc-20', 'tick': 'gwei', 'id': 21000, 'amt': '1000'},
{'p': 'erc-20', 'tick': 'ercs', 'id': 21000, 'amt': '1000'},
{'p': 'erc-20', 'tick': 'etch', 'id': 21000, 'amt': '1000'},
{'p': 'erc-20', 'tick': 'dumb', 'id': 21000, 'amt': '1000'}]
ethscrptions_logo = """
"""
python_token_code = r"""
# ethpen.com
# 最后更新日期:2023 年 8 月 18 日
# 在使用之前,敬请仔细阅读说明,感谢您的配合。
# 请务必访问 ethpen.com 官方网站。您可以确保这里的代码无恶意,安全地复制。
# 你只需要掌握一些 python 相关的基础。
# 在使用过程中,请根据规定准确填写信息,以确保程序顺畅运行。
# 我们建议您使用备用账号,并避免在账号中存放大额资金。
# 若您对此代码存有疑虑,建议您利用如 ChetGPT、Bard 或 Claude 等知名 AI 平台进行查询,以判断是否含有恶意代码。
# 如果你在使用的过程中发现 BUG 或者有什么想法和建议,欢迎与我联系。
# 导入运行代码所需要的库
from web3 import Web3 # 与以太坊交互的库,安装的命令是 pip install web3
import hashlib # 用于数据哈希,安装的命令是 pip install hashlib
import requests # 用于发送网络请求,安装的命令是 pip install requests
import re # 用于正则表达式
import time # 用于时间相关
# ---------- 以下是基础配置 ----------
# 填写你的多个 ETH 地址及私钥,建议填写新建的钱包,用英文逗号分隔(,),如下:地址,私钥。
accounts_str = '''
0xa62C8d0bB4F4530b9B68a14DaF8A949Cb01dB986,4de9b2812d51ba0ebbe7c990947b12544f7926a7aa1ebac084d42f6c7c8afbc1
0x71D10cc20Abe0af4EC16170C502a4319DE0e40B4,377f4a19719337b63d8280f0a52769a42b534343de1eccab4f6d204d1ca04815
0xBe169Ae4AD317B5632DE6Ae0e1EfeF0b22B1f91e,24fdf2ed0b820307582b06e1ed0b2047b4371e9d682e0b32455d310e08baafc5
'''
# 需要题写的代币铭文内容,变动的部分文本如 id 请用 "@#" 代替,例如:'data:,{"p":"erc-20","op":"mint","tick":"eths","id":"@#","amt":"1000"}'
ethscription = 'data:,{"p":"erc-20","op":"mint","tick":"eths","id":"@#","amt":"1000"}'
# 设置代币铭文 id 的起始和结束范围
min_id = 100 # 开始的整数
max_id = 888 # 结束的整数
# 决定是否在题写铭文之前检查该铭文有没有被题写过,如果需要检查就填写 Ture 如果不需要就填 False
check = False
# 每次交易成功后暂停 N 秒,0 为不暂停
sleep_sec = 0
# 这里配置 Ethereum PRC URL,如果你没有,请到 infura.io 或者 alchemy.com 申请一个免费的 API
w3 = Web3(Web3.HTTPProvider('https://sepolia.infura.io/v3/eab7f935b9af45e1a54f7d7ed06c5206'))
# 连接的网络 ID。比如说,1 代表 Mainnet,5 代表 Goerli 测试网络,11155111 代表 Sepolia 测试网络,如果你不放心,可以先用测试网试试。
chain_id = 11155111
# ---------- 以上是基础配置 ----------
# 检查 ETH 地址是否有效
def is_valid_eth_address(address):
if re.match("^0x[0-9a-fA-F]{40}$", address):
return True
return False
# 检查 Ethereum 私钥是否有效
def is_valid_eth_private_key(private_key):
if re.match("^[0-9a-fA-F]{64}$", private_key):
return True
return False
# 验证输入的铭文文本是否含有空格和换行符,而且字母全部为小写
def validate_input(data_str):
if re.search(r'[A-Z\s\n]', data_str): # 查找大写字母、空格或换行符
return False
return True
# 把文字转换成 16 进制
def text_to_hex(text):
return ''.join(format(ord(char), '02x') for char in text)
# 使用sha256算法计算哈希
def sha256(input_string):
sha256 = hashlib.sha256()
sha256.update(input_string.encode('utf-8'))
return sha256.hexdigest()
# 使用 Ethscriptions API(主网)检查某个铭文是否已题写
def check_content_exists(sha):
# 定义请求的网址
endpoint = f"/ethscriptions/exists/{sha}"
response = requests.get('https://mainnet-api.ethscriptions.com/api' + endpoint)
# 如果返回状态码是200,说明请求成功,然后返回结果(Ture or False)
if response.status_code == 200:
return response.json()['result']
# 发送自己到自己 0ETH 的交易
def send_transaction(w3, account_address, private_key, chain_id, gas_price, input_data, current_nonce):
# 设置交易的相关信息
tx = {
'chainId': chain_id, # 网络 ID
'gas': 25000, # 如果交易 gas 过低,可适当调高
'gasPrice': gas_price, # gas 的价格
'nonce': current_nonce, # 账户的交易数
'to': account_address, # 接收地址为自己
'value': 0, # 金额为 0ETH
'data': text_to_hex(input_data), # 铭文内容
}
# 用私钥签名这个交易
signed_tx = w3.eth.account.sign_transaction(tx, private_key)
# 发送签名后的交易并获取交易哈希
tx_hash = w3.eth.send_raw_transaction(signed_tx.rawTransaction)
# 打印结果信息
print(f'{account_address} | {input_data} | Transaction Hash: {tx_hash.hex()}')
# 初始化当前账户索引为 0
current_account_index = 0
# 创建账户列表
accounts = []
# 使用字典来跟踪每个地址的nonce
nonces = {}
if accounts_str: # 如果账户列表有内容
for line in accounts_str.strip().split('\n'): # 先去掉首尾的空白,然后根据换行符划分账户
if ',' in line: # 检查是否包含逗号
address, key = line.split(',') # 分开地址和私钥
if is_valid_eth_address(address) and is_valid_eth_private_key(key): # 验证地址和私钥
current_nonce = w3.eth.get_transaction_count(address) # 获取地址的 nonce
nonces[address] = current_nonce # 记录地址的 nonce
accounts.append((address.strip(), key.strip())) # 保存地址和私钥还有 nonce
else:
print(f"地址 {address} 或私钥 {key} 无效,请检查!")
exit()
else:
print(f"输入格式错误,请确保每行包含一个地址和一个私钥,并使用英文逗号分隔(,)。错误行:**{line}**")
exit()
# 判断铭文文本里是否包含空格、换行符,而且所有的字母都必须为小写。
if not validate_input(ethscription):
print("请注意:通常代币铭文文本里不能包含空格、换行符,而且所有的字母都必须为小写。")
# 检查是否留空
if not accounts or not ethscription:
print('请正确谨慎地填写内容,每一项都不应留空。')
exit()
else:
print('看起来你输入的内容均无没有问题!')
# 认真检查铭文内容,如果发现错误,输入 1 结束
print(f'铭文文本:\033[44m{ethscription}\033[m,题写 id 范围为:{min_id} - {max_id}。')
if input('请预览铭文,输入任意内容继续,输入 1 退出程序:') == '1':
exit()
print(f'开始任务,需要题写的铭文总量为:{max_id - min_id + 1}')
# 对代币铭文 id 进行循环
for the_id in range(min_id, max_id + 1):
# 使用当前账户发送交易
address, key = accounts[current_account_index]
# 得到完整的铭文文本
input_data = ethscription.replace('@#', str(the_id))
# 获取 gas
gas_price = w3.eth.gas_price
# 根据是否检查的开关进行
if check:
# 这里是开了检查后请求 Ethscriptions API
if check_content_exists(sha256(input_data)):
# 返回数据为 Ture,说明该铭文已经被题写,打印信息
print(f'{input_data} 已经被题写!')
else:
# 返回数据为 False,说明该铭文还没被题写,发送交易
# 使用 current_nonce 发送交易
send_transaction(w3, address, key, chain_id, gas_price, input_data, nonces[address])
# 交易成功后,手动增加 nonce 值
nonces[address] += 1
else:
# 这里是未开检查后直接发送交易
# 使用 current_nonce 发送交易
send_transaction(w3, address, key, chain_id, gas_price, input_data, nonces[address])
# 交易成功后,手动增加 nonce 值
nonces[address] += 1
# 更新当前账户索引,确保索引始终在账户列表的范围内
current_account_index = (current_account_index + 1) % len(accounts)
# 暂停 sleep_sec 秒
time.sleep(sleep_sec)
print(f'所有任务已经完成。')
"""
python_name_code = r"""
# ethpen.com
# 最后更新日期:2023 年 8 月 18 日
# 在使用之前,敬请仔细阅读说明,感谢您的配合。
# 请务必访问 ethpen.com 官方网站。您可以确保这里的代码无恶意,安全地复制。
# 你只需要掌握一些 python 相关的基础。
# 在使用过程中,请根据规定准确填写信息,以确保程序顺畅运行。
# 我们建议您使用备用账号,并避免在账号中存放大额资金。
# 若您对此代码存有疑虑,建议您利用如 ChetGPT、Bard 或 Claude 等知名 AI 平台进行查询,以判断是否含有恶意代码。
# 如果你在使用的过程中发现 BUG 或者有什么想法和建议,欢迎与我联系。
# 导入运行代码所需要的库
from web3 import Web3 # 与以太坊交互的库,安装的命令是 pip install web3
import hashlib # 用于数据哈希,安装的命令是 pip install hashlib
import requests # 用于发送网络请求,安装的命令是 pip install requests
import re # 用于正则表达式
import time # 用于时间相关
# ---------- 以下是基础配置 ----------
# 填写你的多个 ETH 地址及私钥,建议填写新建的钱包,用英文逗号分隔(,),如下:地址,私钥。
accounts_str = '''
0xa62C8d0bB4F4530b9B68a14DaF8A949Cb01dB986,4de9b2812d51ba0ebbe7c990947b12544f7926a7aa1ebac084d42f6c7c8afbc1
0x71D10cc20Abe0af4EC16170C502a4319DE0e40B4,377f4a19719337b63d8280f0a52769a42b534343de1eccab4f6d204d1ca04815
0xBe169Ae4AD317B5632DE6Ae0e1EfeF0b22B1f91e,24fdf2ed0b820307582b06e1ed0b2047b4371e9d682e0b32455d310e08baafc5
'''
# 需要题写的铭文内容,在三个单引号内输入多个域名铭文,可以用空格、换行符、英文逗号(,)分开,不要带 data:, 开头
# 不要带 data:, 开头
# 不要带 data:, 开头
ethscription = '''
123
12313131
2131 21313
12313 32313
423213v ethpen.com
'''
# 你希望添加的后缀
suffix = '.eths'
# 以空格、换行符、英文逗号分隔文本,并加上后缀
ethscription_list = [item.strip() + suffix for item in re.split(r'[\s,]+', ethscription) if item]
# 决定是否在题写铭文之前检查该铭文有没有被题写过,如果需要检查就填写 Ture 如果不需要就填 False
check = False
# 每次交易成功后暂停 N 秒,0 为不暂停
sleep_sec = 0
# 这里配置 Ethereum PRC URL,如果你没有,请到 infura.io 或者 alchemy.com 申请一个免费的 API
w3 = Web3(Web3.HTTPProvider('https://sepolia.infura.io/v3/eab7f935b9af45e1a54f7d7ed06c5206'))
# 连接的网络 ID。比如说,1 代表 Mainnet,5 代表 Goerli 测试网络,11155111 代表 Sepolia 测试网络,如果你不放心,可以先用测试网试试。
chain_id = 11155111
# ---------- 以上是基础配置 ----------
# 检查 ETH 地址是否有效
def is_valid_eth_address(address):
if re.match("^0x[0-9a-fA-F]{40}$", address):
return True
return False
# 检查 Ethereum 私钥是否有效
def is_valid_eth_private_key(private_key):
if re.match("^[0-9a-fA-F]{64}$", private_key):
return True
return False
# 验证输入的铭文文本是否含有空格和换行符,而且字母全部为小写
def validate_input(data_str):
if re.search(r'[A-Z\s\n]', data_str): # 查找大写字母、空格或换行符
return False
return True
# 把文字转换成 16 进制
def text_to_hex(text):
return ''.join(format(ord(char), '02x') for char in text)
# 使用sha256算法计算哈希
def sha256(input_string):
sha256 = hashlib.sha256()
sha256.update(input_string.encode('utf-8'))
return sha256.hexdigest()
# 使用 Ethscriptions API(主网)检查某个铭文是否已存在
def check_content_exists(sha):
# 定义请求的网址
endpoint = f"/ethscriptions/exists/{sha}"
response = requests.get('https://mainnet-api.ethscriptions.com/api' + endpoint)
# 如果返回状态码是200,说明请求成功,然后返回结果(Ture or False)
if response.status_code == 200:
return response.json()['result']
# 发送自己到自己 0ETH 的交易
def send_transaction(w3, account_address, private_key, chain_id, gas_price, input_data, current_nonce):
# 设置交易的相关信息
tx = {
'chainId': chain_id, # 网络 ID
'gas': 25000, # 如果交易 gas 过低,可适当调高
'gasPrice': gas_price, # gas 的价格
'nonce': current_nonce, # 账户的交易数
'to': account_address, # 接收地址为自己
'value': 0, # 金额为 0ETH
'data': text_to_hex(input_data), # 铭文内容
}
# 用私钥签名这个交易
signed_tx = w3.eth.account.sign_transaction(tx, private_key)
# 发送签名后的交易并获取交易哈希
tx_hash = w3.eth.send_raw_transaction(signed_tx.rawTransaction)
# 打印结果信息
print(f'{account_address} | {input_data} | Transaction Hash: {tx_hash.hex()}')
# 初始化当前账户索引为 0
current_account_index = 0
# 创建账户列表
accounts = []
# 使用字典来跟踪每个地址的nonce
nonces = {}
if accounts_str: # 如果账户列表有内容
for line in accounts_str.strip().split('\n'): # 先去掉首尾的空白,然后根据换行符划分账户
if ',' in line: # 检查是否包含逗号
address, key = line.split(',') # 分开地址和私钥
if is_valid_eth_address(address) and is_valid_eth_private_key(key): # 验证地址和私钥
current_nonce = w3.eth.get_transaction_count(address) # 获取地址的 nonce
nonces[address] = current_nonce # 记录地址的 nonce
accounts.append((address.strip(), key.strip())) # 保存地址和私钥还有 nonce
else:
print(f"地址 {address} 或私钥 {key} 无效,请检查!")
exit()
else:
print(f"输入格式错误,请确保每行包含一个地址和一个私钥,并使用英文逗号分隔(,)。错误行:**{line}**")
exit()
# 判断铭文文本里是否包含空格、换行符,而且所有的字母都必须为小写。
if not validate_input(ethscription):
print("请注意:通常代币铭文文本里不能包含空格、换行符,而且所有的字母都必须为小写。")
# 检查是否留空
if not accounts or not ethscription:
print('请正确谨慎地填写内容,每一项都不应留空。')
exit()
else:
print('看起来你输入的内容均无没有问题!')
# 认真检查铭文内容,如果发现错误,输入 1 结束
for i in ethscription_list:
print(f'\033[44m{i}\033[m')
if input('请预览铭文,输入任意内容继续,输入 1 退出程序:') == '1':
exit()
print(f'开始任务,需要题写的铭文总量为:{len(ethscription_list)}')
# 对代币铭文 id 进行循环
for name_str in ethscription_list:
# 使用当前账户发送交易
address, key = accounts[current_account_index]
# 得到完整的铭文文本
if not name_str.startswith('data:,'):
input_data = f'data:,{name_str}'
else:
input_data = name_str
# 获取 gas
gas_price = w3.eth.gas_price
# 根据是否检查的开关进行
if check:
# 这里是开了检查后请求 Ethscriptions API
if check_content_exists(sha256(input_data)):
# 返回数据为 Ture,说明该铭文已经被题写,打印信息
print(f'{input_data} 已经被题写!')
else:
# 返回数据为 False,说明该铭文还没被题写,发送交易
# 使用 current_nonce 发送交易
send_transaction(w3, address, key, chain_id, gas_price, input_data, nonces[address])
# 交易成功后,手动增加 nonce 值
nonces[address] += 1
else:
# 这里是未开检查后直接发送交易
# 使用 current_nonce 发送交易
send_transaction(w3, address, key, chain_id, gas_price, input_data, nonces[address])
# 交易成功后,手动增加 nonce 值
nonces[address] += 1
# 更新当前账户索引,确保索引始终在账户列表的范围内
current_account_index = (current_account_index + 1) % len(accounts)
# 暂停 sleep_sec 秒
time.sleep(sleep_sec)
print(f'所有任务已经完成。')
"""
hf_token_code = r"""
# ethpen.com
# 最后更新日期:2023 年 8 月 18 日
# 在使用之前,敬请仔细阅读说明,感谢您的配合。
# 请务必访问 ethpen.com 官方网站。您可以确保这里的代码无恶意,安全地复制。
# 你只需要拥有一个 HuggingFace.co 账户。
# 在使用过程中,请根据规定准确填写信息,以确保程序顺畅运行。
# 我们建议您使用备用账号,并避免在账号中存放大额资金。
# 若您对此代码存有疑虑,建议您利用如 ChetGPT、Bard 或 Claude 等知名 AI 平台进行查询,以判断是否含有恶意代码。
# 请查看我们的例子 https://ethscriptions-name.hf.space。
# 导入运行代码所需要的库
import streamlit as st # streamlit app
from web3 import Web3 # 与以太坊交互的库
import hashlib # 用于数据哈希
import requests # 用于发送网络请求
import re # 用于正则表达式
import time # 用于时间相关
# 检查 ETH 地址是否有效
def is_valid_eth_address(address):
if re.match("^0x[0-9a-fA-F]{40}$", address):
return True
return False
# 检查 Ethereum 私钥是否有效
def is_valid_eth_private_key(private_key):
if re.match("^[0-9a-fA-F]{64}$", private_key):
return True
return False
# 验证输入的铭文文本是否含有空格和换行符,而且字母全部为小写
def validate_input(data_str):
if re.search(r'[A-Z\s\n]', data_str): # 查找大写字母、空格或换行符
return False
return True
# 把文字转换成 16 进制
def text_to_hex(text):
return ''.join(format(ord(char), '02x') for char in text)
# 使用sha256算法计算哈希
def sha256(input_string):
sha256 = hashlib.sha256()
sha256.update(input_string.encode('utf-8'))
return sha256.hexdigest()
# 使用 Ethscriptions API(主网)检查某个铭文是否已题写
def check_content_exists(sha):
# 定义请求的网址
endpoint = f"/ethscriptions/exists/{sha}"
response = requests.get('https://mainnet-api.ethscriptions.com/api' + endpoint)
# 如果返回状态码是200,说明请求成功,然后返回结果(Ture or False)
if response.status_code == 200:
return response.json()['result']
# 发送自己到自己 0ETH 的交易
def send_transaction(w3, account_address, private_key, chain_id, gas_price, input_data, current_nonce):
# 设置交易的相关信息
tx = {
'chainId': chain_id, # 网络 ID
'gas': 25000, # 如果交易 gas 过低,可适当调高
'gasPrice': gas_price, # gas 的价格
'nonce': current_nonce,
'to': account_address, # 接收地址为自己
'value': 0, # 金额为 0ETH
'data': text_to_hex(input_data), # 铭文内容
}
# 用私钥签名这个交易
signed_tx = w3.eth.account.sign_transaction(tx, private_key)
# 发送签名后的交易并获取交易哈希
tx_hash = w3.eth.send_raw_transaction(signed_tx.rawTransaction)
# 打印结果信息
st.toast(f'{input_data}', icon='✅')
# 返回铭文还有交易哈希
return input_data, tx_hash.hex()
# 网页前端显示
# 网页标题
st.markdown('# [ethpen.com](https://ethpen.com) 代币铭文批量题写')
# 提醒
st.info('''在使用之前,敬请仔细阅读说明,感谢您的配合。
- 请务必访问 **[ethpen.com](https://ethpen.com)** 官方网站。您可以确保这里的代码无恶意,安全地复制。
- 在使用过程中,请根据规定准确填写信息,以确保程序顺畅运行。
- 我们建议您使用备用账号,并避免在账号中存放大额资金。
- 若您对此代码存有疑虑,建议您利用如 [ChetGPT](https://chat.openai.com/)、[Bard](https://bard.google.com/) 或 [Claude](https://claude.ai/) 等知名 AI 平台进行查询,以判断是否含有恶意代码。
''')
# 连接的网络 ID。比如说,1 代表 Mainnet,5 代表 Goerli 测试网络,11155111 代表 Sepolia 测试网络,如果你不放心,可以先用测试网试试。
net_options = {
'1': 'Mainnet',
'5': 'Goerli',
'11155111': 'Sepolia'
}
selected_option = st.selectbox(
'**网络 ID**',
list(net_options.keys()),
format_func=lambda x: f"{x} ({net_options[x]})"
)
chain_id = int(selected_option)
# 这里配置 Ethereum PRC URL,如果你没有,请到 infura.io 或者 alchemy.com 申请一个免费的 API
token_eth_prc_url = st.text_input(
f'**Ethereum PRC 链接**:选填,你可以去 [infura.io](https://app.infura.io/) 或者 [alchemy.com](https://alchemy.com/) 免费申请一个',
f'https://{net_options[str(chain_id)]}.infura.io/v3/eab7f935b9af45e1a54f7d7ed06c5206')
w3 = Web3(Web3.HTTPProvider(f'{token_eth_prc_url}'))
# 初始化当前账户索引为 0
current_account_index = 0
# 收集和显示所有交易的结果
transaction_results = []
# 创建账户列表
accounts = []
# 使用字典来跟踪每个地址的nonce
nonces = {}
# 启用多账户操作
if st.checkbox(f'启用**多账户**操作'):
# 多账户的文本框
account_list = st.text_area(f'输入多个 **ETH 地址及其对应的私钥**,用英文逗号分隔(,),如下:地址,私钥')
if account_list: # 如果账户列表有内容
for line in account_list.split('\n'): # 根据换行符划分账户
if ',' in line: # 检查是否包含逗号
address, key = line.split(',') # 分开地址和私钥
if is_valid_eth_address(address) and is_valid_eth_private_key(key): # 验证地址和私钥
current_nonce = w3.eth.get_transaction_count(address) # 获取地址的 nonce
nonces[address] = current_nonce # 记录地址的 nonce
accounts.append((address.strip(), key.strip())) # 保存地址和私钥还有 nonce
else:
st.error(f"地址 {address} 或私钥 {key} 无效,请检查!")
st.stop()
else:
st.error(f"输入格式错误,请确保每行包含一个地址和一个私钥,并使用英文逗号分隔(,)。错误行:**{line}**")
st.stop()
else:
account_address = st.text_input('填写你的 **ETH 地址**:')
private_key = st.text_input('填写你的 **ETH 地址对应的私钥**:', type="password")
if account_address and private_key: # 如果地址和私钥有内容
if is_valid_eth_address(account_address) and is_valid_eth_private_key(private_key): # 验证地址和私钥
current_nonce = w3.eth.get_transaction_count(account_address) # 获取地址的 nonce
nonces[account_address] = current_nonce # 记录地址的 nonce
accounts.append((account_address.strip(), private_key.strip())) # 保存地址和私钥还有 nonce
else:
st.error("地址或私钥无效,请检查!")
st.stop()
# 配置铭文文本
token_protocol = st.text_input('填写需要题写代币铭文协议 **Protocol(p)**:', 'erc-20')
token_operation = st.text_input('填写需要题写代币铭文操作 **Operation(op)**:', 'mint')
token_ticker = st.text_input('填写需要题写代币铭文简称 **Ticker(tick)**:')
token_min_id = st.number_input('填写需要题写代币铭文范围的**最小 ID(id)**:', min_value=1, value=1, step=1)
token_max_id = st.number_input('填写需要题写代币铭文范围的**最大 ID(id)**:', value=21000, step=1)
token_amount = st.number_input('填写需要题写代币铭文数量 **Amount(amt)**:', min_value=1, value=1000, step=1)
st.markdown('###### 预览你需要题写的代币铭文:')
st.code(
f'data:,{{"p":"{token_protocol}","op":"{token_operation}","tick":"{token_ticker}","id":"{token_min_id}","amt":"{token_amount}"}}',
language="json", line_numbers=False)
# 判断铭文文本里是否包含空格、换行符,而且所有的字母都必须为小写。
if not validate_input(
f'data:,{{"p":"{token_protocol}","op":"{token_operation}","tick":"{token_ticker}","id":"{token_min_id}","amt":"{token_amount}"}}'):
st.warning("**请注意**:通常代币铭文文本里不能包含空格、换行符,而且所有的字母都必须为小写。")
# 题写铭文之前检查该铭文有没有被题写
if st.checkbox(f'题写铭文之前**检查该铭文有没有被题写**'):
token_check = True
else:
token_check = False
# 每次交易成功后暂停 3 秒
if st.checkbox(f'每次交易完成后暂停 3 秒'):
sleep_3s = True
else:
sleep_3s = False
# 点击发送交易开始
if st.button(f'开始**发送交易**'):
if not accounts or not token_protocol or not token_operation or not token_ticker: # 检查是否留空
st.error(f'请正确谨慎地填写内容,每一项都**不应留空**。')
st.stop()
else:
st.toast('看起来你输入的内容均无没有问题!', icon='🥳')
st.toast(f'开始任务,需要题写的铭文总量为:{token_max_id - token_min_id + 1}', icon='😎')
# 对代币铭文 id 进行循环
for the_id in range(token_min_id, token_max_id + 1):
# 使用当前账户发送交易,获取当前账户的 nonce
address, key = accounts[current_account_index]
# 得到完整的铭文文本
input_data = f'data:,{{"p":"{token_protocol}","op":"{token_operation}","tick":"{token_ticker}","id":"{the_id}","amt":"{token_amount}"}}'
# 获取 gas
gas_price = w3.eth.gas_price
# 根据是否检查的开关进行
if token_check:
# 这里是开了检查后请求 Ethscriptions API
if check_content_exists(sha256(input_data)):
# 返回数据为 Ture,说明该铭文已经被题写,打印信息
st.toast(f'{input_data} 已经被题写!', icon='☹️')
else:
# 返回数据为 False,说明该铭文还没被题写,发送交易
# 使用 current_nonce 发送交易
data, tx_hash = send_transaction(w3, address, key, chain_id, gas_price, input_data, nonces[address])
# 记录最后输出的结果
transaction_results.append(f"{address} | {data} | Transaction Hash: {tx_hash}")
# 交易成功后,手动增加 nonce 值
nonces[address] += 1
else:
# 这里是未开检查后直接发送交易
# 使用 current_nonce 发送交易
data, tx_hash = send_transaction(w3, address, key, chain_id, gas_price, input_data, nonces[address])
# 记录最后输出的结果
transaction_results.append(f"{address} | {data} | Transaction Hash: {tx_hash}")
# 交易成功后,手动增加 nonce 值
nonces[address] += 1
# 更新当前账户索引,确保索引始终在账户列表的范围内
current_account_index = (current_account_index + 1) % len(accounts)
# 暂停 3 秒
if sleep_3s:
time.sleep(3) # 暂停三秒
st.toast(f'所有任务已经完成。', icon='🎉')
# 庆祝动画
st.balloons()
# 显示所有交易的结果
st.code('\n'.join(transaction_results))
"""
hf_name_code = r"""
# ethpen.com
# 最后更新日期:2023 年 8 月 18 日
# 在使用之前,敬请仔细阅读说明,感谢您的配合。
# 请务必访问 ethpen.com 官方网站。您可以确保这里的代码无恶意,安全地复制。
# 你只需要拥有一个 HuggingFace.co 账户。
# 在使用过程中,请根据规定准确填写信息,以确保程序顺畅运行。
# 我们建议您使用备用账号,并避免在账号中存放大额资金。
# 若您对此代码存有疑虑,建议您利用如 ChetGPT、Bard 或 Claude 等知名 AI 平台进行查询,以判断是否含有恶意代码。
# 请查看我们的例子 https://ethscriptions-name.hf.space。
# 导入运行代码所需要的库
import streamlit as st # streamlit app
from web3 import Web3 # 与以太坊交互的库
import hashlib # 用于数据哈希
import requests # 用于发送网络请求
import re # 用于正则表达式
import time # 用于时间相关
# 检查 ETH 地址是否有效
def is_valid_eth_address(address):
if re.match("^0x[0-9a-fA-F]{40}$", address):
return True
return False
# 检查 Ethereum 私钥是否有效
def is_valid_eth_private_key(private_key):
if re.match("^[0-9a-fA-F]{64}$", private_key):
return True
return False
# 验证输入的铭文文本是否含有空格和换行符,而且字母全部为小写
def validate_input(data_str):
if re.search(r'[A-Z\s\n]', data_str): # 查找大写字母、空格或换行符
return False
return True
# 分隔文本函数
def split_and_append(ethscriptions_str, name_selected_option):
separators = [' ', '\n', ',']
split_texts = [ethscriptions_str] # 初始时只有一个完整文本
for sep in separators:
pieces = []
for text in split_texts:
pieces.extend(text.split(sep))
split_texts = pieces
# 移除空字符串
split_texts = [text.strip() + name_selected_option for text in split_texts if text.strip() != '']
return split_texts
# 把文字转换成 16 进制
def text_to_hex(text):
return ''.join(format(ord(char), '02x') for char in text)
# 使用sha256算法计算哈希
def sha256(input_string):
sha256 = hashlib.sha256()
sha256.update(input_string.encode('utf-8'))
return sha256.hexdigest()
# 使用 Ethscriptions API(主网)检查某个铭文是否已题写
def check_content_exists(sha):
# 定义请求的网址
endpoint = f"/ethscriptions/exists/{sha}"
response = requests.get('https://mainnet-api.ethscriptions.com/api' + endpoint)
# 如果返回状态码是200,说明请求成功,然后返回结果(Ture or False)
if response.status_code == 200:
return response.json()['result']
# 发送自己到自己 0ETH 的交易
def send_transaction(w3, account_address, private_key, chain_id, gas_price, input_data, current_nonce):
# 设置交易的相关信息
tx = {
'chainId': chain_id, # 网络 ID
'gas': 25000, # 如果交易 gas 过低,可适当调高
'gasPrice': gas_price, # gas 的价格
'nonce': current_nonce,
'to': account_address, # 接收地址为自己
'value': 0, # 金额为 0ETH
'data': text_to_hex(input_data), # 铭文内容
}
# 用私钥签名这个交易
signed_tx = w3.eth.account.sign_transaction(tx, private_key)
# 发送签名后的交易并获取交易哈希
tx_hash = w3.eth.send_raw_transaction(signed_tx.rawTransaction)
# 打印结果信息
st.toast(f'{input_data}', icon='✅')
# 返回铭文还有交易哈希
return input_data, tx_hash.hex()
# 网页前端显示
# 网页标题
st.markdown('# [ethpen.com](https://ethpen.com) 域名铭文批量题写')
# 提醒
st.info('''在使用之前,敬请仔细阅读说明,感谢您的配合。
- 请务必访问 **[ethpen.com](https://ethpen.com)** 官方网站。您可以确保这里的代码无恶意,安全地复制。
- 在使用过程中,请根据规定准确填写信息,以确保程序顺畅运行。
- 我们建议您使用备用账号,并避免在账号中存放大额资金。
- 若您对此代码存有疑虑,建议您利用如 [ChetGPT](https://chat.openai.com/)、[Bard](https://bard.google.com/) 或 [Claude](https://claude.ai/) 等知名 AI 平台进行查询,以判断是否含有恶意代码。
''')
# 连接的网络 ID。比如说,1 代表主网络,5 代表 Goerli 测试网络,11155111 代表 Sepolia 测试网络,如果你不放心,可以先用测试网试试。
net_options = {
'1': 'Mainnet',
'5': 'Goerli',
'11155111': 'Sepolia'
}
selected_option = st.selectbox(
'**网络 ID**',
list(net_options.keys()),
format_func=lambda x: f"{x} ({net_options[x]})"
)
chain_id = int(selected_option)
# 这里配置 Ethereum PRC URL,如果你没有,请到 infura.io 或者 alchemy.com 申请一个免费的 API
token_eth_prc_url = st.text_input(
f'**Ethereum PRC 链接**:选填,你可以去 [infura.io](https://app.infura.io/) 或者 [alchemy.com](https://alchemy.com/) 免费申请一个',
f'https://{net_options[str(chain_id)]}.infura.io/v3/eab7f935b9af45e1a54f7d7ed06c5206')
w3 = Web3(Web3.HTTPProvider(f'{token_eth_prc_url}'))
# 初始化当前账户索引为 0
current_account_index = 0
# 收集和显示所有交易的结果
transaction_results = []
# 创建账户列表
accounts = []
# 使用字典来跟踪每个地址的nonce
nonces = {}
# 启用多账户操作
if st.checkbox(f'启用**多账户**操作'):
# 多账户的文本框
account_list = st.text_area(f'输入多个 **ETH 地址及其对应的私钥**,用英文逗号分隔(,),如下:地址,私钥')
if account_list: # 如果账户列表有内容
for line in account_list.split('\n'): # 根据换行符划分账户
if ',' in line: # 检查是否包含逗号
address, key = line.split(',') # 分开地址和私钥
if is_valid_eth_address(address) and is_valid_eth_private_key(key): # 验证地址和私钥
current_nonce = w3.eth.get_transaction_count(address) # 获取地址的 nonce
nonces[address] = current_nonce # 记录地址的 nonce
accounts.append((address.strip(), key.strip())) # 保存地址和私钥还有 nonce
else:
st.error(f"地址 {address} 或私钥 {key} 无效,请检查!")
st.stop()
else:
st.error(f"输入格式错误,请确保每行包含一个地址和一个私钥,并使用英文逗号分隔(,)。错误行:**{line}**")
st.stop()
else:
account_address = st.text_input('填写你的 **ETH 地址**:')
private_key = st.text_input('填写你的 **ETH 地址对应的私钥**:', type="password")
if account_address and private_key: # 如果地址和私钥有内容
if is_valid_eth_address(account_address) and is_valid_eth_private_key(private_key): # 验证地址和私钥
current_nonce = w3.eth.get_transaction_count(account_address) # 获取地址的 nonce
nonces[account_address] = current_nonce # 记录地址的 nonce
accounts.append((account_address.strip(), private_key.strip())) # 保存地址和私钥还有 nonce
else:
st.error("地址或私钥无效,请检查!")
st.stop()
# 配置铭文文本
ethscriptions_str = st.text_area(f'输入**多个域名铭文或其他**,可以用空格、换行符、英文逗号(,)分开,不要带 data:, 前缀,不要带域名后缀')
name_options = ["自定义", ".eth", ".eths", ".tree", ".honk", ".etch"]
name_selected_option = st.selectbox(f'选择**域名后缀**', name_options)
if name_selected_option == '自定义':
name_selected_option = st.text_input('输入**自定义的域名**:')
# 以空格、换行符、英文逗号分隔文本并加上后缀
ethscription_list = split_and_append(ethscriptions_str, name_selected_option)
# 判断铭文文本里是否包含空格、换行符,而且所有的字母都必须为小写。
if not validate_input(''.join(ethscription_list)):
st.warning("**请注意**:通常代币铭文文本里不能包含空格、换行符,而且所有的字母都必须为小写。")
# 题写铭文之前检查该铭文有没有被题写
if st.checkbox(f'题写铭文之前**检查该铭文有没有被题写**'):
token_check = True
else:
token_check = False
# 每次交易成功后暂停 3 秒
if st.checkbox(f'每次交易完成后暂停 3 秒'):
sleep_3s = True
else:
sleep_3s = False
# 点击发送交易开始
if st.button(f'开始**发送交易**'):
if not accounts or not ethscriptions_str or not name_selected_option: # 检查是否留空
st.error(f'请正确谨慎地填写内容,每一项都**不应留空**。')
st.stop()
else:
st.toast('看起来你输入的内容均无没有问题!', icon='🥳')
st.toast(f'开始任务,需要题写的铭文总量为:{len(ethscription_list)}', icon='😎')
# 对代币铭文 id 进行循环
for name_str in ethscription_list:
# 使用当前账户发送交易,获取当前账户的 nonce
address, key = accounts[current_account_index]
# 获取 gas
gas_price = w3.eth.gas_price
# 得到完整的铭文文本
if not name_str.startswith('data:,'):
input_data = f'data:,{name_str}'
# 根据是否检查的开关进行
if token_check:
# 这里是开了检查后请求 Ethscriptions API
if check_content_exists(sha256(input_data)):
# 返回数据为 Ture,说明该铭文已经被题写,打印信息
st.toast(f'{input_data} 已经被题写!', icon='☹️')
else:
# 返回数据为 False,说明该铭文还没被题写,发送交易
# 使用 current_nonce 发送交易
data, tx_hash = send_transaction(w3, address, key, chain_id, gas_price, input_data, nonces[address])
# 记录最后输出的结果
transaction_results.append(f"{address} | {data} | Transaction Hash: {tx_hash}")
# 交易成功后,手动增加 nonce 值
nonces[address] += 1
else:
# 这里是未开检查后直接发送交易
# 使用 current_nonce 发送交易
data, tx_hash = send_transaction(w3, address, key, chain_id, gas_price, input_data, nonces[address])
# 记录最后输出的结果
transaction_results.append(f"{address} | {data} | Transaction Hash: {tx_hash}")
# 交易成功后,手动增加 nonce 值
nonces[address] += 1
# 更新当前账户索引,确保索引始终在账户列表的范围内
current_account_index = (current_account_index + 1) % len(accounts)
# 暂停 3 秒
if sleep_3s:
time.sleep(3) # 暂停三秒
st.toast(f'所有任务已经完成。', icon='🎉')
# 庆祝动画
st.balloons()
# 显示所有交易的结果
st.code('\n'.join(transaction_results))
"""
my_style = '''
'''
# 图片Base64
def image_to_base64(img_path):
with open(img_path, "rb") as image_file:
return base64.b64encode(image_file.read()).decode()
# 验证代币铭文函数
def is_valid_eths(data, p, tick, id, amt):
# 构建匹配1到id-1的正则表达式
pattern_range = "|".join([str(i) for i in range(1, id)])
# 使用 f-string 插入参数到正则表达式
pattern = rf'^data:,{{"p":"{p}","op":"mint","tick":"{tick}","id":"({pattern_range}|{id})","amt":"{amt}"}}$'
return bool(re.match(pattern, data))
# 文本转换到十六进制
def text_to_hex(text):
return ''.join(format(ord(char), '02x') for char in text)
# str SHA256
def sha256(input_string):
sha256 = hashlib.sha256()
sha256.update(input_string.encode('utf-8'))
return sha256.hexdigest()
# 根据 TX 获取 input data
def get_input_data(tx_hash):
endpoint = f"https://mainnet.infura.io/v3/{infura_api_key}"
headers = {
"Content-Type": "application/json",
}
data = {
"jsonrpc": "2.0",
"id": 1,
"method": "eth_getTransactionByHash",
"params": [tx_hash]
}
eth_transaction = requests.post(endpoint, headers=headers, data=json.dumps(data))
transaction_data = eth_transaction.json()
return transaction_data['result']['input']
# 获取所有的 ethscriptions
def get_all_ethscriptions(page=None, per_page=None, sort_order=None):
endpoint = "/ethscriptions"
params = {
"page": page, # 页码
"per_page": per_page, # 每页的数量
"sort_order": sort_order # 排序顺序
}
response = requests.get(BASE_URL + endpoint, params=params)
return response.json()
# 根据地址获取 ethscriptions
def get_ethscriptions_by_address(address):
all_ethscriptions = []
page = 1
per_page = 100
while True:
endpoint = f"/ethscriptions/owned_by/{address}"
params = {
"page": page,
"per_page": per_page,
"sort_order": 'asc'
}
response = requests.get(BASE_URL + endpoint, params=params)
if response.status_code != 200:
print(f"Error fetching data: {response.text}")
break
ethscriptions = response.json()
all_ethscriptions.extend(ethscriptions)
if len(ethscriptions) < per_page:
break
page += 1
return all_ethscriptions
# 使用ID或数字获取特定的 ethscription
def get_specific_ethscription(ethscription_identifier):
endpoint = f"/ethscriptions/{ethscription_identifier}"
response = requests.get(BASE_URL + endpoint)
return response.json()
# 获取特定 ethscription 的数据
def get_ethscription_data(ethscription_identifier):
endpoint = f"/ethscriptions/{ethscription_identifier}/data"
response = requests.get(BASE_URL + endpoint)
return response.json()
# 使用 SHA256 值检查内容是否已被 ethscribed
def check_content_exists(sha):
endpoint = f"/ethscriptions/exists/{sha}"
response = requests.get(BASE_URL + endpoint)
if response.status_code == 200:
return response.json()
# 确定索引器是否落后
def get_block_status():
endpoint = "/block_status"
response = requests.get(BASE_URL + endpoint)
return response.json()
# 获取 $eths 价格
def get_eths_price():
params = {
'category': 'token',
'collectionName': 'erc-20 eths',
}
response = requests.get(
'https://www.etch.market/api/markets/collections/details',
params=params
)
if response.status_code == 200:
response = response.json()
if response['message'] == 'success':
return response['data']
return {} # 返回一个空字典作为默认值
# 从 etch.market 那里获取用户地址代币余额
def get_etch_token_amt():
params = {
'category': 'token',
'tokenQuery': '',
}
response = requests.get(
'https://www.etch.market/api/markets/ethscriptions/collections/0x59724739940777947c56C4f2f2C9211cd5130FEf',
params=params
)
if response.status_code == 200:
response = response.json()
if response['message'] == 'success':
return response['data']
return {} # 返回一个空字典作为默认值
# 获取 $eths 质押数据
def get_eths_staking():
response = requests.get('https://www.etch.market/api/staking/statistics/erc-20%20eths')
if response.status_code == 200:
response = response.json()
if response['message'] == 'success':
return response['data']
return {} # 返回一个空字典作为默认值
st.set_page_config(page_title="EthPen - 以太之笔", page_icon="🖊", layout='wide', initial_sidebar_state='expanded')
# 首页
st.markdown(
f'# :rainbow[EthPen - 以太之笔]',
unsafe_allow_html=True)
st.subheader('', anchor=False, divider='rainbow')
# 最近新闻
st.markdown(f'### 最近新闻')
st.markdown(
f'
',
unsafe_allow_html=True)
st.markdown(f'> 3 周前,我们提出了 Ethscriptions 虚拟机的构想——一种通过将其解释为计算机指令来显著增强 Ethscriptions 功能的方法。今天,我们宣布了该虚拟机的首个实现。已在 Goerli 网络上线,并已在 GitHub 上完全开源!👆')
# 广告位图片
st.markdown(f'### 广告位')
st.markdown(
f'
',
unsafe_allow_html=True)
st.markdown(f'> 拆分方案现在面向所有人推出!让我们一起加入权益挖矿的浪潮,并分享50%的月度服务费。')
st.markdown("### 功能专区")
# st.expander
search_rune_expander = st.expander("查询 Ethscriptions")
create_rune_expander = st.expander("题写 Ethscriptions")
token_no_code_expander = st.expander("一键式铭文批量题写,无需编码知识!")
trend_expander = st.expander("潮流动态")
help_expander = st.expander("教程帮助")
st.markdown("🎉 更多功能尽在菜单栏,请点击左上角的 >")
# 查询铭文页面
search_rune_expander.info(
f"铭文数据来自 [Ethscriptions](https://ethscriptions.com/) 官方网站,当前索引器状态落后: {get_block_status()['blocks_behind']} 个区块。")
search_rune_expander.markdown("##### 查询 ETH 地址所属铭文")
user_address = search_rune_expander.text_input('输入 ETH 地址:', '')
if search_rune_expander.button('🔍 查询', key='查询铭文'):
# 检查ETH地址
pattern = "^0x[a-fA-F0-9]{40}$"
if re.match(pattern, user_address):
data = get_ethscriptions_by_address(user_address)
if not data:
search_rune_expander.info(
"该地址没有任何铭文,或许是区块暂时没同步过来,如果你不确定,请前往 Ethscriptions 官网再次查询!")
else:
token_total = 0
for token in token_list:
for ethscriptions in data:
if is_valid_eths(ethscriptions['content_uri'], token['p'], token['tick'], token['id'],
token['amt']):
input_data_str = json.loads(ethscriptions['content_uri'][6:])
token_total = token_total + int(input_data_str['amt'])
search_rune_expander.success(f"${token['tick']} 有效总量为:{token_total}")
token_total = 0
search_rune_expander.warning(
f"只统计 etch.market 流动性较高的资产,etch.market 上架的代币不计算在内,详细更多的信息请点击[这里](https://ethscriptions.com/{user_address})")
else:
search_rune_expander.error("输入的 ETH 地址不正确!")
search_rune_expander.markdown("##### 查询铭文的完整信息")
ethscriptions_str = search_rune_expander.text_input('输入完整的铭文文本:', '')
if search_rune_expander.button('🔍 查询', key='查询信息'):
if not ethscriptions_str.startswith('data:,'):
ethscriptions_str = f'data:,{ethscriptions_str}'
ethscriptions_all_str = sha256(ethscriptions_str)
ethscriptions_data = check_content_exists(ethscriptions_all_str)
if ethscriptions_data['result']:
search_rune_expander.markdown(f'###### :green[{ethscriptions_str}] 相关信息如下:')
selected_data = {
'当前拥有者': ethscriptions_data["ethscription"]["current_owner"],
'题写时间': ethscriptions_data["ethscription"]["creation_timestamp"],
'铭文编号': f'#{ethscriptions_data["ethscription"]["ethscription_number"]}',
'铭文完整内容': ethscriptions_data["ethscription"]["content_uri"],
}
search_rune_expander.json(selected_data)
else:
search_rune_expander.markdown(f'###### :green[{ethscriptions_str}] 铭文还没被题写!复制下方文本前去题写。')
search_rune_expander.code(f'{text_to_hex(ethscriptions_str)}', line_numbers=False)
# 批量查询铭文是否被存在
runes = []
search_rune_expander.markdown("##### 批量查询铭文是否被题写")
search_rune_expander.markdown(r'''
1. **查域名**:可以用空格和换行符还有英文逗号(,)分开,不要带前缀 data:,
2. **查代币**:需要查询的代币铭文内容变动的部分文本如 id 请用 "@#" 代替,例如:`data:,{"p":"erc-20","op":"mint","tick":"eths","id":"@#","amt":"1000"}`
3. **查纯文本**:可任意填写,用空格和换行符还有英文逗号(,)分开''')
input_content = search_rune_expander.text_area(f'输入铭文文本:')
search_type = search_rune_expander.radio('选择查询类型:', ['查域名', '查代币', '查纯文本'],
label_visibility="collapsed", horizontal=True, index=2)
if search_type == '查域名':
search_dotname = search_rune_expander.text_input('填写域名后缀:')
elif search_type == '查代币':
search_token_min_id = search_rune_expander.number_input(f'填写代币铭文范围的**最小 ID(id)**:', min_value=1, value=1,
step=1)
search_token_max_id = search_rune_expander.number_input(f'填写代币铭文范围的**最大 ID(id)**:', value=10, step=1)
if search_rune_expander.button('🔍 查询', key='批量查询铭文'):
runes = re.split(r'[\s,]+', input_content)
# 过滤掉空或仅包含空白字符的项
runes = [r for r in runes if r.strip() != '']
if search_type == '查域名':
runes = [r + search_dotname for r in runes]
elif search_type == '查代币':
token_runes = []
if len(runes) != 1 and '@#' in input_content:
for the_id in range(search_token_min_id, search_token_max_id + 1):
token_runes.append(input_content.replace('@#', str(the_id)))
else:
st.stop()
runes = token_runes
# 创建一个空的结果列表
results = []
# 循环遍历每一个铭文并查询其存在状态
for rune in runes:
if not rune.startswith('data:,'):
rune = f'data:,{rune}'
sha_value = sha256(rune)
response_data = check_content_exists(sha_value)
# 根据返回的result,得到真或者假
exists = "已题写" if response_data['result'] else "未题写"
results.append([rune, exists])
# 使用 st.table 显示结果
table_data = pd.DataFrame(results, columns=['铭文', '状态'])
# 根据状态生成一个辅助排序列
table_data['sort_helper'] = table_data['状态'].apply(lambda x: 0 if x == "未题写" else 1)
# 使用辅助列进行排序
table_data.sort_values(by='sort_helper', ascending=True, inplace=True)
# 删除辅助排序列
table_data.drop(columns=['sort_helper'], inplace=True)
# 定义样式和生成带有专门类名的HTML表格
table_style = """
"""
search_rune_expander.markdown(table_style, unsafe_allow_html=True)
table_html = table_data.to_html(index=False, classes='styled_table', border=0, escape=False,
formatters=dict(状态=lambda x: f'
${eths_data[0][2]:.2f}
市值:${eths_data[0][3]:,.0f}
总量:21,000,000
24h 交易量:${eths_data[0][5]:,.0f}
官网:None
浏览器: Ethscriptions
Ethscription ID: 0x463654......bed2e4
部署时间:2023/06/18 05:46:11
公链:Ethereum Ethscriptions
持有人数:{eths_data[0][4]:,.0f}
社交: @ethscriptions
@ethscriptions
质押总量:{eths_data[0][6]:,.0f} $eths
质押人数:{eths_data[0][7]:,.0f}
TVL:${eths_data[0][8]:,.0f}