View this page as Markdown

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.

Example

Local

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

API reference

Exact signatures with descriptions, requirements, inputs, returns, and examples.

raw_call(CLIENT, ADDRESS, BYTES) # Immediate Read · RPC required

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

Inputs

Name Type Use
client CLIENT

CLIENT for retained execution state, local simulation, or live RPC.

required positional
to ADDRESS

Target address for eth_call.

required positional
data BYTES

ABI-encoded function selector and arguments.

required positional

Returns

Name Type
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.

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 overloads

raw_call(CLIENT, ADDRESS, BYTES, BIGINT) # Immediate Read · RPC required

Adds an explicit numeric block height for deterministic historical calls.

Inputs

Name Type Use
client CLIENT

CLIENT for retained execution state, local simulation, or live RPC.

required positional
to ADDRESS

Target address for eth_call.

required positional
data BYTES

ABI-encoded function selector and arguments.

required positional
block_number BIGINT

Numeric block height for a reproducible historical call.

required positional

Returns

Name Type
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.

Overload examples

Named parameters · RPC required

-- 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;
raw_call(ADDRESS, BYTES) # Read Builder · RPC required

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

Inputs

Name Type Use
to ADDRESS

Contract address that the later observation should call.

required positional
data BYTES

Exact calldata bytes for the later observation.

required positional

Returns

Name Type
read READ

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

raw_call(ADDRESS, BYTES, ADDRESS, UINT256, UBIGINT) # Read Builder · RPC required

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

Inputs

Name Type Use
to ADDRESS

Contract address that the later observation should call.

required positional
data BYTES

Exact calldata bytes for the later observation.

required positional
caller ADDRESS

EVM msg.sender value exposed to the observed call.

required positional
value UINT256

Exact UINT256 value, in Wei, exposed to the isolated call.

required positional
gas_limit UBIGINT

Maximum gas available to the call; values greater than 30,000,000 are rejected.

required positional

Returns

Name Type
read READ

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

Examples

Local SQL

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

Named parameters · RPC required

-- 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;

Related functions

Category and tags

Category
Chain reads
Tag
RPC
Tag
Simulate