/alchemy-pack:alchemy-rate-limitsfrom alchemy-pack
Implements Alchemy Compute Unit (CU) rate limiting and request throttling for blockchain queries. Handles 429 errors, optimizes CU usage, and manages concurrent requests within plan limits.
Ships in alchemy-pack. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Alchemy uses Compute Units (CU) to measure API usage. Different methods cost different CU amounts. Rate limits are per-second, and exceeding them returns 429 errors.
| Method | CU Cost | Category |
|---|---|---|
eth_blockNumber | 10 | Core |
eth_getBalance | 19 | Core |
eth_call | 26 | Core |
eth_getTransactionReceipt | 15 | Core |
getTokenBalances | 50 | Enhanced |
getTokenMetadata | 50 | Enhanced |
getAssetTransfers | 150 | Enhanced |
getNftsForOwner | 50 | NFT |
getNftMetadataBatch | 50 | NFT |
getContractMetadata | 50 | NFT |
| Plan | CU/sec | Monthly CU | Price |
|---|---|---|---|
| Free | 330 | 300M | $0 |
| Growth | 660 | 1.2B | $49/mo |
| Scale | Custom | Custom | Custom |
// src/alchemy/throttler.ts
import Bottleneck from 'bottleneck';
const CU_COSTS: Record<string, number> = {
'eth_blockNumber': 10,
'eth_getBalance': 19,
'eth_call': 26,
'getTokenBalances': 50,
'getAssetTransfers': 150,
'getNftsForOwner': 50,
};
// Free tier: 330 CU/sec = ~16 getBalance calls/sec
const limiter = new Bottleneck({
reservoir: 330, // CU budget per interval
reservoirRefreshInterval: 1000, // Refresh every second
reservoirRefreshAmount: 330, // Reset to max CU/sec
maxConcurrent: 10, // Max parallel requests
minTime: 50, // Min 50ms between requests
});
limiter.on('depleted', () => {
console.warn('CU budget depleted — queueing requests');
});
async function throttledAlchemyCall<T>(
method: string,
operation: () => Promise<T>,
): Promise<T> {
const cost = CU_COSTS[method] || 26; // Default to eth_call cost
return limiter.schedule({ weight: cost }, operation);
}
export { throttledAlchemyCall, limiter };
// src/alchemy/batch-optimizer.ts
import { Alchemy } from 'alchemy-sdk';
// Instead of N individual calls, batch when possible
async function batchGetBalances(
alchemy: Alchemy,
addresses: string[],
): Promise<Map<string, string>> {
const results = new Map<string, string>();
// Process in chunks to stay under rate limit
const CHUNK_SIZE = 10;
for (let i = 0; i < addresses.length; i += CHUNK_SIZE) {
const chunk = addresses.slice(i, i + CHUNK_SIZE);
const balances = await Promise.all(
chunk.map(addr => alchemy.core.getBalance(addr))
);
chunk.forEach((addr, idx) => {
results.set(addr, (parseInt(balances[idx].toString()) / 1e18).toFixed(6));
});
// Pause between chunks to stay under CU limit
if (i + CHUNK_SIZE < addresses.length) {
await new Promise(r => setTimeout(r, 200));
}
}
return results;
}
export { batchGetBalances };
// src/alchemy/retry.ts
async function withAlchemyRetry<T>(
operation: () => Promise<T>,
maxRetries: number = 5,
): Promise<T> {
for (let attempt = 1; attempt <= maxRetries; attempt++) {
try {
return await operation();
} catch (err: any) {
if (err.response?.status !== 429 || attempt === maxRetries) throw err;
const retryAfter = parseInt(err.response.headers?.['retry-after'] || '1');
const jitter = Math.random() * 500;
const delay = retryAfter * 1000 + jitter;
console.log(`Rate limited — retry ${attempt}/${maxRetries} in ${delay.toFixed(0)}ms`);
await new Promise(r => setTimeout(r, delay));
}
}
throw new Error('Unreachable');
}
For security best practices, see alchemy-security-basics.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub flight505/skill-forge --plugin alchemy-pack18 skills in this plugin
/alchemy-ci-integrationConfigure CI/CD pipeline for Alchemy-powered Web3 applications.
Use when setting up automated testing with Hardhat forks,
smart contract verification, or testnet deployment pipelines.
Trigger: "alchemy CI", "alchemy GitHub Actions", "web3 CI/CD pipeline".
/alchemy-common-errorsDiagnose and fix common Alchemy SDK and Web3 API errors.
Use when encountering rate limits, RPC failures, invalid parameters,
or blockchain query errors with the Alchemy SDK.
Trigger: "alchemy error", "alchemy not working", "alchemy 429",
"alchemy debug", "fix alchemy issue".
/alchemy-core-workflow-aBuild a complete wallet portfolio tracker using Alchemy Enhanced APIs.
Use when implementing token balance dashboards, NFT galleries,
transaction history views, or wallet analytics applications.
Trigger: "alchemy wallet tracker", "alchemy portfolio", "alchemy token dashboard",
"alchemy transaction history", "build dApp with alchemy".
/alchemy-core-workflow-bBuild NFT collection explorer and smart contract interaction with Alchemy.
Use when fetching NFT metadata, building galleries, reading contract state,
or implementing NFT marketplace features.
Trigger: "alchemy NFT", "alchemy smart contract", "alchemy collection",
"alchemy NFT metadata", "alchemy contract read".
/alchemy-cost-tuningOptimize Alchemy API costs through CU budgeting, caching, and plan selection.
Use when analyzing Alchemy billing, reducing Compute Unit consumption,
or choosing the right plan for your dApp traffic.
Trigger: "alchemy cost", "alchemy pricing", "alchemy CU budget",
"alchemy billing optimization", "alchemy free tier limits".
/alchemy-debug-bundleCollect Alchemy SDK debug evidence for troubleshooting and support tickets.
Use when encountering persistent issues, preparing support tickets,
or debugging blockchain query failures.
Trigger: "alchemy debug bundle", "alchemy support ticket", "alchemy diagnostics".
Other plugins' skills for the same job