evm-callkit
v0.1.2
Published
RPC toolkit for EVM chains with cache, retry, and rotation.
Maintainers
Readme
evm-callkit
A minimal RPC toolkit for EVM-based chains (Ethereum, Base, etc.) with built-in features:
- ✅ LRU + Redis caching for
readContract,multicall - 🔁 Auto RPC rotation & retry with fallback
- 🧠 Debounce/coalesce requests to avoid duplication
- 🧰
readContractLive,multicallLivefor real-time calls - 📦 Simple to integrate in bots, indexers, monitoring tools
Install
npm install evm-callkitQuick Start
import { initCallkit, readContractWithCache } from 'evm-callkit';
initCallkit({
rpcUrls: [
'https://base.blockpi.network/v1/rpc/xxx',
'https://base.blockpi.network/v1/rpc/yyy',
],
ttl: 600, // 10 minutes
redisUrl: 'redis://localhost:6379',
logger: console, // Optional logger
});
const symbol = await readContractWithCache<string>({
address: '0x...',
abi: parseAbi(['function symbol() view returns (string)']),
functionName: 'symbol',
});API
Init
initCallkit({
rpcUrls: string[],
ttl?: number, // in seconds
maxRetry?: number,
redisUrl?: string,
logger?: Console | CustomLogger,
})readContractWithCache
Call eth_call with memory/redis cache and retry:
await readContractWithCache<string>({
address,
abi,
functionName,
args,
});readContractLive
Bypass cache and always call live:
await readContractLive<string>({
address,
abi,
functionName,
args,
});multicallWithCache
await multicallWithCache([...contracts], client?, options?);Supports cache, coalescing, redis.
multicallLive
await multicallLive([...contracts], rpcUrl?);Bypass all cache, use raw RPC.
Test
npm run testTo customize via .env:
REDIS_URL=redis://localhost:6379
CALLKIT_TTL=600
CALLKIT_MAX_RETRY=3
CALLKIT_DEBUG=1
CALLKIT_RPC_ENDPOINTS=https://mainnet.infura.io/v3/YOUR_INFURA_API_KEY,...License
MIT
Built by @hauchu1196 with ❤️
