jack 6 mesi fa
parent
commit
fcec6e390f

+ 0 - 84
demo/balance_query/balance_query_monad.py

@@ -1,84 +0,0 @@
-# -*- coding: utf-8 -*-
-from web3 import Web3
-import time
-
-# 设置 RPC URL
-rpc_url = "https://testnet-rpc.monad.xyz"
-
-# 初始化 web3.py 提供器
-w3 = Web3(Web3.HTTPProvider(rpc_url))
-
-
-# 检查是否连接成功
-def check_connection():
-    try:
-        network_id = w3.eth.chain_id
-        print(f"已成功连接到链节点,网络ID为: {network_id}。正在查询钱包余额...")
-        return True
-    except Exception as e:
-        print("无法连接到链节点,请检查 URL 是否正确")
-        return False
-
-
-# 钱包地址列表
-wallet_addresses = [
-    '0xe50B77Cd771243b8Ae1d6ce33b4E13ECC5Fa28a6',
-    '0x9ea2ECAD4090E32916e03b77d7C75CbF6C8E0A55',
-    '0xE8A4b0C04300154DC9B1D0e565Ba70F996614690',
-    '0x1b623c5d70c93b437d93c305bf2cfa389095f636',
-    '0x06D25c3e0E1F753ac0486a3f8aaD7259149656cB',
-    '0x15cFEE34Ca4541CAc9a1c4B6F6aB47A65877E240',
-    '0x7aBF0dA8Ac07B6dE7206e467988455E1AD0b60B5',
-    '0xF736f45d4663a8D8DfF7EFA55b1Cf6Fe38D026c8',
-    '0x83173eECf3a6d9ABB79682568e16c2eAd361620e',
-    '0xa401b85B4849Fc7610Bd180cc937859C78528F47',
-    '0x10A43E7Fe77E2D84adBeC26cF0bFc6f403841266',
-    '0x70D5EE1DfddD3726f0D71F4CD5a8Ef43aC651a75'
-]
-
-
-def query_balances():
-    if not check_connection():
-        return
-
-    wallet_num = 1
-    for wallet_address in wallet_addresses:
-        retry_count = 0
-        max_retries = 3
-        delay = 2  # 延迟时间,单位为秒
-
-        result_message = ""
-        result_balance = -1
-
-        # 转换为校验和地址
-        try:
-            checksum_address = w3.to_checksum_address(wallet_address)
-        except Exception as e:
-            print(f"钱包 {wallet_address} 地址格式无效: {str(e)}")
-            wallet_num += 1
-            continue
-
-        while retry_count < max_retries:
-            try:
-                # 查询余额
-                balance = w3.eth.get_balance(checksum_address)
-                # 将余额从 Wei 转换为 Ether
-                balance_eth = w3.from_wei(balance, 'ether')
-                result_message = f"Wallet address: {checksum_address} {wallet_num}, balance: {balance_eth} Token"
-                result_balance = balance_eth
-                print(result_message)
-                wallet_num += 1
-                break
-            except Exception as e:
-                print(f"查询钱包 {checksum_address} {wallet_num} 余额时发生错误: {str(e)}")
-                retry_count += 1
-                print(f"正在重试...(第 {retry_count} 次)")
-                time.sleep(delay)
-
-        if retry_count == max_retries:
-            result_message = f"钱包 {checksum_address} 查询余额失败,已达到最大重试次数。"
-            print(result_message)
-
-
-if __name__ == "__main__":
-    query_balances()

+ 0 - 84
demo/balance_query/balance_query_somnia.py

@@ -1,84 +0,0 @@
-# -*- coding: utf-8 -*-
-from web3 import Web3
-import time
-
-# 设置 RPC URL
-rpc_url = "https://dream-rpc.somnia.network"
-
-# 初始化 web3.py 提供器
-w3 = Web3(Web3.HTTPProvider(rpc_url))
-
-
-# 检查是否连接成功
-def check_connection():
-    try:
-        network_id = w3.eth.chain_id
-        print(f"已成功连接到链节点,网络ID为: {network_id}。正在查询钱包余额...")
-        return True
-    except Exception as e:
-        print("无法连接到链节点,请检查 URL 是否正确")
-        return False
-
-
-# 钱包地址列表
-wallet_addresses = [
-    '0xe50B77Cd771243b8Ae1d6ce33b4E13ECC5Fa28a6',
-    '0x9ea2ECAD4090E32916e03b77d7C75CbF6C8E0A55',
-    '0xE8A4b0C04300154DC9B1D0e565Ba70F996614690',
-    '0x1b623c5d70c93b437d93c305bf2cfa389095f636',
-    '0x06D25c3e0E1F753ac0486a3f8aaD7259149656cB',
-    '0x15cFEE34Ca4541CAc9a1c4B6F6aB47A65877E240',
-    '0x7aBF0dA8Ac07B6dE7206e467988455E1AD0b60B5',
-    '0xF736f45d4663a8D8DfF7EFA55b1Cf6Fe38D026c8',
-    '0x83173eECf3a6d9ABB79682568e16c2eAd361620e',
-    '0xa401b85B4849Fc7610Bd180cc937859C78528F47',
-    '0x10A43E7Fe77E2D84adBeC26cF0bFc6f403841266',
-    '0x70D5EE1DfddD3726f0D71F4CD5a8Ef43aC651a75'
-]
-
-
-def query_balances():
-    if not check_connection():
-        return
-
-    wallet_num = 1
-    for wallet_address in wallet_addresses:
-        retry_count = 0
-        max_retries = 3
-        delay = 2  # 延迟时间,单位为秒
-
-        result_message = ""
-        result_balance = -1
-
-        # 转换为校验和地址
-        try:
-            checksum_address = w3.to_checksum_address(wallet_address)
-        except Exception as e:
-            print(f"钱包 {wallet_address} 地址格式无效: {str(e)}")
-            wallet_num += 1
-            continue
-
-        while retry_count < max_retries:
-            try:
-                # 查询余额
-                balance = w3.eth.get_balance(checksum_address)
-                # 将余额从 Wei 转换为 Ether
-                balance_eth = w3.from_wei(balance, 'ether')
-                result_message = f"Wallet address: {checksum_address} {wallet_num}, balance: {balance_eth} Token"
-                result_balance = balance_eth
-                print(result_message)
-                wallet_num += 1
-                break
-            except Exception as e:
-                print(f"查询钱包 {checksum_address} {wallet_num} 余额时发生错误: {str(e)}")
-                retry_count += 1
-                print(f"正在重试...(第 {retry_count} 次)")
-                time.sleep(delay)
-
-        if retry_count == max_retries:
-            result_message = f"钱包 {checksum_address} 查询余额失败,已达到最大重试次数。"
-            print(result_message)
-
-
-if __name__ == "__main__":
-    query_balances()

+ 0 - 0
demo/balance_query/balance_query_eth.py → demo/query_balance/query_balance_eth.py


+ 106 - 0
demo/query_balance/query_balance_monad.py

@@ -0,0 +1,106 @@
+# -*- coding: utf-8 -*-
+from web3 import Web3
+import time
+
+# 设置 RPC URL
+rpc_url = "https://testnet-rpc.monad.xyz"
+
+# 初始化 web3.py 提供器
+w3 = Web3(Web3.HTTPProvider(rpc_url))
+
+
+# 检查是否连接成功
+def check_connection():
+    try:
+        network_id = w3.eth.chain_id
+        print(f"已成功连接到链节点,网络ID为: {network_id}。正在查询钱包余额...")
+        return True
+    except Exception as e:
+        print("无法连接到链节点,请检查 URL 是否正确")
+        return False
+
+
+# 钱包地址列表
+wallet_addresses = [
+    '0xe50B77Cd771243b8Ae1d6ce33b4E13ECC5Fa28a6',
+    '0x9ea2ECAD4090E32916e03b77d7C75CbF6C8E0A55',
+    '0xE8A4b0C04300154DC9B1D0e565Ba70F996614690',
+    '0x1b623c5d70c93b437d93c305bf2cfa389095f636',
+    '0x06D25c3e0E1F753ac0486a3f8aaD7259149656cB',
+    '0x15cFEE34Ca4541CAc9a1c4B6F6aB47A65877E240',
+    '0x7aBF0dA8Ac07B6dE7206e467988455E1AD0b60B5',
+    '0xF736f45d4663a8D8DfF7EFA55b1Cf6Fe38D026c8',
+    '0x83173eECf3a6d9ABB79682568e16c2eAd361620e',
+    '0xa401b85B4849Fc7610Bd180cc937859C78528F47',
+    '0x10A43E7Fe77E2D84adBeC26cF0bFc6f403841266',
+    '0x70D5EE1DfddD3726f0D71F4CD5a8Ef43aC651a75'
+]
+
+
+def query_balances(wallet_num, wallet_address):
+    retry_count = 0
+    max_retries = 3
+    delay = 2  # 延迟时间,单位为秒
+
+    result_message = ""
+    result_balance = -1
+
+    # 转换为校验和地址
+    try:
+        checksum_address = w3.to_checksum_address(wallet_address)
+    except Exception as e:
+        print(f"钱包 {wallet_address} 地址格式无效: {str(e)}")
+        return wallet_num
+
+    while retry_count < max_retries:
+        try:
+            # 查询余额
+            balance = w3.eth.get_balance(checksum_address)
+            # 将余额从 Wei 转换为 Ether
+            balance_eth = w3.from_wei(balance, 'ether')
+            result_message = f"Wallet {wallet_num}: {checksum_address}\nbalance: {balance_eth} Token"
+            result_balance = balance_eth
+            print(result_message)
+            wallet_num += 1
+            break
+        except Exception as e:
+            print(f"查询钱包 {checksum_address} {wallet_num} 余额时发生错误: {str(e)}")
+            retry_count += 1
+            print(f"正在重试...(第 {retry_count} 次)")
+            time.sleep(delay)
+
+    if retry_count == max_retries:
+        result_message = f"钱包 {checksum_address} 查询余额失败,已达到最大重试次数。"
+        print(result_message)
+
+    return wallet_num
+
+
+def query_nonce(wallet_num, wallet_address):
+    try:
+        checksum_address = w3.to_checksum_address(wallet_address)
+    except Exception as e:
+        print(f"钱包 {wallet_address} 地址格式无效: {str(e)}")
+        return
+
+    try:
+        nonce_latest = w3.eth.get_transaction_count(checksum_address, "latest")
+        nonce_pending = w3.eth.get_transaction_count(checksum_address, "pending")
+        print(f'pending nonce: {nonce_pending} ; latest nonce: {nonce_latest}')
+    except Exception as e:
+        print(f"查询钱包 {checksum_address} {wallet_num} nonce时发生错误: {str(e)}")
+
+
+def main():
+    if not check_connection():
+        return
+
+    wallet_num = 1
+    for wallet_address in wallet_addresses:
+        wallet_num = query_balances(wallet_num, wallet_address)
+        query_nonce(wallet_num - 1, wallet_address)
+        print('------------')
+
+
+if __name__ == "__main__":
+    main()

+ 106 - 0
demo/query_balance/query_balance_somnia.py

@@ -0,0 +1,106 @@
+# -*- coding: utf-8 -*-
+from web3 import Web3
+import time
+
+# 设置 RPC URL
+rpc_url = "https://dream-rpc.somnia.network"
+
+# 初始化 web3.py 提供器
+w3 = Web3(Web3.HTTPProvider(rpc_url))
+
+
+# 检查是否连接成功
+def check_connection():
+    try:
+        network_id = w3.eth.chain_id
+        print(f"已成功连接到链节点,网络ID为: {network_id}。正在查询钱包余额...")
+        return True
+    except Exception as e:
+        print("无法连接到链节点,请检查 URL 是否正确")
+        return False
+
+
+# 钱包地址列表
+wallet_addresses = [
+    '0xe50B77Cd771243b8Ae1d6ce33b4E13ECC5Fa28a6',
+    '0x9ea2ECAD4090E32916e03b77d7C75CbF6C8E0A55',
+    '0xE8A4b0C04300154DC9B1D0e565Ba70F996614690',
+    '0x1b623c5d70c93b437d93c305bf2cfa389095f636',
+    '0x06D25c3e0E1F753ac0486a3f8aaD7259149656cB',
+    '0x15cFEE34Ca4541CAc9a1c4B6F6aB47A65877E240',
+    '0x7aBF0dA8Ac07B6dE7206e467988455E1AD0b60B5',
+    '0xF736f45d4663a8D8DfF7EFA55b1Cf6Fe38D026c8',
+    '0x83173eECf3a6d9ABB79682568e16c2eAd361620e',
+    '0xa401b85B4849Fc7610Bd180cc937859C78528F47',
+    '0x10A43E7Fe77E2D84adBeC26cF0bFc6f403841266',
+    '0x70D5EE1DfddD3726f0D71F4CD5a8Ef43aC651a75'
+]
+
+
+def query_balances(wallet_num, wallet_address):
+    retry_count = 0
+    max_retries = 3
+    delay = 2  # 延迟时间,单位为秒
+
+    result_message = ""
+    result_balance = -1
+
+    # 转换为校验和地址
+    try:
+        checksum_address = w3.to_checksum_address(wallet_address)
+    except Exception as e:
+        print(f"钱包 {wallet_address} 地址格式无效: {str(e)}")
+        return wallet_num
+
+    while retry_count < max_retries:
+        try:
+            # 查询余额
+            balance = w3.eth.get_balance(checksum_address)
+            # 将余额从 Wei 转换为 Ether
+            balance_eth = w3.from_wei(balance, 'ether')
+            result_message = f"Wallet {wallet_num}: {checksum_address}\nbalance: {balance_eth} Token"
+            result_balance = balance_eth
+            print(result_message)
+            wallet_num += 1
+            break
+        except Exception as e:
+            print(f"查询钱包 {checksum_address} {wallet_num} 余额时发生错误: {str(e)}")
+            retry_count += 1
+            print(f"正在重试...(第 {retry_count} 次)")
+            time.sleep(delay)
+
+    if retry_count == max_retries:
+        result_message = f"钱包 {checksum_address} 查询余额失败,已达到最大重试次数。"
+        print(result_message)
+
+    return wallet_num
+
+
+def query_nonce(wallet_num, wallet_address):
+    try:
+        checksum_address = w3.to_checksum_address(wallet_address)
+    except Exception as e:
+        print(f"钱包 {wallet_address} 地址格式无效: {str(e)}")
+        return
+
+    try:
+        nonce_latest = w3.eth.get_transaction_count(checksum_address, "latest")
+        nonce_pending = w3.eth.get_transaction_count(checksum_address, "pending")
+        print(f'pending nonce: {nonce_pending} ; latest nonce: {nonce_latest}')
+    except Exception as e:
+        print(f"查询钱包 {checksum_address} {wallet_num} nonce时发生错误: {str(e)}")
+
+
+def main():
+    if not check_connection():
+        return
+
+    wallet_num = 1
+    for wallet_address in wallet_addresses:
+        wallet_num = query_balances(wallet_num, wallet_address)
+        query_nonce(wallet_num - 1, wallet_address)
+        print('------------')
+
+
+if __name__ == "__main__":
+    main()

+ 1 - 0
project/monad/AccountList.txt

@@ -0,0 +1 @@
+0x618a59dcbbc05a38e10b9872f50855c1b52dd01baced785a7134876ba404be1b

+ 1 - 0
project/monad/contract.py

@@ -0,0 +1 @@
+# -*- coding: utf-8 -*-

+ 108 - 0
project/monad/query_balance_and_nonce.py

@@ -0,0 +1,108 @@
+# -*- coding: utf-8 -*-
+from web3 import Web3
+import time
+
+# 设置 RPC URL
+rpc_url = "https://testnet-rpc.monad.xyz"
+
+# 初始化 web3.py 提供器
+w3 = Web3(Web3.HTTPProvider(rpc_url))
+
+
+# 检查是否连接成功
+def check_connection():
+    try:
+        network_id = w3.eth.chain_id
+        print(f"已成功连接到链节点,网络ID为: {network_id}。正在查询钱包余额...")
+        return True
+    except Exception as e:
+        print("无法连接到链节点,请检查 URL 是否正确")
+        return False
+
+
+# 钱包地址列表
+# wallet_addresses = [
+#     '0xe50B77Cd771243b8Ae1d6ce33b4E13ECC5Fa28a6',
+#     '0x9ea2ECAD4090E32916e03b77d7C75CbF6C8E0A55',
+#     '0xE8A4b0C04300154DC9B1D0e565Ba70F996614690',
+#     '0x1b623c5d70c93b437d93c305bf2cfa389095f636',
+#     '0x06D25c3e0E1F753ac0486a3f8aaD7259149656cB',
+#     '0x15cFEE34Ca4541CAc9a1c4B6F6aB47A65877E240',
+#     '0x7aBF0dA8Ac07B6dE7206e467988455E1AD0b60B5',
+#     '0xF736f45d4663a8D8DfF7EFA55b1Cf6Fe38D026c8',
+#     '0x83173eECf3a6d9ABB79682568e16c2eAd361620e',
+#     '0xa401b85B4849Fc7610Bd180cc937859C78528F47',
+#     '0x10A43E7Fe77E2D84adBeC26cF0bFc6f403841266',
+#     '0x70D5EE1DfddD3726f0D71F4CD5a8Ef43aC651a75'
+# ]
+
+wallet_addresses = ['0x70D5EE1DfddD3726f0D71F4CD5a8ef43aC651a75']
+
+
+def query_balances(wallet_num, wallet_address):
+    retry_count = 0
+    max_retries = 3
+    delay = 2  # 延迟时间,单位为秒
+
+    result_message = ""
+    result_balance = -1
+
+    # 转换为校验和地址
+    try:
+        checksum_address = w3.to_checksum_address(wallet_address)
+    except Exception as e:
+        print(f"钱包 {wallet_address} 地址格式无效: {str(e)}")
+        return wallet_num
+
+    while retry_count < max_retries:
+        try:
+            # 查询余额
+            balance = w3.eth.get_balance(checksum_address)
+            # 将余额从 Wei 转换为 Ether
+            balance_eth = w3.from_wei(balance, 'ether')
+            result_message = f"Wallet {wallet_num}: {checksum_address}\nbalance: {balance_eth} Token"
+            result_balance = balance_eth
+            print(result_message)
+            wallet_num += 1
+            break
+        except Exception as e:
+            print(f"查询钱包 {checksum_address} {wallet_num} 余额时发生错误: {str(e)}")
+            retry_count += 1
+            print(f"正在重试...(第 {retry_count} 次)")
+            time.sleep(delay)
+
+    if retry_count == max_retries:
+        result_message = f"钱包 {checksum_address} 查询余额失败,已达到最大重试次数。"
+        print(result_message)
+
+    return wallet_num
+
+
+def query_nonce(wallet_num, wallet_address):
+    try:
+        checksum_address = w3.to_checksum_address(wallet_address)
+    except Exception as e:
+        print(f"钱包 {wallet_address} 地址格式无效: {str(e)}")
+        return
+
+    try:
+        nonce_latest = w3.eth.get_transaction_count(checksum_address, "latest")
+        nonce_pending = w3.eth.get_transaction_count(checksum_address, "pending")
+        print(f'pending nonce: {nonce_pending} ; latest nonce: {nonce_latest}')
+    except Exception as e:
+        print(f"查询钱包 {checksum_address} {wallet_num} nonce时发生错误: {str(e)}")
+
+
+def main():
+    if not check_connection():
+        return
+
+    wallet_num = 1
+    for wallet_address in wallet_addresses:
+        wallet_num = query_balances(wallet_num, wallet_address)
+        query_nonce(wallet_num - 1, wallet_address)
+        print('------------')
+
+
+if __name__ == "__main__":
+    main()

+ 1 - 0
project/monad/signin.py

@@ -0,0 +1 @@
+# -*- coding: utf-8 -*-

+ 153 - 0
project/monad/swap.py

@@ -0,0 +1,153 @@
+# -*- coding: utf-8 -*-
+from web3 import Web3
+import random
+import time
+import os
+
+# Monad 测试网 RPC URL
+provider_url = "https://testnet-rpc.monad.xyz"
+w3 = Web3(Web3.HTTPProvider(provider_url))
+
+# 合约地址、合约方法哈希值及描述
+contract_data = [
+    {
+        "address": "0x2c9c959516e9aaedb2c748224a41249202ca8be7",
+        "data_hash": "0xd5575982",
+        "description": "Magmastaking"
+    },
+    {
+        "address": "0x760AfE86e5de5fa0Ee542fc7B7B713e1c5425701",
+        "data_hash": "0xd5575982",
+        "description": "ApeBond"
+    },
+    {
+        "address": "0x760AfE86e5de5fa0Ee542fc7B7B713e1c5425701",
+        "data_hash": "0xd0e30db0",
+        "description": "OctoSwap - WMON"
+    }
+]
+
+# 读取私钥文件
+file_path = os.path.join(os.path.dirname(__file__), 'AccountList.txt')
+
+
+def get_random_amount():
+    # 生成随机交易金额 0.00000000****(最后4位随机数)
+    random_tail = random.randint(1000, 9999)
+    return Web3.to_wei(f"0.0000000000{random_tail}", "ether")
+
+
+def get_random_contract_data():
+    # 随机获取合约地址、合约方法哈希值及描述
+    if not contract_data:
+        print("The contract data array is empty, the contract cannot be selected, and the program exits.")
+        exit(1)
+    return random.choice(contract_data)
+
+
+def check_wallet_balance(balance, minimum_balance):
+    # 如果钱包余额小于等于最小余额
+    if balance <= Web3.to_wei(minimum_balance, "ether"):
+        print("The wallet balance is invalid.")
+        exit(1)
+
+
+async def execute_contract(account, minimum_balance):
+    try:
+        # 随机选择一个合约地址、合约方法哈希值及描述
+        contract_info = get_random_contract_data()
+        address = contract_info["address"]
+        data_hash = contract_info["data_hash"]
+        description = contract_info["description"]
+        print(f"Selected contract: {description}")
+        print(f"Selected contract address: {address}")
+        print(f"Selected contract dataHash: {data_hash}")
+
+        # 检查原生代币余额
+        balance = w3.eth.get_balance(account.address)
+        before_balance = Web3.from_wei(balance, "ether")
+        print(f"Native balance: {before_balance}")
+
+        # 检查钱包余额,不能小于 0.2
+        check_wallet_balance(balance, minimum_balance)
+
+        # 质押金额
+        amount_to_stake = get_random_amount()
+        print(f"Amount to contract: {Web3.from_wei(amount_to_stake, 'ether')}")
+
+        if balance < amount_to_stake:
+            raise Exception("Insufficient balance for contract execution.")
+
+        # 构建交易
+        nonce = w3.eth.get_transaction_count(account.address)
+        tx = {
+            "to": Web3.to_checksum_address(address),
+            "value": amount_to_stake,
+            "data": data_hash,
+            "gas": 100000,
+            "gasPrice": Web3.to_wei(50, "gwei"),
+            "nonce": nonce,
+            "chainId": w3.eth.chain_id
+        }
+
+        # 签名并发送交易
+        signed_tx = w3.eth.account.sign_transaction(tx, account.key)
+        tx_hash = w3.eth.send_raw_transaction(signed_tx.raw_transaction)
+        print(f"Contract Execution hash: {tx_hash.hex()}")
+
+        # 等待交易确认
+        receipt = w3.eth.wait_for_transaction_receipt(tx_hash)
+        execute_status = receipt["status"]
+        if execute_status == 1:
+            print("Contract Execution status: seccessful")
+        elif execute_status == 0:
+            print("Contract Execution status: failed")
+        else:
+            print("Contract Execution status: unknown")
+
+        # 检查交易后的余额
+        balance_staking = w3.eth.get_balance(account.address)
+        after_balance = Web3.from_wei(balance_staking, "ether")
+        print(f"Native balance after transaction: {after_balance}")
+        print(f"The cost of this transaction: {float(before_balance) - float(after_balance)}")
+
+    except Exception as e:
+        print(f"Error executing contract: {e}")
+
+
+async def run_multiple_staking(private_keys):
+    last_times = 100
+    min_delay = 10
+    max_delay = 20
+    minimum_balance = 4
+
+    for private_key in private_keys:
+        account = w3.eth.account.from_key(private_key.strip())
+        print(f"Processing wallet with address: {account.address}")
+
+        for i in range(last_times):
+            if last_times > 1:
+                print(f"Starting Contract attempt {i + 1}")
+            await execute_contract(account, minimum_balance)
+            print(f"Completed Contract attempt {i + 1}")
+            if i < last_times - 1:
+                delay = random.uniform(min_delay, max_delay)
+                print(f"Waiting for {delay} seconds...")
+                print('------------------------------------------------------------')
+                time.sleep(random.uniform(min_delay, max_delay))
+
+
+async def main():
+    try:
+        with open(file_path, 'r') as file:
+            private_keys = [line.strip() for line in file if line.strip()]
+        await run_multiple_staking(private_keys)
+    except Exception as err:
+        print(f'读取文件时发生错误: {err}')
+        exit(1)
+
+
+if __name__ == "__main__":
+    import asyncio
+
+    asyncio.run(main())

+ 140 - 0
project/monad/transaction.py

@@ -0,0 +1,140 @@
+# -*- coding: utf-8 -*-
+from web3 import Web3
+import random
+import time
+import os
+
+# Monad 测试网 RPC URL
+provider_url = "https://testnet-rpc.monad.xyz"
+w3 = Web3(Web3.HTTPProvider(provider_url))
+
+# 合约地址、合约方法哈希值及描述
+contract_data = [
+    {
+        "address": "0x2c9c959516e9aaedb2c748224a41249202ca8be7",
+        "data_hash": "0xd5575982",
+        "description": "Magmastaking"
+    },
+    {
+        "address": "0x760AfE86e5de5fa0Ee542fc7B7B713e1c5425701",
+        "data_hash": "0xd5575982",
+        "description": "ApeBond"
+    },
+    {
+        "address": "0x760AfE86e5de5fa0Ee542fc7B7B713e1c5425701",
+        "data_hash": "0xd0e30db0",
+        "description": "OctoSwap - WMON"
+    }
+]
+
+# 读取私钥文件
+file_path = os.path.join(os.path.dirname(__file__), 'AccountList.txt')
+
+def get_random_amount():
+    # 生成随机交易金额 0.00000000****(最后4位随机数)
+    random_tail = random.randint(1000, 9999)
+    return Web3.to_wei(f"0.00000000{random_tail}", "ether")
+
+def get_random_contract_data():
+    # 随机获取合约地址、合约方法哈希值及描述
+    if not contract_data:
+        print("The contract data array is empty, the contract cannot be selected, and the program exits.")
+        exit(1)
+    return random.choice(contract_data)
+
+
+def check_wallet_balance(balance, minimum_balance):
+    # 如果钱包余额小于等于最小余额
+    if balance <= Web3.to_wei(minimum_balance, "ether"):
+        print("The wallet balance is invalid.")
+        exit(1)
+
+async def execute_contract(account, minimum_balance):
+    try:
+        # 随机选择一个合约地址、合约方法哈希值及描述
+        contract_info = get_random_contract_data()
+        address = contract_info["address"]
+        data_hash = contract_info["data_hash"]
+        description = contract_info["description"]
+        print(f"Selected contract: {description}")
+        print(f"Selected contract address: {address}")
+        print(f"Selected contract dataHash: {data_hash}")
+
+        # 检查原生代币余额
+        balance = w3.eth.get_balance(account.address)
+        before_balance = Web3.from_wei(balance, "ether")
+        print(f"Native balance: {before_balance}")
+
+        # 检查钱包余额,不能小于 0.2
+        check_wallet_balance(balance, minimum_balance)
+
+        # 质押金额
+        amount_to_stake = get_random_amount()
+        print(f"Amount to contract: {Web3.from_wei(amount_to_stake, 'ether')}")
+
+        if balance < amount_to_stake:
+            raise Exception("Insufficient balance for contract execution.")
+
+        # 构建交易
+        nonce = w3.eth.get_transaction_count(account.address)
+        tx = {
+            "to": Web3.to_checksum_address(address),
+            "value": amount_to_stake,
+            "data": data_hash,
+            "gas": 100000,
+            "gasPrice": Web3.to_wei(50, "gwei"),
+            "nonce": nonce,
+            "chainId": w3.eth.chain_id
+        }
+
+        # 签名并发送交易
+        signed_tx = w3.eth.account.sign_transaction(tx, account.key)
+        tx_hash = w3.eth.send_raw_transaction(signed_tx.raw_transaction)
+        print(f"Contract Execution hash: {tx_hash.hex()}")
+
+        # 等待交易确认
+        receipt = w3.eth.wait_for_transaction_receipt(tx_hash)
+        print("Contract Execution status: ok")
+
+        # 检查交易后的余额
+        balance_staking = w3.eth.get_balance(account.address)
+        after_balance = Web3.from_wei(balance_staking, "ether")
+        print(f"Native balance after transaction: {after_balance}")
+        print(f"The cost of this transaction: {float(before_balance) - float(after_balance)}")
+
+    except Exception as e:
+        print(f"Error executing contract: {e}")
+
+async def run_multiple_staking(private_keys):
+    last_times = 100
+    min_delay = 10
+    max_delay = 20
+    minimum_balance = 3
+
+    for private_key in private_keys:
+        account = w3.eth.account.from_key(private_key.strip())
+        print(f"Processing wallet with address: {account.address}")
+
+        for i in range(last_times):
+            if last_times > 1:
+                print(f"Starting Contract attempt {i + 1}")
+            await execute_contract(account, minimum_balance)
+            print(f"Completed Contract attempt {i + 1}")
+            if i < last_times - 1:
+                delay = random.uniform(min_delay, max_delay)
+                print(f"Waiting for {delay} seconds...")
+                print('------------------------------------------------------------')
+                time.sleep(random.uniform(min_delay, max_delay))
+
+async def main():
+    try:
+        with open(file_path, 'r') as file:
+            private_keys = [line.strip() for line in file if line.strip()]
+        await run_multiple_staking(private_keys)
+    except Exception as err:
+        print(f'读取文件时发生错误: {err}')
+        exit(1)
+
+if __name__ == "__main__":
+    import asyncio
+    asyncio.run(main())

+ 1 - 0
project/pharos/AccountList.txt

@@ -0,0 +1 @@
+0x618a59dcbbc05a38e10b9872f50855c1b52dd01baced785a7134876ba404be1b

+ 106 - 0
project/pharos/query_balance_and_nonce.py

@@ -0,0 +1,106 @@
+# -*- coding: utf-8 -*-
+from web3 import Web3
+import time
+
+# 设置 RPC URL
+rpc_url = 'https://testnet.dplabs-internal.com'
+
+# 初始化 web3.py 提供器
+w3 = Web3(Web3.HTTPProvider(rpc_url))
+
+
+# 检查是否连接成功
+def check_connection():
+    try:
+        network_id = w3.eth.chain_id
+        print(f"已成功连接到链节点,网络ID为: {network_id}。正在查询钱包余额...")
+        return True
+    except Exception as e:
+        print("无法连接到链节点,请检查 URL 是否正确")
+        return False
+
+
+# 钱包地址列表
+wallet_addresses = [
+    '0xe50B77Cd771243b8Ae1d6ce33b4E13ECC5Fa28a6',
+    '0x9ea2ECAD4090E32916e03b77d7C75CbF6C8E0A55',
+    '0xE8A4b0C04300154DC9B1D0e565Ba70F996614690',
+    '0x1b623c5d70c93b437d93c305bf2cfa389095f636',
+    '0x06D25c3e0E1F753ac0486a3f8aaD7259149656cB',
+    '0x15cFEE34Ca4541CAc9a1c4B6F6aB47A65877E240',
+    '0x7aBF0dA8Ac07B6dE7206e467988455E1AD0b60B5',
+    '0xF736f45d4663a8D8DfF7EFA55b1Cf6Fe38D026c8',
+    '0x83173eECf3a6d9ABB79682568e16c2eAd361620e',
+    '0xa401b85B4849Fc7610Bd180cc937859C78528F47',
+    '0x10A43E7Fe77E2D84adBeC26cF0bFc6f403841266',
+    '0x70D5EE1DfddD3726f0D71F4CD5a8Ef43aC651a75'
+]
+
+
+def query_balances(wallet_num, wallet_address):
+    retry_count = 0
+    max_retries = 3
+    delay = 2  # 延迟时间,单位为秒
+
+    result_message = ""
+    result_balance = -1
+
+    # 转换为校验和地址
+    try:
+        checksum_address = w3.to_checksum_address(wallet_address)
+    except Exception as e:
+        print(f"钱包 {wallet_address} 地址格式无效: {str(e)}")
+        return wallet_num
+
+    while retry_count < max_retries:
+        try:
+            # 查询余额
+            balance = w3.eth.get_balance(checksum_address)
+            # 将余额从 Wei 转换为 Ether
+            balance_eth = w3.from_wei(balance, 'ether')
+            result_message = f"Wallet {wallet_num}: {checksum_address}\nbalance: {balance_eth} Token"
+            result_balance = balance_eth
+            print(result_message)
+            wallet_num += 1
+            break
+        except Exception as e:
+            print(f"查询钱包 {checksum_address} {wallet_num} 余额时发生错误: {str(e)}")
+            retry_count += 1
+            print(f"正在重试...(第 {retry_count} 次)")
+            time.sleep(delay)
+
+    if retry_count == max_retries:
+        result_message = f"钱包 {checksum_address} 查询余额失败,已达到最大重试次数。"
+        print(result_message)
+
+    return wallet_num
+
+
+def query_nonce(wallet_num, wallet_address):
+    try:
+        checksum_address = w3.to_checksum_address(wallet_address)
+    except Exception as e:
+        print(f"钱包 {wallet_address} 地址格式无效: {str(e)}")
+        return
+
+    try:
+        nonce_latest = w3.eth.get_transaction_count(checksum_address, "latest")
+        nonce_pending = w3.eth.get_transaction_count(checksum_address, "pending")
+        print(f'pending nonce: {nonce_pending} ; latest nonce: {nonce_latest}')
+    except Exception as e:
+        print(f"查询钱包 {checksum_address} {wallet_num} nonce时发生错误: {str(e)}")
+
+
+def main():
+    if not check_connection():
+        return
+
+    wallet_num = 1
+    for wallet_address in wallet_addresses:
+        wallet_num = query_balances(wallet_num, wallet_address)
+        query_nonce(wallet_num - 1, wallet_address)
+        print('------------')
+
+
+if __name__ == "__main__":
+    main()

+ 0 - 0
reference/demo/balance_query/balance_query_eth.mjs → reference/demo/balance_query/query_balance_eth.mjs


+ 0 - 0
reference/demo/balance_query/balance_query_monad.mjs → reference/demo/balance_query/query_balance_monad.mjs


+ 0 - 0
reference/demo/balance_query/balance_query_somnia.mjs → reference/demo/balance_query/query_balance_somnia.mjs


+ 0 - 0
reference/demo/balance_query/balance_query_sui.mjs → reference/demo/balance_query/query_balance_sui.mjs