Skip to content

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_foo
abe_bar
eth_accounts
eth_blobBaseFee
eth_blockNumber
eth_call
eth_chainId
eth_coinbase
eth_estimateGas
eth_feeHistory
eth_gasPrice
eth_getBalance
eth_getBlockByHash
eth_getBlockByNumber
eth_getBlockTransactionCountByHash
eth_getBlockTransactionCountByNumber
eth_getCode
eth_getFilterChanges
eth_getFilterLogs
eth_getLogs
eth_getProof
eth_getStorageAt
eth_getTransactionByBlockHashAndIndex
eth_getTransactionByBlockNumberAndIndex
eth_getTransactionByHash
eth_getTransactionCount
eth_getTransactionReceipt
eth_getUncleCountByBlockHash
eth_getUncleCountByBlockNumber
eth_maxPriorityFeePerGas
eth_newBlockFilter
eth_newFilter
eth_newPendingTransactionFilter
eth_protocolVersion
eth_requestAccounts
eth_sendRawTransaction
eth_sendTransaction
eth_signTransaction
eth_signTypedData_v4
eth_uninstallFilter
personal_sign
wallet_addEthereumChain
wallet_getCallsStatus
wallet_getCapabilities
wallet_getPermissions
wallet_grantPermissions
wallet_requestPermissions
wallet_revokePermissions
wallet_sendCalls
wallet_showCallsStatus
wallet_switchEthereumChain
wallet_watchAsset
e' })

Definition

function from<schema>(): schema

Source: src/core/RpcSchema.ts

Return Type

schema