# Besu Balance Query Script Query balances from Besu RPC nodes running on VMID 115-117. **Note**: Only RPC nodes (115-117) expose RPC endpoints. Validators (106-110) and sentries (111-114) don't have RPC enabled. ## Installation ```bash npm install ethers ``` ## Usage ### Basic Usage (with RPC template) The script defaults to querying RPC nodes 115-117. It uses a template to generate RPC URLs by substituting `{vmid}` with the VMID: ```bash RPC_TEMPLATE="http://192.168.11.{vmid}:8545" \ node scripts/besu_balances_106_117.js ``` **Note**: The default template is `http://192.168.11.{vmid}:8545` and defaults to VMIDs 115-117 (RPC nodes only). ### With Custom RPC URLs You can also provide explicit RPC URLs (comma-separated): ```bash RPC_URLS="http://192.168.11.13:8545,http://192.168.11.14:8545,http://192.168.11.15:8545" \ node scripts/besu_balances_106_117.js ``` ### With Token Addresses ```bash RPC_TEMPLATE="http://192.168.11.{vmid}:8545" \ WETH9_ADDRESS="0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2" \ WETH10_ADDRESS="0xYourWETH10Address" \ node scripts/besu_balances_106_117.js ``` ## Environment Variables - `RPC_TEMPLATE`: Template for RPC URLs with `{vmid}` placeholder (default: `http://192.168.11.{vmid}:8545`) - `RPC_URLS`: Comma-separated list of explicit RPC URLs (overrides template if set) - `VMID_START`: Starting VMID for template (default: `115` - RPC nodes only) - `VMID_END`: Ending VMID for template (default: `117` - RPC nodes only) - `WETH9_ADDRESS`: WETH9 token contract address (default: `0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2`) - `WETH10_ADDRESS`: WETH10 token contract address (optional, skipped if not set) ## Output The script outputs balance information for each RPC endpoint: ``` VMID: 106 RPC: http://192.168.11.13:8545 chainId: 138 block: 12345 ETH: 1.5 (wei: 1500000000000000000) WETH9: 0.0 WETH (raw: 0) WETH10: skipped (missing address) --- ``` ## Features - Queries native ETH balance - Queries ERC-20 token balances (WETH9, WETH10) - Fetches token decimals and symbol for formatted display - Health checks (chainId, blockNumber) - Concurrent requests (limit: 4) - Request timeout: 15 seconds - Continues on failures, reports errors per endpoint - Exit code: 0 if at least one RPC succeeded, 1 if all failed ## Container IP Mapping (Reference) For the deployed containers, the VMID to IP mapping is: - 106 -> 192.168.11.13 (besu-validator-1) - 107 -> 192.168.11.14 (besu-validator-2) - 108 -> 192.168.11.15 (besu-validator-3) - 109 -> 192.168.11.16 (besu-validator-4) - 110 -> 192.168.11.18 (besu-validator-5) - 111 -> 192.168.11.19 (besu-sentry-2) - 112 -> 192.168.11.20 (besu-sentry-3) - 113 -> 192.168.11.21 (besu-sentry-4) - 114 -> 192.168.11.22 (besu-sentry-5) - 115 -> 192.168.11.23 (besu-rpc-1) - 116 -> 192.168.11.24 (besu-rpc-2) - 117 -> 192.168.11.25 (besu-rpc-3) **Note**: Since the IPs don't follow a simple pattern with VMID, it's recommended to use `RPC_URLS` with explicit addresses or create a custom mapping in the script.