IPC Transport
A function to create an IPC Transport for a Client
The ipc
Transport connects to a JSON-RPC API via IPC (inter-process communication).
Import
import { ipc } from 'viem/node'
Usage
import { createPublicClient } from 'viem'
import { ipc } from 'viem/node'
import { mainnet } from 'viem/chains'
const client = createPublicClient({
chain: mainnet,
transport: ipc('/tmp/reth.ipc'),
})
Parameters
path
- Type:
string
IPC Path the transport should connect to.
const transport = ipc('/tmp/reth.ipc')
key (optional)
- Type:
string
- Default:
"ipc"
A key for the Transport.
const transport = ipc('/tmp/reth.ipc', {
key: 'reth-ipc',
})
name (optional)
- Type:
string
- Default:
"IPC JSON-RPC"
A name for the Transport
const transport = ipc('/tmp/reth.ipc', {
name: 'Reth IPC',
})
reconnect (optional)
- Type:
boolean | { maxAttempts?: number, delay?: number }
- Default:
true
Whether or not to attempt to reconnect on socket failure.
const transport = ipc('/tmp/reth.ipc', {
reconnect: false,
})
reconnect.attempts (optional)
- Type:
number
- Default:
5
The max number of times to attempt to reconnect.
const transport = ipc('/tmp/reth.ipc', {
reconnect: {
attempts: 10,
}
})
reconnect.delay (optional)
- Type:
number
- Default:
2_000
Retry delay (in ms) between reconnect attempts.
const transport = ipc('/tmp/reth.ipc', {
reconnect: {
delay: 1_000,
}
})
retryCount (optional)
- Type:
number
- Default:
3
The max number of times to retry when a request fails.
const transport = ipc('/tmp/reth.ipc', {
retryCount: 5,
})
retryDelay (optional)
- Type:
number
- Default:
150
The base delay (in ms) between retries. By default, the Transport will use exponential backoff (~~(1 << count) * retryDelay
), which means the time between retries is not constant.
const transport = ipc('/tmp/reth.ipc', {
retryDelay: 100,
})
timeout (optional)
- Type:
number
- Default:
10_000
The timeout for async IPC requests.
const transport = ipc('/tmp/reth.ipc', {
timeout: 60_000,
})