@define-kit/utilities
v0.1.1
Published
Reusable utilities for EVM infrastructure.
Maintainers
Readme
@define-kit/utilities
Utilities for RPC endpoint validation, health checks, and other common EVM infrastructure tasks.
Installation
npm install @define-kit/utilitiesRPC health checks
The package currently exports RpcHealthCheck for checking JSON-RPC endpoints.
import { RpcHealthCheck } from '@define-kit/utilities';
const checker = new RpcHealthCheck();
const result = await checker.check({
url: 'https://your-rpc.example',
expectedChainId: 1,
});The check:
- verifies
eth_chainIdagainstexpectedChainId; - calls
eth_blockNumberand measures latency; - checks whether
eth_callappears to be available.
isSuccess reflects the chain ID and block-number checks. supportsEthCall is reported separately.
interface RpcHealthCheckResult {
latencyMs: number;
isSuccess: boolean;
supportsEthCall?: boolean;
error: string;
}Metadata
Use checkWithMeta to attach caller-owned metadata to a result:
const result = await checker.checkWithMeta({
url: 'https://your-rpc.example',
expectedChainId: 1,
meta: { rpcId: 'primary-mainnet' },
});Batch checks
Use checkMany to check multiple endpoints with a concurrency limit. Results preserve input order.
const results = await checker.checkMany(inputs, {
concurrency: 5,
});The default Axios client uses a six-second timeout. A custom Axios instance can be passed to the constructor.
The package does not persist health state, manage cooldowns, disable endpoints, select providers, or schedule checks.
Development
From the repository root:
yarn nx build utilities
yarn nx test utilities
yarn nx typecheck utilities
yarn nx lint utilitiesLicense
MIT
