rpc array
This commit is contained in:
23
claim.sh
23
claim.sh
@@ -12,15 +12,24 @@ monitor_value=${1:-0.1}
|
||||
#export http_proxy="http://10.3.255.132:51837"
|
||||
#export https_proxy="http://10.3.255.132:51837"
|
||||
|
||||
#rpc=https://api.mainnet-beta.solana.com
|
||||
rpc=https://solana-mainnet.core.chainstack.com/b366b2ab269b22f4b6dd521c59079618
|
||||
#rpc=https://mainnet.helius-rpc.com/?api-key=fa8414c7-043e-4888-922a-344a2d413ec8
|
||||
#rpc=https://prettiest-multi-scion.solana-mainnet.quiknode.pro/879eb32f3cd556cfff80973ff6a51b9e8b7a81ec/
|
||||
#rpc=https://silent-tiniest-diamond.solana-mainnet.quiknode.pro/fcef276a3d99aa044e9d7d7193aced24563de630/
|
||||
# 定义RPC URL数组
|
||||
rpcurls=(
|
||||
"https://solana-mainnet.core.chainstack.com/b366b2ab269b22f4b6dd521c59079618"
|
||||
"https://prettiest-multi-scion.solana-mainnet.quiknode.pro/879eb32f3cd556cfff80973ff6a51b9e8b7a81ec/"
|
||||
"https://silent-tiniest-diamond.solana-mainnet.quiknode.pro/fcef276a3d99aa044e9d7d7193aced24563de630/"
|
||||
"https://api.mainnet-beta.solana.com"
|
||||
)
|
||||
|
||||
echo $rpc
|
||||
toaddress="DefJYX8sJmaLBQGyvWPS3rRgVbJRf9kvKEJ19uJpJQEf"
|
||||
|
||||
echo "toaddress=" $toaddress
|
||||
files=$(find . -maxdepth 2 -type f -name "*.json")
|
||||
for keyfile in $files; do
|
||||
# 随机选择一个RPC URL
|
||||
index=$((RANDOM % ${#rpcurls[@]}))
|
||||
rpc=${rpcurls[$index]}
|
||||
echo "选中rpc=$rpc"
|
||||
|
||||
echo $keyfile
|
||||
rewards=$(ore --rpc $rpc --keypair "$keyfile" rewards | sed 's/ ORE//')
|
||||
if [ -z "$rewards" ]; then
|
||||
@@ -34,7 +43,7 @@ for keyfile in $files; do
|
||||
echo "claim reward $keyfile"
|
||||
echo "================================================"
|
||||
echo "Rewards ($rewards) is greater than monitor value ($monitor_value). Claiming rewards..."
|
||||
./ore --rpc $rpc --keypair $keyfile --priority-fee 10000 claim
|
||||
./ore --rpc $rpc --keypair $keyfile --priority-fee 10000 claim $rewards $toaddress
|
||||
else
|
||||
echo "Rewards ($rewards) is less than or equal to monitor value ($monitor_value). No action needed."
|
||||
fi
|
||||
|
||||
77
gatherSol.sh
Normal file
77
gatherSol.sh
Normal file
@@ -0,0 +1,77 @@
|
||||
#!/bin/bash
|
||||
|
||||
KPATH="."
|
||||
# 目标账户的密钥文件路径
|
||||
DESTINATION_KEYPAIR="./id1.json"
|
||||
# 设置RPC节点
|
||||
RPC_URL=""
|
||||
# 最大尝试次数
|
||||
MAX_RETRIES=10
|
||||
# 重试间隔时间(秒)
|
||||
RETRY_INTERVAL=0
|
||||
|
||||
# Solana CLI配置设置
|
||||
solana config set --url $RPC_URL
|
||||
|
||||
# 清空账户并转移SOL,带有重试机制
|
||||
function drain_account_with_retry() {
|
||||
from_keypair=$1
|
||||
destination_address=$(solana-keygen pubkey $DESTINATION_KEYPAIR)
|
||||
attempt=1
|
||||
|
||||
while [ $attempt -le $MAX_RETRIES ]; do
|
||||
echo "Attempt $attempt: Calculating available balance for transfer..."
|
||||
|
||||
# 获取源账户余额(以lamports为单位)
|
||||
balance_lamports=$(solana balance $from_keypair --url $RPC_URL --output json | jq -r '.lamports')
|
||||
|
||||
# 转换lamports为SOL
|
||||
balance_SOL=$(echo "scale=9; $balance_lamports / 1000000000" | bc)
|
||||
|
||||
# 使用`solana fees`命令获取当前的交易费用(以lamports为单位)
|
||||
fee_lamports=$(solana fees --url $RPC_URL --output json | jq -r '.lamportsPerSignature')
|
||||
|
||||
# 将费用转换为SOL
|
||||
fee_SOL=$(echo "scale=9; $fee_lamports / 1000000000" | bc)
|
||||
|
||||
# 计算实际转账金额(余额减去交易费用),单位为SOL
|
||||
amount_SOL=$(echo "$balance_SOL - $fee_SOL" | bc)
|
||||
|
||||
if (( $(echo "$amount_SOL > 0" | bc -l) )); then
|
||||
echo "Transferring $amount_SOL SOL from $from_keypair to $destination_address..."
|
||||
transfer_output=$(solana transfer $destination_address $amount_SOL --fee-payer $from_keypair --from $from_keypair --url $RPC_URL 2>&1)
|
||||
transfer_status=$?
|
||||
|
||||
if [ $transfer_status -eq 0 ]; then
|
||||
echo "Transfer successful."
|
||||
return 0
|
||||
else
|
||||
echo "Transfer failed: $transfer_output"
|
||||
echo "Waiting $RETRY_INTERVAL seconds before retry..."
|
||||
sleep $RETRY_INTERVAL
|
||||
fi
|
||||
else
|
||||
echo "Not enough balance in $from_keypair to cover the transaction fee after $attempt attempts."
|
||||
return 1
|
||||
fi
|
||||
|
||||
attempt=$((attempt+1))
|
||||
|
||||
|
||||
done
|
||||
|
||||
echo "Transfer failed after $MAX_RETRIES attempts."
|
||||
return 1
|
||||
}
|
||||
|
||||
|
||||
|
||||
# 示例:清空某个账户并将SOL转移到id1.json对应的账户,带有重试机制
|
||||
# 注意:请确保替换下面的路径为你的实际路径
|
||||
# for keypair in *.json; do
|
||||
for keypair in $(ls id*.json.d | sort -V); do
|
||||
|
||||
drain_account_with_retry $KPATH/$keypair
|
||||
done
|
||||
|
||||
echo "Operation complete."
|
||||
Reference in New Issue
Block a user