---
name: grpc
description: "Call gRPC methods on the Train Solver NetworkService (blockchain.proto). Use when the user wants to query or debug a network gRPC service — balances, health, fees, transactions, etc."
---

# Network gRPC Client

Call any RPC method on the Train Solver `NetworkService` defined in `protos/blockchain.proto`.

## Prerequisites

```bash
cd tools/swap-cli && npm install
```

## Usage

```bash
cd tools/swap-cli && node grpc-call.mjs <endpoint> <method> [json-body]
```

- `endpoint`: gRPC host:port (e.g., `localhost:60979`)
- `method`: RPC method name, or `list` to show all methods
- `json-body`: JSON request body (default: `{}`)

## Arguments

`$ARGUMENTS` should contain:
- The gRPC endpoint URL/port
- The method to call
- Any request parameters

Parse naturally — the user might say "check health on localhost:60979" or "get balance for 0xABC on bsc-testnet via localhost:60979".

## Common Methods

**Health & Status:**
```bash
node grpc-call.mjs localhost:60979 GetHealth '{}'
```

**Balances:**
```bash
node grpc-call.mjs localhost:60979 GetBalance '{"network_slug":"arb-sepolia","address":"0x...","token_contract":"0x000..."}'
node grpc-call.mjs localhost:60979 GetBatchBalances '{"network_slug":"bsc-testnet","address":"0x...","token_contracts":["0x000..."]}'
```

**Fee Estimation:**
```bash
node grpc-call.mjs localhost:60979 GetEstimatedFees '{"network_slug":"eth-sepolia"}'
```

**Transaction Lifecycle:**
```bash
node grpc-call.mjs localhost:60979 GetTransaction '{"network_slug":"arb-sepolia","transaction_hash":"0x..."}'
node grpc-call.mjs localhost:60979 GetTransactionLifecycle '{"network_slug":"arb-sepolia","correlation_id":"..."}'
```

**TP Diagnostics:**
```bash
node grpc-call.mjs localhost:60979 GetQueueStats '{"network_slug":"arb-sepolia"}'
node grpc-call.mjs localhost:60979 GetStuckTransactions '{"network_slug":"arb-sepolia"}'
node grpc-call.mjs localhost:60979 GetActiveReservations '{"network_slug":"arb-sepolia"}'
```

**Build Transactions:**
```bash
node grpc-call.mjs localhost:60979 BuildSolverLockTransaction '{"network_slug":"...","request":{...}}'
node grpc-call.mjs localhost:60979 BuildUserRedeemTransaction '{"network_slug":"...","request":{...}}'
```

## Proto Field Convention

Use snake_case for field names in the JSON body (matching the proto definition), not camelCase.
