RpcSchema Types
RpcSchema.Default
Type-safe union of all JSON-RPC Methods.
Examples
import { RpcSchema } from 'ox'
type type Schema = {
Request: {
method: "eth_accounts";
params?: undefined;
};
ReturnType: Address[];
} | {
Request: {
method: "eth_blobBaseFee";
params?: undefined;
};
ReturnType: Hex;
} | ... 48 more ... | {
...;
}Schema = RpcSchema.Default
Source: src/RpcSchema.ts
RpcSchema.Eth
Union of all JSON-RPC Methods for the eth_
namespace.
Examples
import { RpcSchema } from 'ox'
type type Schema = {
Request: {
method: "eth_accounts";
params?: undefined;
};
ReturnType: Address[];
} | {
Request: {
method: "eth_blobBaseFee";
params?: undefined;
};
ReturnType: Hex;
} | ... 35 more ... | {
...;
}Schema = RpcSchema.Eth
Source: src/internal/rpcSchemas/eth.ts
RpcSchema.ExtractItem
Extracts a schema item from a RpcSchema.Generic
or RpcSchema.MethodNameGeneric
.
Examples
import { RpcSchema } from 'ox'
type type Item = {
Request: {
method: "eth_getBlockByNumber";
params: [block: Number<Hex> | Tag, includeTransactionObjects: boolean];
};
ReturnType: {
...;
} | null;
}Item = RpcSchema.ExtractItem<RpcSchema.Eth, 'eth_getBlockByNumber'>
Source: src/RpcSchema.ts
RpcSchema.ExtractMethodName
Type-safe union of all JSON-RPC Method Names.
Examples
import { RpcSchema } from 'ox'
type type MethodName = "eth_accounts" | "eth_blobBaseFee" | "eth_blockNumber" | "eth_call" | "eth_chainId" | "eth_coinbase" | "eth_estimateGas" | "eth_feeHistory" | "eth_gasPrice" | "eth_getBalance" | ... 39 more ... | "wallet_watchAsset"MethodName = RpcSchema.ExtractMethodName<RpcSchema.Default>
Source: src/RpcSchema.ts
RpcSchema.ExtractParams
Extracts parameters from a RpcSchema.Generic
or RpcSchema.MethodNameGeneric
.
Examples
import { RpcSchema } from 'ox'
type type Eth_GetBlockByNumber = [block: `0x${string}` | Tag, includeTransactionObjects: boolean]Eth_GetBlockByNumber = RpcSchema.ExtractParams<RpcSchema.Eth, 'eth_getBlockByNumber'>
Source: src/RpcSchema.ts
RpcSchema.ExtractRequest
Extracts request from a RpcSchema.Generic
or RpcSchema.MethodNameGeneric
.
Examples
import { RpcSchema } from 'ox'
type type Request = {
method: "eth_getBlockByNumber";
params: [block: Number<Hex> | Tag, includeTransactionObjects: boolean];
}Request = RpcSchema.ExtractRequest<RpcSchema.Eth, 'eth_getBlockByNumber'>
Source: src/RpcSchema.ts
RpcSchema.ExtractReturnType
Extracts return type from a RpcSchema.Generic
or RpcSchema.MethodNameGeneric
.
Examples
import { RpcSchema } from 'ox'
type type ReturnType = {
baseFeePerGas?: `0x${string}` | undefined;
blobGasUsed?: `0x${string}` | undefined;
difficulty?: `0x${string}` | undefined;
excessBlobGas?: `0x${string}` | undefined;
extraData?: Hex | undefined;
... 21 more ...;
withdrawalsRoot?: Hex | undefined;
} | nullReturnType = RpcSchema.ExtractReturnType<RpcSchema.Eth, 'eth_getBlockByNumber'>
Source: src/RpcSchema.ts
RpcSchema.From
Type to define a custom type-safe JSON-RPC Schema.
Examples
import { RpcSchema, RpcRequest } from 'ox'
type Schema = RpcSchema.From<{
Request: {
method: 'eth_foobar',
params: [id: number],
}
ReturnType: string
}>
Source: src/RpcSchema.ts
RpcSchema.Generic
Generic type to define a JSON-RPC Method.
Examples
import { RpcSchema } from 'ox'
type type Schema = {
Request: {
method: string;
params?: unknown;
};
ReturnType?: unknown;
}Schema = RpcSchema.Generic
Source: src/RpcSchema.ts
RpcSchema.MethodNameGeneric
Generic type to define a JSON-RPC Method Name.
Examples
import { RpcSchema } from 'ox'
type type Name = RpcSchema.MethodName | (string & {})Name = RpcSchema.MethodNameGeneric
Source: src/RpcSchema.ts
RpcSchema.Wallet
Union of all JSON-RPC Methods for the wallet_
namespace.
Examples
import { RpcSchema } from 'ox'
type type Schema = {
Request: {
method: "eth_requestAccounts";
params?: undefined;
};
ReturnType: readonly Address[];
} | {
Request: {
method: "personal_sign";
params: [data: Hex, address: Address];
};
ReturnType: Hex;
} | ... 10 more ... | {
...;
}Schema = RpcSchema.Wallet