RpcSchema.from
Instantiates a statically typed Schema. This is a runtime-noop function, and is purposed to be used as a type-level tag to be used with Provider.from
or RpcTransport.fromHttp
.
Imports
Named
import { RpcSchema } from 'ox'
Examples
Using with Provider.from
import 'ox/window'
import { Provider, RpcSchema } from 'ox'
const schema = RpcSchema.from<
| RpcSchema.Default
| {
Request: {
method: 'abe_foo',
params: [id: number],
}
ReturnType: string
}
| {
Request: {
method: 'abe_bar',
params: [id: string],
}
ReturnType: string
}
>()
const provider = Provider.from(window.ethereum, { schema })
const blockNumber = await provider.request({ method: 'abe_fooabe_bareth_accountseth_blobBaseFeeeth_blockNumbereth_calleth_chainIdeth_coinbaseeth_estimateGaseth_feeHistoryeth_gasPriceeth_getBalanceeth_getBlockByHasheth_getBlockByNumbereth_getBlockTransactionCountByHasheth_getBlockTransactionCountByNumbereth_getCodeeth_getFilterChangeseth_getFilterLogseth_getLogseth_getProofeth_getStorageAteth_getTransactionByBlockHashAndIndexeth_getTransactionByBlockNumberAndIndexeth_getTransactionByHasheth_getTransactionCounteth_getTransactionReceipteth_getUncleCountByBlockHasheth_getUncleCountByBlockNumbereth_maxPriorityFeePerGaseth_newBlockFiltereth_newFiltereth_newPendingTransactionFiltereth_protocolVersioneth_requestAccountseth_sendRawTransactioneth_sendTransactioneth_signTransactioneth_signTypedData_v4eth_uninstallFilterpersonal_signwallet_addEthereumChainwallet_getCallsStatuswallet_getCapabilitieswallet_getPermissionswallet_grantPermissionswallet_requestPermissionswallet_revokePermissionswallet_sendCallswallet_showCallsStatuswallet_switchEthereumChainwallet_watchAssete' })
Definition
function from<schema>(): schema
Source: src/core/RpcSchema.ts
Return Type
schema