Skip to main content
Version: 1.14.0

Type Alias: ChainContext

ChainContext = WithLogger & { abort?: AbortSignal; apiClient?: CCIPAPIClient | string | null; apiRetryConfig?: ApiRetryConfig; fetch?: typeof fetch; verificationsIndexer?: readonly string[]; verifierTransport?: VerifierTransport; } & WithCantonConfig

Defined in: chain.ts:136

Context for Chain class initialization. Extends WithLogger with optional API client configuration.

Type Declaration​

abort?​

optional abort?: AbortSignal

Abort signal for cancelling in-flight requests and watch loops on this chain. When the signal fires, the provider is destroyed and all active getLogs watch loops exit.

apiClient?​

optional apiClient?: CCIPAPIClient | string | null

CCIP API client instance for lane information queries.

  • undefined (default): Creates CCIPAPIClient with DEFAULT_API_BASE_URL
  • string: Creates CCIPAPIClient with provided URL
  • CCIPAPIClient: Uses provided instance (allows custom URL, fetch, etc.)
  • null: Disables API client entirely (getLaneLatency() will throw)

Default: undefined (auto-create with production endpoint)

apiRetryConfig?​

optional apiRetryConfig?: ApiRetryConfig

Retry configuration for API fallback operations. Controls exponential backoff behavior for transient errors. Default: DEFAULT_API_RETRY_CONFIG

fetch?​

optional fetch?: typeof fetch

Custom fetch implementation. When provided, it is used verbatim for all HTTP requests on this chain and the built-in rate-limit/retry wrapper is NOT applied. When omitted, a default per-endpoint rate-limited fetch (with adaptive throttle, 429/Retry-After handling and retries) is installed automatically.

verificationsIndexer?​

optional verificationsIndexer?: readonly string[]

Default CCIP v2 indexer base URLs for getVerifications (commit / CCV verifier lookups), overriding the built-in public per-network defaults (MAINNET_INDEXER_URLS / TESTNET_INDEXER_URLS). A per-call indexer option still wins over this.

Default: undefined (use the built-in public indexers for the chain's network)

verifierTransport?​

optional verifierTransport?: VerifierTransport

Transport for reading CCV attestations directly from the verifier endpoints passed as verifiers to Chain.getVerifications / Chain.execute. The SDK owns the verifier schema and when to call it; the transport only moves one call's bytes. Inject one to reach endpoints the default can't, e.g. a native gRPC client for grpc:// URLs.

Default: undefined (use grpcWebTransport: grpc-web over fetch, for http(s):// endpoints served by a grpc-web proxy)

Examples​

Default behavior (auto-create API client)

TypeScript
const chain = await EVMChain.fromUrl(rpcUrl, { logger })
await chain.getLaneLatency(destSelector) // Works - uses production API

Custom API endpoint

TypeScript
const api = CCIPAPIClient.fromUrl('https://staging-api.example.com', { logger })
const chain = await EVMChain.fromUrl(rpcUrl, { apiClient: api, logger })

Explicit opt-out (decentralized mode)

TypeScript
const chain = await EVMChain.fromUrl(rpcUrl, { apiClient: null, logger })
await chain.getLaneLatency(destSelector) // Throws CCIPApiClientNotAvailableError