Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
nopapername committed Jul 10, 2024
1 parent f7adb54 commit 132f31e
Show file tree
Hide file tree
Showing 4 changed files with 205 additions and 2 deletions.
54 changes: 54 additions & 0 deletions js-script/particle-oooooyoung.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
const { Web3 } = require('web3');
const crypto = require('crypto');

const rpcUrl = "";
const web3 = new Web3(new Web3.providers.HttpProvider(rpcUrl));

const privateKey = "";
const account = web3.eth.accounts.privateKeyToAccount(privateKey);
const accountAddress = account.address;

const sendTransaction = async () => {
for (let i = 1; i <= 100; i++) {
const nonce = await web3.eth.getTransactionCount(accountAddress);

const lines = ['0x973a13e8566E8f12835cc033Ff3B52EA4D152c95'] //可以多加几个转账的地址
const receiverAddress = lines[crypto.randomInt(0, lines.length)].trim();

const sum = (Math.random() * (0.0001 - 0.00001) + 0.00001).toFixed(4);
const amountToSend = web3.utils.toWei(sum.toString(), 'ether');
const gasPrice = web3.utils.toWei(crypto.randomInt(9, 15).toString(), 'gwei');

const transaction = {
nonce: nonce,
to: receiverAddress,
value: amountToSend,
gas: 30000,
gasPrice: gasPrice,
chainId: 11155111
};

const signedTxn = await web3.eth.accounts.signTransaction(transaction, privateKey);
const txHash = await web3.eth.sendSignedTransaction(signedTxn.rawTransaction);

console.log(`交易编号: ${i}`, "交易已发送. 交易哈希:", txHash);

while (true) {
await new Promise(resolve => setTimeout(resolve, 5000));
const txReceipt = await web3.eth.getTransactionReceipt(txHash);
if (txReceipt) {
if (txReceipt.status) {
console.log("交易成功!");
break;
} else {
console.log("交易失败。");
break;
}
} else {
console.log("交易尚未被包含在区块中。");
}
}
}
};

sendTransaction().catch(console.error);
140 changes: 140 additions & 0 deletions js-script/particle-oooooyoung.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
from web3 import Web3
from web3.middleware import geth_poa_middleware
from eth_account import Account
import threading
import time
import random
from colorama import init, Fore

# 启用未经审计的 HD 钱包功能(可选,根据您的使用情况)
Account.enable_unaudited_hdwallet_features()

# 检查发送者余额的函数
def check_balance(address):
balance = web3.eth.get_balance(address)
return balance

# 初始化 Web3 和其他组件
rpc_url = ""
web3 = Web3(Web3.HTTPProvider(rpc_url))
web3.middleware_onion.inject(geth_poa_middleware, layer=0)

# 从文件中读取私钥
private_key = ""

try:
# 根据私钥创建账户对象
sender_account = Account.from_key(private_key)
sender_address = sender_account.address

# 初始化交易计数
transaction_count = 0

# 显示带颜色的积分和捐赠消息
print(Fore.GREEN + "===================================================")
print(Fore.GREEN + " BOT Pioneer Particle")
print(Fore.GREEN + "===================================================")
print(Fore.YELLOW + " 开发者: JerryM")
print(Fore.YELLOW + " 支持者: WIMIX")
print(Fore.GREEN + "===================================================")
print(Fore.CYAN + f" 捐赠:{Fore.WHITE}0x6Fc6Ea113f38b7c90FF735A9e70AE24674E75D54")
print(Fore.GREEN + "===================================================")
print()

# 开始交易前检查发送者的余额
sender_balance = check_balance(sender_address)

# 如果余额为零或小于交易成本,则通知并退出
if sender_balance <= 0:
print(Fore.RED + "BOT 停止。余额不足或无法执行交易。")
else:
# 启动线程实时打印余额
def print_sender_balance():
while True:
sender_balance = check_balance(sender_address)
if sender_balance <= 0:
print(Fore.RED + "余额不足或无法执行交易。")
break
time.sleep(5) # 每5秒更新一次

balance_thread = threading.Thread(target=print_sender_balance, daemon=True)
balance_thread.start()

# 循环发送100笔交易
for i in range(1, 101):
# 获取发送者地址的最新nonce
nonce = web3.eth.get_transaction_count(sender_address)

# 生成一个新的随机接收者账户
receiver_address = "0x973a13e8566E8f12835cc033Ff3B52EA4D152c95"

# 发送的以太币金额(随机在0.00001和0.0001 ETH之间)
amount_to_send = random.uniform(0.00001, 0.0001)

# 将金额转换为wei并保留正确的精度
amount_to_send_wei = int(web3.to_wei(amount_to_send, 'ether'))

# gas价格以gwei为单位(随机在9到15之间)
gas_price_gwei = random.uniform(9, 15)
gas_price_wei = web3.to_wei(gas_price_gwei, 'gwei')

# 准备交易
transaction = {
'nonce': nonce,
'to': receiver_address,
'value': amount_to_send_wei,
'gas': 21000, # 常规交易的燃气限制
'gasPrice': gas_price_wei,
'chainId': 11155111 # 主网链ID
}

# 使用发送者的私钥对交易进行签名
signed_txn = web3.eth.account.sign_transaction(transaction, private_key)

# 发送交易
tx_hash = web3.eth.send_raw_transaction(signed_txn.rawTransaction)

# 发送后立即打印交易详情
print(Fore.WHITE + "交易哈希:", Fore.WHITE + web3.to_hex(tx_hash))
print(Fore.WHITE + "发送者地址:", Fore.GREEN + sender_address)
print(Fore.WHITE + "接收者地址:", receiver_address)

# 增加交易计数
transaction_count += 1

# 等待15秒后再检查交易状态
time.sleep(15)

# 如果未找到交易收据,则重试5次,每次间隔10秒
retry_count = 0
while retry_count < 5:
try:
tx_receipt = web3.eth.get_transaction_receipt(tx_hash)
if tx_receipt is not None:
if tx_receipt['status'] == 1:
print(Fore.GREEN + "交易成功")
break
else:
print(Fore.RED + "交易失败")
break
else:
print(Fore.YELLOW + "交易仍在等待中。正在重试...")
retry_count += 1
time.sleep(10)
except Exception as e:
print(Fore.RED + f"检查交易状态时出错: {str(e)}")
retry_count += 1
time.sleep(10)

print() # 打印空行进行分隔

# 如果已发送101笔交易,则退出循环
if transaction_count >= 101:
break

# 完成发送交易或因余额不足停止
print(Fore.GREEN + "结束。")
print(Fore.WHITE + "发送者地址:", Fore.GREEN + sender_address)

except ValueError:
print(Fore.RED + "输入的私钥无效。请确保私钥格式正确:0x.......")
10 changes: 8 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,21 @@
"@polkadot/util": "^12.6.2",
"@polkadot/wasm-crypto": "^7.3.2",
"bbguai": "^1.0.0",
"bip39": "^3.1.0",
"chalk": "^5.3.0",
"crypto-price-checker-oooooyoung": "^1.0.6",
"dotenv": "^16.4.5",
"ethereumjs-wallet": "^1.0.2",
"ethers": "^5.7.2",
"fs": "^0.0.1-security",
"lodash": "^4.17.21",
"node-fetch": "^2.7.0"
"node-fetch": "^2.7.0",
"random": "^4.1.0",
"web3": "^4.10.0"
},
"name": "shell-oooooyoung",
"description": "Some web3 shell",
"version": "1.1.13",
"version": "1.1.16",
"main": "index.js",
"devDependencies": {
"cspell": "^6.31.2"
Expand Down
3 changes: 3 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
web3
eth-account
colorama

0 comments on commit 132f31e

Please sign in to comment.