# raw_call

Executes an isolated EVM call and returns the raw response bytes. Without a CLIENT, it builds a reusable READ and does not execute the call.

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

- Kind: scalar function
- Category: [Chain reads](/docs/category/chain-reads.md)
- Tags: RPC, Program Compiler, Simulate

Executes an isolated EVM call and returns the raw response bytes. Without a CLIENT, it builds a reusable READ and does not execute the call.

## Overload 1: raw_call(CLIENT, ADDRESS, BYTES)

```sql
raw_call(CLIENT, ADDRESS, BYTES)
```

Immediately calls the CLIENT's current state context. Only a live CLIENT necessarily resolves latest.

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

### Requirements

- client_state_context
- rpc

### Risks

- provider_limits
- chain_reorganization

### Inputs

- `client` (CLIENT; required; positional) — CLIENT for retained execution state, local simulation, or live RPC.
- `to` (ADDRESS; required; positional) — Target address for eth_call.
- `data` (BYTES; required; positional) — ABI-encoded function selector and arguments.

### Returns

Raw eth_call bytes

Returns the raw BYTES result from eth_call. Decode it with ABI casts or ABI decode helpers when needed.

- `result` (BYTES)

Raw eth_call bytes. Returns the raw BYTES result from eth_call. Decode it with ABI casts or ABI decode helpers when needed.

### Examples

_Named parameters · Needs RPC · RPC required_

```sql
-- Check the WETH balance of Vitalik's address via balanceOf
WITH abi AS (
  SELECT '[
    {
      "type": "function",
      "name": "balanceOf",
      "stateMutability": "view",
      "inputs":  [{ "name": "account", "type": "address" }],
      "outputs": [{ "type": "uint256" }]
    }
  ]'::JSON AS abi_json
),
calldata AS (
  SELECT encode_function_data(abi.abi_json, 'balanceOf', '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045'::ADDRESS) AS data
  FROM abi
)
SELECT raw_call($client,
            '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'::ADDRESS, -- Ethereum mainnet WETH
            calldata.data) AS raw_balance
FROM calldata;
```

## Overload 2: raw_call(CLIENT, ADDRESS, BYTES, BIGINT)

```sql
raw_call(CLIENT, ADDRESS, BYTES, BIGINT)
```

Adds an explicit numeric block height for deterministic historical calls.

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

### Requirements

- client_state_context
- rpc

### Risks

- provider_limits
- chain_reorganization

### Inputs

- `client` (CLIENT; required; positional) — CLIENT for retained execution state, local simulation, or live RPC.
- `to` (ADDRESS; required; positional) — Target address for eth_call.
- `data` (BYTES; required; positional) — ABI-encoded function selector and arguments.
- `block_number` (BIGINT; required; positional) — Numeric block height for a reproducible historical call.

### Returns

Raw eth_call bytes

Returns the raw BYTES result from eth_call. Decode it with ABI casts or ABI decode helpers when needed.

- `result` (BYTES)

Raw eth_call bytes. Returns the raw BYTES result from eth_call. Decode it with ABI casts or ABI decode helpers when needed.

### Examples

_Named parameters · Needs RPC · RPC required_

```sql
-- Pin Vitalik's WETH balance check to Ethereum mainnet block 21,000,000
WITH abi AS (
  SELECT '[
    {
      "type": "function",
      "name": "balanceOf",
      "stateMutability": "view",
      "inputs":  [{ "name": "account", "type": "address" }],
      "outputs": [{ "type": "uint256" }]
    }
  ]'::JSON AS abi_json
),
calldata AS (
  SELECT encode_function_data(abi.abi_json, 'balanceOf', '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045'::ADDRESS) AS data
  FROM abi
)
SELECT raw_call($client,
            '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'::ADDRESS, -- Ethereum mainnet WETH
            calldata.data,
            21000000) AS raw_balance
FROM calldata;
```

## Overload 3: raw_call(ADDRESS, BYTES)

```sql
raw_call(ADDRESS, BYTES)
```

Records calldata for a later isolated EVM call using the default caller, value, and gas limit.

- Kind: scalar
- Execution context: Live RPC
- Behavior: Read Builder
- Execution modes: Read Constructor
- Input shape: Scalar Arguments
- Planning contract: Deferred Execution
- Cardinality: One Per Input
- Determinism: Deterministic
- Return shape: Scalar
- Schema stability: Fixed
- Stability: Stable
- Side effects: None documented

### Requirements

- rpc

### Inputs

- `to` (ADDRESS; required; positional) — Contract address that the later observation should call.
- `data` (BYTES; required; positional) — Exact calldata bytes for the later observation.

### Returns

Raw-call READ

Returns a READ with the zero address as caller, zero Wei value, and a 16,777,216 gas limit.

- `read` (READ)

Raw-call READ. Returns a READ with the zero address as caller, zero Wei value, and a 16,777,216 gas limit.

## Overload 4: raw_call(ADDRESS, BYTES, ADDRESS, UINT256, UBIGINT)

```sql
raw_call(ADDRESS, BYTES, ADDRESS, UINT256, UBIGINT)
```

Records explicit call semantics for a later isolated EVM call; construction does not execute it.

- Kind: scalar
- Execution context: Live RPC
- Behavior: Read Builder
- Execution modes: Read Constructor
- Input shape: Scalar Arguments
- Planning contract: Deferred Execution
- Cardinality: One Per Input
- Determinism: Deterministic
- Return shape: Scalar
- Schema stability: Fixed
- Stability: Stable
- Side effects: None documented

### Requirements

- rpc

### Inputs

- `to` (ADDRESS; required; positional) — Contract address that the later observation should call.
- `data` (BYTES; required; positional) — Exact calldata bytes for the later observation.
- `caller` (ADDRESS; required; positional) — EVM msg.sender value exposed to the observed call.
- `value` (UINT256; required; positional) — Exact UINT256 value, in Wei, exposed to the isolated call.
- `gas_limit` (UBIGINT; required; positional) — Maximum gas available to the call; values greater than 30,000,000 are rejected.

### Returns

Raw-call READ

Returns a READ containing the explicit caller, Wei value, gas limit, and calldata.

- `read` (READ)

Raw-call READ. Returns a READ containing the explicit caller, Wei value, gas limit, and calldata.

## Guidance

### Immediate call or reusable READ

CLIENT overloads execute immediately. Overloads without CLIENT only build a READ for observe or observe_after_step.

- Use raw_call when calldata and raw return bytes are the desired interface.
- Use read_contract for ABI encoding and typed SQL results.
- Use call_decode when raw return bytes already exist and need ABI-derived columns.

### State and failure behavior

The call is isolated and does not publish state changes.

- Use a pinned CLIENT or explicit block number for repeatable chain reads.
- Historical calls may require archive-capable RPC access.
- Keep the raw BYTES result when exact response framing is evidence; decode only in a separate step.

### Evaluation

The call executes only when an OBSERVATION consumes the READ. Observation calls cannot exceed 30,000,000 gas.

## Additional examples

```sql
SELECT raw_call('0x0000000000000000000000000000000000000001'::ADDRESS, '0x'::BYTES);
```

```sql
SELECT raw_call('0x0000000000000000000000000000000000000001'::ADDRESS, '0x'::BYTES, '0x0000000000000000000000000000000000000000'::ADDRESS, 0::UINT256, 16777216);
```

## Related functions

- [encode_function_data](/docs/functions/encode_function_data.md) — Usually After
- [call_decode](/docs/functions/call_decode.md) — Usually Before
- [read_contract](/docs/functions/read_contract.md) — Alternative
- [read_contract_multicall](/docs/functions/read_contract_multicall.md) — See Also
