OPBNB铭文$OPBN科学家Python脚本分享

铭文规则

$opbn项目方规定,单个地址只能打100次铭文,超过的无效。
在这里插入图片描述

批量生成OPbnb钱包地址

程序默认生成10个,可以自行调整。

from eth_account import Account, messages
from eth_account.hdaccount import Mnemonic

def generate_opbnb_wallets(num_wallets=10):
    wallets = []
    for _ in range(num_wallets):
        account = Account.create()
        address = account.address
        private_key = account.privateKey.hex()
        
        # Generate mnemonic
        mnemonic = Mnemonic().to_mnemonic(account.key)

        wallet_info = {
            'address': address,
            'private_key': private_key,
            'mnemonic': mnemonic
        }
        wallets.append(wallet_info)

    return wallets

if __name__ == "__main__":
    num_wallets = 10
    opbnb_wallets = generate_opbnb_wallets(num_wallets)
    target_addresses = []
    for i, wallet in enumerate(opbnb_wallets, start=1):
        target_addresses.append(wallet['address'])
        print(f"{wallet['address']}")
        print(f"{wallet['private_key']}")
        print(f"{wallet['mnemonic']}")
   
    print(f"{target_addresses}")

批量转账

下面程序中,sender_address和private_key是你的发送BNB的地址。上一步生成的地址,拷贝,放到target_addresses数组里,每个地址转0.01BNB,可以自行修改,0.01打100次足够了。

from web3 import Web3
from web3.middleware import geth_poa_middleware

rpc_url = "" # 自行替换
web3 = Web3(Web3.HTTPProvider(rpc_url))
web3.middleware_onion.inject(geth_poa_middleware, layer=0)

sender_address = ""  # 自行替换
private_key = ""  # 自行替换

target_addresses = ['']  

amount_to_send = Web3.toWei(0.01, 'ether')  

def build_transaction(to_address):
    transaction = {
        'to': web3.toChecksumAddress(to_address),
        'value': amount_to_send,
        'gas': 21000,
        'gasPrice': int(web3.eth.gas_price*1.0),  
        'nonce': web3.eth.getTransactionCount(sender_address),
        'chainId': 204,  
    }
    return transaction

def send_transaction(transaction, private_key):
    signed_transaction = web3.eth.account.signTransaction(transaction, private_key)
    transaction_hash = web3.eth.sendRawTransaction(signed_transaction.rawTransaction)
    return transaction_hash

for target_address in target_addresses:
    transaction = build_transaction(target_address)
    transaction_hash = send_transaction(transaction, private_key)
    receipt = web3.eth.wait_for_transaction_receipt(transaction_hash, timeout=120)
    print(f"Transaction sent to {target_address}. Transaction Hash: {web3.toHex(transaction_hash)}")
    if receipt.status == 1:
        print(f"successfully sent to {target_address}")

打铭文

按照项目方的煞笔规则,每个地址可以打100次铭文,打超的部分作废,你有10个地址的话,就起10个程序跑。

from web3 import Web3
from dotenv import load_dotenv
import os,time
load_dotenv()

private_key = '填你wallet的private key'
address = '填你wallet的address'
rpc_url = "https://1rpc.io/opbnb"
web3 = Web3(Web3.HTTPProvider(rpc_url))
address = Web3.toChecksumAddress(address)
print(web3.isConnected()) 
print(Web3.fromWei(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.5)
    tx = {
        'nonce': nonce,
        'chainId': 204,
        'to': Web3.toChecksumAddress("0x83b978cf73ee1d571b1a2550c5570861285af337"), 
        'from':address,
        'data':'0x646174613a6170706c69636174696f6e2f6a736f6e2c7b2270223a226f70627263222c226f70223a226d696e74222c227469636b223a226f70626e227d', #mint 16进制数据
        'gasPrice': gas_price,
        'value': Web3.toWei(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)
        print(web3.toHex(tx_hash))
        receipt = web3.eth.wait_for_transaction_receipt(tx_hash, timeout=120)
        if receipt.status == 1:
            if c > 100:
                sys.exit()
            c = c+1
            time.sleep(20) # 可以自行修改
            print("%s Mint Success!" %c)
            continue
        else:
            continue
    except Exception as e:
        print(e)

批量归集

等$opbn出转账功能了,再补上。

  • 8
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值