# 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#L307)

## `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#L768)

## `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#L307)

## `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#L307)

## `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#L307)

## `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#L307)

## `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#L307)

## `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#L307)

## `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#L307)

## `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#L307)

## `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#L307)

## `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#L307)

## `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)
