# RpcTransport

Utility functions for working with JSON-RPC Transports.

:::note
This is a convenience module distributed for experimenting with network connectivity on Ox.

Consider using networking functionality from a higher-level library such as [Viem's Transports](https://viem.sh/docs/clients/transports/http)
if you need more features such as: retry logic, WebSockets/IPC, middleware, batch JSON-RPC, etc.
:::

## Examples

### HTTP Instantiation

```ts twoslash
import { RpcTransport } from 'ox'

const transport = RpcTransport.fromHttp(
  'https://1.rpc.thirdweb.com'
)

const blockNumber = await transport.request({
  method: 'eth_blockNumber'
})
// @log: '0x1a2b3c'
```

## Functions

| Name                | Description                         |
| ------------------- | ----------------------------------- |
| [`RpcTransport.fromHttp`](/api/RpcTransport/fromHttp) | Creates a HTTP JSON-RPC Transport from a URL. |

## Errors

| Name                | Description                         |
| ------------------- | ----------------------------------- |
| [`RpcTransport.HttpError`](/api/RpcTransport/errors#rpctransporthttperror) | Thrown when a HTTP request fails. |
| [`RpcTransport.MalformedResponseError`](/api/RpcTransport/errors#rpctransportmalformedresponseerror) | Thrown when a HTTP response is malformed. |

## Types

| Name                | Description                         |
| ------------------- | ----------------------------------- |
| [`RpcTransport.Http`](/api/RpcTransport/types#rpctransporthttp) | HTTP-based RPC Transport. |
| [`RpcTransport.HttpOptions`](/api/RpcTransport/types#rpctransporthttpoptions) |  |
| [`RpcTransport.RequestFn`](/api/RpcTransport/types#rpctransportrequestfn) |  |
| [`RpcTransport.RpcTransport`](/api/RpcTransport/types#rpctransportrpctransport) | Root type for an RPC Transport. |
