> ## Documentation Index
> Fetch the complete documentation index at: https://docs.b3os.org/llms.txt
> Use this file to discover all available pages before exploring further.

# RAILGUN Query Balance

Query private token balances in a RAILGUN wallet. Returns all ERC20 token balances or a specific token balance. Ideal for: pre-flight validation, UI display, balance verification, unshield planning.

![RAILGUN Query Balance logo](https://cdn.b3.fun/b3os-icons/railgun.png)
Catalog action EVM Onchain railgun

Query private token balances in a RAILGUN wallet. Returns all ERC20 token balances or a specific token balance. Ideal for: pre-flight validation, UI display, balance verification, unshield planning.


## At a Glance

| Field | Value |
| --- | --- |
| Action ID | `railgun-query-balance` |
| Category | EVM Onchain |
| Connector | `railgun` |
| Requires gas | No |
| Funds movement | None declared |
| Tags | `railgun`, `privacy`, `query`, `balance`, `read` |

## Payload Schema

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `chainId` | `number` | Yes | Chain ID. Supported: Ethereum \(1\), BNB Chain \(56\), Polygon \(137\), Arbitrum \(42161\) |
| `mnemonic` | `string` | No | RAILGUN wallet mnemonic \(12 or 24 words\) |
| `tokenAddress` | `string` | No | Optional: Specific ERC20 token address to query. If omitted, returns all token balances in the wallet. |
| `maxRetries` | `number` | No | Maximum number of retry attempts for the balance query. After a shield, the merkletree scan needs time to index new UTXOs. Each retry progresses the scan. Default: 10. |
| `retryIntervalMs` | `number` | No | Milliseconds to wait between retry attempts. Default: 15000 \(15 seconds\). |

## Result Schema

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `balances` | `array` | Yes | Array of ERC20 token balances in the RAILGUN wallet |
| `railgunAddress` | `string` | Yes | The RAILGUN 0zk... address for this wallet |
| `totalTokens` | `number` | No | Total number of different tokens with non-zero balances |

## Examples

**Workflow node**

```json
{
  "type": "railgun-query-balance",
  "payload": {
    "chainId": 1
  },
  "children": [],
  "connector": {
    "type": "railgun",
    "id": "conn_railgun"
  }
}
```
  **Test with API**

```bash
curl -X POST "https://api.b3os.org/v1/actions/railgun-query-balance/test" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "inputs": {
    "chainId": 1
  }
}'
```

**Use expressions for dynamic values**

Payload fields can use workflow expressions such as `{{$trigger.body.amount}}`, `{{$nodes.fetch.result.price}}`, and `{{$props.asset}}` when the value should come from a trigger, prior node, or reusable workflow prop.