evm铭文

借用web5.ink里

根据dune用户@sixdegree 创建的 Ethscriptions 查询工具我们可以看到,eths代币的“规则”是在6月17日被一个用户所确定,他在以太坊主网上写入了一串字符串:

data:,{"p":"erc-20","op":"deploy","tick":"eths","max":"21000 ","lim":"1000"}

EVM 铭文的结构

Input Data 记录数据是 Hex 十六进制,在浏览器上需要 转为 UTF-8 格式。

网址: https://etherscan.io/tx/0x6734241aa845c102d062acf85a2e080189264a565468b6afa9bb8823c86414ed

这里粘贴我们的代码

from web3 import Web3, HTTPProvider
import time
import random

#私钥
private_key = ''
#打的次数
count = 50

#打哪条链 下面是avax主网例子、查询chainIdchainlist.org
provider_urls = 'https://avalanche.blockpi.network/v1/rpc/public'
chianId = 43114
#例子都是自转
#指定gasPrice,单位认为gwei。也可以根据市场的gas、修改43行代码   
我'gasPrice':w3.eth.gas_price,
gasPrice = 126

#打的内容: 如果不知道具体打的内容、只知道16进制的数据、修改 代码42行,'data':'你的是18进制数据'
def create_text():
    return 'data:,{"p":"asc-20","op":"mint","tick":"aval","amt":"100000000"}'
def string_to_hex(string):
    return '0x' + string.encode().hex()

def batch_mint_ethscriptions():
    w3 = Web3(HTTPProvider(provider_urls))
    account = w3.eth.account.from_key(private_key)
    public_key  =account.address
    nonce =  w3.eth.get_transaction_count(public_key)
    end = count + nonce
    last_nonce_update_time = time.time()

    while nonce < end:
        try:
            if time.time() - last_nonce_update_time > 120:  # 180秒 = 3分钟
                nonce = w3.eth.get_transaction_count(public_key)
                last_nonce_update_time = time.time()
            hex_data_uri = string_to_hex(create_text())
            tx = {
                'chainId': chianId,
                'from': public_key,
                'to': public_key,
                'value': 0,
                'data': hex_data_uri,
                'nonce': nonce,
                'gasPrice':w3.to_wei(str(gasPrice),'gwei'),
                'gas': 23000,
            }

            signed_txn = w3.eth.account.sign_transaction(tx, private_key=private_key)
            tx_hash = w3.eth.send_raw_transaction(signed_txn.rawTransaction)
            print('正确',nonce)
            nonce += 1
        except Exception as e:
            print(f"出错 {nonce},")
            print(f'Error: {e}')


if __name__ == '__main__':
    batch_mint_ethscriptions()