Custom Transport
The custom Transport accepts an EIP-1193 Ethereum Provider (with at least a request attribute) as a parameter. This transport is useful for integrating with injected wallets, wallets that provide an EIP-1193 provider (eg. WalletConnect or Coinbase SDK), or even providing your own custom EIP-1193 request function.
Import
ts
import { custom } from 'viem'
Usage
ts
import { createWalletClient, custom } from 'viem'
const client = createWalletClient({ 
  transport: custom(window.ethereum)
})
Parameters
provider
- Type: 
custom 
An EIP-1193 or equivalent provider with at least an EIP-1193 request function.
ts
import { customRpc } from './rpc'
const transport = custom({
  async request({ method, params }) { 
    const response = await customRpc.request(method, params)
    return response
  }
})
key (optional)
- Type: 
string - Default: 
"custom" 
A key for the Transport.
ts
const transport = custom(
  window.ethereum,
  { 
    key: 'windowProvider', 
  }
)
name (optional)
- Type: 
string - Default: 
"Ethereum Provider" 
A name for the Transport
ts
const transport = custom(
  window.ethereum,
  { 
    name: 'Window Ethereum Provider', 
  }
)
Gotchas
- If you are pairing the 
customTransport with a Public Client, ensure that your provider supports Public Actions.