# RpcSchema Types

## `RpcSchema.Default`

Type-safe union of all JSON-RPC Methods.

### Examples

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

type Schema = RpcSchema.Default
//   ^?
```

**Source:** [src/core/RpcSchema.ts](https://github.com/wevm/ox/blob/main/src/core/RpcSchema.ts#L367)

## `RpcSchema.Eth`

Union of all JSON-RPC Methods for the `eth_` namespace.

### Examples

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

type Schema = RpcSchema.Eth
//   ^?
```

**Source:** [src/core/internal/rpcSchemas/eth.ts](https://github.com/wevm/ox/blob/main/src/core/internal/rpcSchemas/eth.ts#L834)

## `RpcSchema.ExtractItem`

Extracts a schema item from a [`RpcSchema.Generic`](/api/RpcSchema/types#generic) or [`RpcSchema.MethodNameGeneric`](/api/RpcSchema/types#methodnamegeneric).

### Examples

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

type Item = RpcSchema.ExtractItem<
  RpcSchema.Eth,
  'eth_getBlockByNumber'
>
const item = null as unknown as Item
//    ^?
```

**Source:** [src/core/RpcSchema.ts](https://github.com/wevm/ox/blob/main/src/core/RpcSchema.ts#L367)

## `RpcSchema.ExtractMethodName`

Type-safe union of all JSON-RPC Method Names.

### Examples

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

type MethodName =
  RpcSchema.ExtractMethodName<RpcSchema.Default>
//   ^?
```

**Source:** [src/core/RpcSchema.ts](https://github.com/wevm/ox/blob/main/src/core/RpcSchema.ts#L367)

## `RpcSchema.ExtractParams`

Extracts parameters from a [`RpcSchema.Generic`](/api/RpcSchema/types#generic) or [`RpcSchema.MethodNameGeneric`](/api/RpcSchema/types#methodnamegeneric).

### Examples

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

type Eth_GetBlockByNumber = RpcSchema.ExtractParams<
  RpcSchema.Eth,
  'eth_getBlockByNumber'
>
const parameters = null as unknown as Eth_GetBlockByNumber
//    ^?
```

**Source:** [src/core/RpcSchema.ts](https://github.com/wevm/ox/blob/main/src/core/RpcSchema.ts#L367)

## `RpcSchema.ExtractRequest`

Extracts request from a [`RpcSchema.Generic`](/api/RpcSchema/types#generic) or [`RpcSchema.MethodNameGeneric`](/api/RpcSchema/types#methodnamegeneric).

### Examples

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

type Request = RpcSchema.ExtractRequest<
  RpcSchema.Eth,
  'eth_getBlockByNumber'
>
const request = null as unknown as Request
//    ^?
```

**Source:** [src/core/RpcSchema.ts](https://github.com/wevm/ox/blob/main/src/core/RpcSchema.ts#L367)

## `RpcSchema.ExtractReturnType`

Extracts return type from a [`RpcSchema.Generic`](/api/RpcSchema/types#generic) or [`RpcSchema.MethodNameGeneric`](/api/RpcSchema/types#methodnamegeneric).

### Examples

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

type ReturnType = RpcSchema.ExtractReturnType<
  RpcSchema.Eth,
  'eth_getBlockByNumber'
>
const returnType = null as unknown as ReturnType
//    ^?
```

**Source:** [src/core/RpcSchema.ts](https://github.com/wevm/ox/blob/main/src/core/RpcSchema.ts#L367)

## `RpcSchema.From`

Type to define a custom type-safe JSON-RPC Schema.

### Examples

```ts twoslash
import { RpcSchema, RpcRequest } from 'ox'

type Schema = RpcSchema.From<{
  Request: {
    method: 'eth_foobar'
    params: [id: number]
  }
  ReturnType: string
}>
```

**Source:** [src/core/RpcSchema.ts](https://github.com/wevm/ox/blob/main/src/core/RpcSchema.ts#L367)

## `RpcSchema.FromViem`

Converts a [Viem-compatible RPC schema](https://viem.sh) (tuple of `{ Method, Parameters, ReturnType }`) to an Ox [`RpcSchema.Generic`](/api/RpcSchema/types#generic) (union of `{ Request, ReturnType }`).

### Examples

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

type OxSchema = RpcSchema.FromViem<
  [
    {
      Method: 'eth_blockNumber'
      Parameters?: undefined
      ReturnType: `0x${string}`
    },
    {
      Method: 'eth_chainId'
      Parameters?: undefined
      ReturnType: `0x${string}`
    }
  ]
>
```

**Source:** [src/core/RpcSchema.ts](https://github.com/wevm/ox/blob/main/src/core/RpcSchema.ts#L367)

## `RpcSchema.FromZod`

Converts a record of Zod `params`/`returns` schemas (keyed by method name) to an Ox [`RpcSchema.Generic`](/api/RpcSchema/types#generic) (union of `{ Request, ReturnType }`).

Each method's name comes from its key. Both `params` and `ReturnType` are derived from the Zod schema's input (wire) type, since raw JSON-RPC clients send and receive wire values. Decode wire results to their native representation explicitly via `zod.RpcSchema.decodeReturns`.

### Examples

```ts twoslash
import { RpcSchema } from 'ox'
import { z } from 'ox/zod'

type Schema = RpcSchema.FromZod<typeof z.RpcSchema.Eth>
//   ^?
```

**Source:** [src/core/RpcSchema.ts](https://github.com/wevm/ox/blob/main/src/core/RpcSchema.ts#L367)

## `RpcSchema.Generic`

Generic type to define a JSON-RPC Method.

### Examples

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

type Schema = RpcSchema.Generic
//   ^?
```

**Source:** [src/core/RpcSchema.ts](https://github.com/wevm/ox/blob/main/src/core/RpcSchema.ts#L367)

## `RpcSchema.MethodNameGeneric`

Generic type to define a JSON-RPC Method Name.

### Examples

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

type Name = RpcSchema.MethodNameGeneric
//   ^?
```

**Source:** [src/core/RpcSchema.ts](https://github.com/wevm/ox/blob/main/src/core/RpcSchema.ts#L367)

## `RpcSchema.Schema`

Schema input accepted by APIs that statically type JSON-RPC requests (e.g. [`Provider.from`](/api/Provider/from), [`RpcTransport.fromHttp`](/api/RpcTransport/fromHttp)): either an Ox [`RpcSchema.Generic`](/api/RpcSchema/types#generic) or a record of Zod `params`/`returns` schemas (keyed by method name) from `ox/zod`.

**Source:** [src/core/RpcSchema.ts](https://github.com/wevm/ox/blob/main/src/core/RpcSchema.ts#L367)

## `RpcSchema.ToGeneric`

Resolves a [`RpcSchema.Schema`](/api/RpcSchema/types#schema) input to an Ox [`RpcSchema.Generic`](/api/RpcSchema/types#generic). A Zod namespace is converted via [`RpcSchema.FromZod`](/api/RpcSchema/types#fromzod); a `Generic` is passed through; otherwise falls back to [`RpcSchema.Default`](/api/RpcSchema/types#default).

**Source:** [src/core/RpcSchema.ts](https://github.com/wevm/ox/blob/main/src/core/RpcSchema.ts#L367)

## `RpcSchema.ToViem`

Converts an Ox [`RpcSchema.Generic`](/api/RpcSchema/types#generic) (union of `{ Request, ReturnType }`) to a [Viem-compatible RPC schema](https://viem.sh) (tuple of `{ Method, Parameters, ReturnType }`).

### Examples

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

type ViemSchema = RpcSchema.ToViem<
  | {
      Request: {
        method: 'eth_blockNumber'
        params?: undefined
      }
      ReturnType: `0x${string}`
    }
  | {
      Request: { method: 'eth_chainId'; params?: undefined }
      ReturnType: `0x${string}`
    }
>
```

**Source:** [src/core/RpcSchema.ts](https://github.com/wevm/ox/blob/main/src/core/RpcSchema.ts#L367)

## `RpcSchema.Wallet`

Union of all JSON-RPC Methods for the `wallet_` namespace.

### Examples

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

type Schema = RpcSchema.Wallet
//   ^?
```

**Source:** [src/core/internal/rpcSchemas/wallet.ts](https://github.com/wevm/ox/blob/main/src/core/internal/rpcSchemas/wallet.ts#L461)
