Skip to content

Chain Contract Client

The ChainContractClient provides cached access to chain configs, RPC URLs, contract ABIs, and registry addresses. It enables you to retrieve network settings and contract details across multiple blockchains with automatic caching for performance.

The ChainConfig interface defines blockchain connection parameters with built-in network settings. It contains chainId, name, displayName, rpcUrl, viemChain object, and optional block explorer URLs for standardized blockchain access.

Create a client instance using the factory function:

const client = createChainContractClient(env);

Requires CHAIN_CONTRACT service binding in environment, throws if missing.

Access blockchain network information including currency and explorer details:

const network = await client.getNetwork(chainId);

Returns NetworkResponse with 5-minute cache, throws on API errors.

Retrieve RPC URLs for direct blockchain connection:

const rpcUrl = await client.getRpcUrl(chainId);

Returns cached RPC URL string through reliable endpoints.

Get complete network settings for blockchain interactions:

const config = await client.getChainConfig(chainId);

Returns ChainConfig with viem Chain object, cached 5 minutes.

Retrieve verified contract interfaces using contract addresses:

const contract = await client.getContract(chainId, address);

Returns ContractResponse with ABI array, 1-minute cache, null if not found.

Access contract functionality using readable contract names:

const contract = await client.getContractByName(chainId, name);

Searches active deployments, returns first match with 5-minute cache.

Connect to the main registry for document operations:

const registryAddress = await client.getRegistryAddress(chainId);

Returns Address for IntegraRegistryV1 deployment, throws if not found.

Confirm network availability before operations:

const isSupported = await client.isChainSupported(chainId);

Returns boolean, checks isActive flag and RPC availability.