# rpc_call

Sends a low-level JSON-RPC request and returns the response's result value as JSON. Provider errors and transport failures are raised as SQL errors.

Canonical HTML: <https://determica.com/docs/functions/rpc_call>

- Kind: scalar function
- Category: [Clients and state contexts](/docs/category/clients-and-state-contexts.md)
- Tags: Client

Sends a low-level JSON-RPC request and returns the response's result value as JSON. Provider errors and transport failures are raised as SQL errors.

## Overload 1: rpc_call(CLIENT, VARCHAR, JSON)

```sql
rpc_call(CLIENT, VARCHAR, JSON)
```

Sends one method call with params in provider order and returns only the JSON-RPC result field.

- Kind: scalar
- Execution context: Live RPC
- Behavior: Immediate Read
- Execution modes: Live Client
- Input shape: Scalar Arguments
- Planning contract: Runtime
- Cardinality: One Per Input
- Determinism: External State
- Return shape: JSON
- Schema stability: Fixed
- Stability: Stable
- Side effects: network_io

### Requirements

- attached_live_client
- rpc

### Risks

- provider_limits
- chain_reorganization

### Inputs

- `client` (CLIENT; required; positional) — Attached live CLIENT used for the JSON-RPC request.
- `method` (VARCHAR; required; positional) — Method name such as eth_blockNumber or eth_getBalance.
- `params` (JSON; required; positional) — JSON array of method parameters in provider order.

### Returns

Raw JSON-RPC result

Returns the JSON result field from the provider response. RPC errors are raised as SQL errors.

- `result` (JSON)

Raw JSON-RPC result. Returns the JSON result field from the provider response. RPC errors are raised as SQL errors.

### Examples

_Named parameters · Needs RPC · RPC required_

```sql
-- Fetch the current gas price via eth_gasPrice
SELECT rpc_call(
  $client,
  'eth_gasPrice',
  '[]'::JSON
) AS response;
```

## Guidance

### When to use rpc_call

rpc_call is the escape hatch for methods that do not have a typed Determica function.

- Prefer typed functions such as get_block, get_logs, or read_contract when you want validated inputs and typed SQL results.
- Pass params as a JSON array in the exact order required by the RPC method.
- The response envelope is not returned; provider and transport errors become SQL errors.

## Related functions

- [transport](/docs/functions/transport.md) — Usually After
- [http_transport](/docs/functions/http_transport.md) — Usually After
- [raw_call](/docs/functions/raw_call.md) — Alternative
