Cover photo

直接用 其他evm链上的自己改

不要忘了

pip install web3

from web3 import Web3
import os

private_key = '填入私钥'
address = '钱包地址'
rpc_url = "https://avalanche.public-rpc.com"
web3 = Web3(Web3.HTTPProvider(rpc_url))
print(web3.is_connected())
print(Web3.from_wei(web3.eth.get_balance(address), 'ether'))
c = 0
while True:
    nonce = web3.eth.get_transaction_count(address)
    gas_price = int(web3.eth.gas_price * 1.1)
    tx = {
        'nonce': nonce,
        'chainId': 43114,
        'to': address, 
        'from': address,
        'data': '0x646174613a2c7b2270223a226173632d3230222c226f70223a226d696e74222c227469636b223a2261766176222c22616d74223a223639363936393639227d',
        'gasPrice': gas_price,
        'value': Web3.to_wei(0, 'ether') 
    }

    try:
        gas = web3.eth.estimate_gas(tx)
        tx['gas'] = gas
        print(tx)
        signed_tx = web3.eth.account.sign_transaction(tx, private_key)
        tx_hash = web3.eth.send_raw_transaction(signed_tx.rawTransaction)
        receipt = web3.eth.wait_for_transaction_receipt(tx_hash, timeout=10)
        if receipt.status == 1:
            c += 1
            print(f"{c} Mint Success!")
    except Exception as e:
        print(e)