File tree Expand file tree Collapse file tree 2 files changed +85
-16
lines changed
crates/node/tests/testdata Expand file tree Collapse file tree 2 files changed +85
-16
lines changed Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ # 脚本:发送所有 commitBatch 交易到 Anvil
4+ # 用法: ./send_commit_batch.sh
5+
6+ RPC_URL=" http://localhost:8544"
7+ JSON_FILE=" test_transactions.json"
8+
9+ # 检查 JSON 文件是否存在
10+ if [ ! -f " $JSON_FILE " ]; then
11+ echo " 错误: 找不到文件 $JSON_FILE "
12+ exit 1
13+ fi
14+
15+ # 检查是否安装了 jq 和 cast
16+ if ! command -v jq & > /dev/null; then
17+ echo " 错误: 需要安装 jq"
18+ exit 1
19+ fi
20+
21+ if ! command -v cast & > /dev/null; then
22+ echo " 错误: 需要安装 cast (foundry)"
23+ exit 1
24+ fi
25+
26+ echo " 开始发送 commitBatch 交易..."
27+ echo " RPC URL: $RPC_URL "
28+ echo " "
29+
30+ # 获取所有 commitBatch 的键
31+ keys=$( jq -r ' .commitBatch | keys[]' " $JSON_FILE " )
32+
33+ # 计数器
34+ count=0
35+ success=0
36+ failed=0
37+
38+ # 遍历所有 commitBatch 交易
39+ for key in $keys ; do
40+ count=$(( count + 1 ))
41+ echo " [$count ] 发送 commitBatch[$key ]..."
42+
43+ # 获取原始交易数据
44+ raw_tx=$( jq -r " .commitBatch[\" $key \" ]" " $JSON_FILE " )
45+
46+ # 发送交易
47+ if tx_hash=$( cast rpc --rpc-url " $RPC_URL " eth_sendRawTransaction " $raw_tx " 2>&1 ) ; then
48+ # 提取交易哈希(去掉可能的引号)
49+ tx_hash=$( echo " $tx_hash " | tr -d ' "' )
50+ echo " ✓ 成功! 交易哈希: $tx_hash "
51+ success=$(( success + 1 ))
52+ else
53+ echo " ✗ 失败! 错误: $tx_hash "
54+ failed=$(( failed + 1 ))
55+ fi
56+
57+ echo " "
58+
59+ # 可选:添加延迟以避免请求过快
60+ # sleep 0.1
61+ done
62+
63+ echo " ================================"
64+ echo " 完成!"
65+ echo " 总交易数: $count "
66+ echo " 成功: $success "
67+ echo " 失败: $failed "
68+ echo " ================================"
69+
70+
Load Diff Large diffs are not rendered by default.
You can’t perform that action at this time.
0 commit comments