Chain Contract Client
Chain Contract Client
Section titled “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.
ChainConfig Interface
Section titled “ChainConfig Interface”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.
Client Setup
Section titled “Client Setup”Create a client instance using the factory function:
const client = createChainContractClient(env);Requires CHAIN_CONTRACT service binding in environment, throws if missing.
Network Operations
Section titled “Network Operations”Getting Network Details
Section titled “Getting Network Details”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.
RPC Connection
Section titled “RPC Connection”Retrieve RPC URLs for direct blockchain connection:
const rpcUrl = await client.getRpcUrl(chainId);Returns cached RPC URL string through reliable endpoints.
Chain Configuration
Section titled “Chain Configuration”Get complete network settings for blockchain interactions:
const config = await client.getChainConfig(chainId);Returns ChainConfig with viem Chain object, cached 5 minutes.
Contract Operations
Section titled “Contract Operations”Contract by Address
Section titled “Contract by Address”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.
Contract by Name
Section titled “Contract by Name”Access contract functionality using readable contract names:
const contract = await client.getContractByName(chainId, name);Searches active deployments, returns first match with 5-minute cache.
Registry Access
Section titled “Registry Access”Connect to the main registry for document operations:
const registryAddress = await client.getRegistryAddress(chainId);Returns Address for IntegraRegistryV1 deployment, throws if not found.
Network Support
Section titled “Network Support”Confirm network availability before operations:
const isSupported = await client.isChainSupported(chainId);Returns boolean, checks isActive flag and RPC availability.