# http_transport

Builds a TRANSPORT for an HTTP or HTTPS JSON-RPC endpoint. It records the endpoint, declared chain id, and request policy without contacting the provider.

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

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

Builds a TRANSPORT for an HTTP or HTTPS JSON-RPC endpoint. It records the endpoint, declared chain id, and request policy without contacting the provider.

## Overload 1: http_transport(VARCHAR, UBIGINT)

```sql
http_transport(VARCHAR, UBIGINT)
```

Records chain_id as trusted metadata. The function does not call eth_chainId or verify the value against the endpoint.

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

### Inputs

- `url` (VARCHAR; required; positional) — HTTP or HTTPS JSON-RPC endpoint. Without a scheme, localhost and 127.0.0.1 use http://; other hosts use https://.
- `chain_id` (UBIGINT; required; positional) — EVM chain id recorded in the TRANSPORT. Determica trusts this value and does not query the endpoint while constructing the TRANSPORT.

### Returns

HTTP TRANSPORT

Returns a TRANSPORT value containing type, url, chain_id, and the merged config object.

- `transport` (TRANSPORT)

HTTP TRANSPORT. Returns a TRANSPORT value containing type, url, chain_id, and the merged config object.

### Examples

_Local SQL · Local_

```sql
SELECT http_transport('http://127.0.0.1:8545', 31337) AS transport;
```

## Overload 2: http_transport(VARCHAR)

```sql
http_transport(VARCHAR)
```

Uses chain id 1. If url has no scheme, local endpoints use HTTP and other hosts use HTTPS.

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

### Inputs

- `url` (VARCHAR; required; positional) — HTTP or HTTPS JSON-RPC endpoint. Without a scheme, localhost and 127.0.0.1 use http://; other hosts use https://.

### Returns

HTTP TRANSPORT

Returns a TRANSPORT value containing type, url, chain_id, and the merged config object.

- `transport` (TRANSPORT)

HTTP TRANSPORT. Returns a TRANSPORT value containing type, url, chain_id, and the merged config object.

### Examples

_Local SQL · Local_

```sql
SELECT http_transport('eth.drpc.org') AS transport;
```

## Overload 3: http_transport(VARCHAR, UBIGINT, JSON)

```sql
http_transport(VARCHAR, UBIGINT, JSON)
```

Overrides selected HTTP policy fields. Fields omitted from config keep their defaults.

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

### Inputs

- `url` (VARCHAR; required; positional) — HTTP or HTTPS JSON-RPC endpoint. Without a scheme, localhost and 127.0.0.1 use http://; other hosts use https://.
- `chain_id` (UBIGINT; required; positional) — EVM chain id recorded in the TRANSPORT. Determica trusts this value and does not query the endpoint while constructing the TRANSPORT.
- `config` (JSON; required; positional) — JSON object whose fields override the default request, retry, pagination, batching, and rate-limit policy.

### Returns

HTTP TRANSPORT

Returns a TRANSPORT value containing type, url, chain_id, and the merged config object.

- `transport` (TRANSPORT)

HTTP TRANSPORT. Returns a TRANSPORT value containing type, url, chain_id, and the merged config object.

### Examples

_Local SQL · Local_

```sql
-- Limit retries and parallel requests for a rate-limited provider.
SELECT http_transport(
  'https://eth.llamarpc.com',
  1,
  json('{
    "timeout_ms": 15000,
    "retry_count": 2,
    "max_block_range": 1000,
    "requests_per_second": 10,
    "max_concurrent": 4
  }')
) AS transport;
```

## Guidance

### Request and retry policy

The config object overrides individual defaults. http_transport merges the object locally; the CLIENT validates supported field types and ranges when it consumes the TRANSPORT.

- timeout_ms sets the timeout for each HTTP attempt and defaults to 30000.
- retry_count is the number of retries after the first attempt and defaults to 9.
- Native clients wait retry_delay_ms before the first retry, then double the delay up to retry_max_delay_ms. The defaults are 125 and 32000. Browser clients retry without a blocking delay.
- deadline_ms is checked between attempts and defaults to 0, which disables the retry deadline.
- verify_ssl defaults to true for native clients. Browsers apply their own certificate policy.

### RPC work limits

- max_block_range is the largest eth_getLogs block range one request spans and defaults to 2000. get_logs starts at 2000 blocks or less and doubles after sparse chunks up to it; set it to the provider's limit.
- max_rpc_batch_size defaults to 100 and caps batches created by timestamp lookup and shared chain-state hydration. read_contract and create_access_list use their own rpc_batch_size options.
- requests_per_second and max_concurrent default to 20 and 10. Rate limits are shared by normalized URL; the first request for a URL sets both values for the runtime.

### transport vs http_transport

- Use http_transport when you need HTTP-specific options like timeout, retry count, rate limits, concurrency, SSL verification, or log pagination limits.
- Use transport for minimal generic transport construction.

## Additional examples

```sql
-- Anvil uses chain id 31337 by default.
SELECT http_transport('http://127.0.0.1:8545', 31337) AS transport;
```

## Related functions

- [transport](/docs/functions/transport.md) — Alternative
- [get_logs](/docs/functions/get_logs.md) — Usually Before
- [rpc_call](/docs/functions/rpc_call.md) — Usually Before
