Skip to content
LogoLogo

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 {  } from 'viem/node'

Usage

import {  } from 'viem'
import {  } from 'viem/node'
import {  } from 'viem/chains'
 
const  = ({
  : , 
  : ('/tmp/reth.ipc'), 
})

Parameters

path

  • Type: string

IPC Path the transport should connect to.

const  = ('/tmp/reth.ipc')

key (optional)

  • Type: string
  • Default: "ipc"

A key for the Transport.

const  = ('/tmp/reth.ipc', { 
  : 'reth-ipc',  
})

methods (optional)

  • Type: { include?: string[], exclude?: string[] }

Methods to include or exclude from sending RPC requests.

const  = ('/tmp/reth.ipc', {
  : {
    : ['eth_sendTransaction', 'eth_signTypedData_v4'],
  },
})

name (optional)

  • Type: string
  • Default: "IPC JSON-RPC"

A name for the Transport

const  = ('/tmp/reth.ipc', { 
  : 'Reth IPC',  
})

reconnect (optional)

  • Type: boolean | { maxAttempts?: number, delay?: number }
  • Default: true

Whether or not to attempt to reconnect on socket failure.

const  = ('/tmp/reth.ipc', {
  : false, 
})

reconnect.attempts (optional)

  • Type: number
  • Default: 5

The max number of times to attempt to reconnect.

const  = ('/tmp/reth.ipc', {
  : {
    : 10, 
  }
})

reconnect.delay (optional)

  • Type: number
  • Default: 2_000

Retry delay (in ms) between reconnect attempts.

const  = ('/tmp/reth.ipc', {
  : {
    : 1_000, 
  }
})

retryCount (optional)

  • Type: number
  • Default: 3

The max number of times to retry when a request fails.

const  = ('/tmp/reth.ipc', {
  : 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  = ('/tmp/reth.ipc', {
  : 100, 
})

timeout (optional)

  • Type: number
  • Default: 10_000

The timeout for async IPC requests.

const  = ('/tmp/reth.ipc', {
  : 60_000, 
})