skills/barissozen/pitfalls-blockchain/SKILL.md
Blockchain RPC error handling, gas estimation, multi-chain config, and transaction management. Use when interacting with smart contracts, estimating gas, or managing transactions. Triggers on: RPC, contract call, gas, multicall, nonce, transaction, revert.
npx skillsauth add aiskillstore/marketplace pitfalls-blockchainInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Common pitfalls and correct patterns for blockchain interactions.
Check all contract calls are wrapped in try/catch.
Ensure gas is estimated with buffer before sending.
Confirm multicall uses allowFailure: true.
// ✅ Wrap ALL contract calls
async function getQuote(tokenIn: Address, tokenOut: Address) {
try {
const quote = await quoter.quoteExactInput(...);
return quote;
} catch (error) {
// Low-liquidity tokens WILL fail - this is expected
console.warn(`Quote failed for ${tokenIn}->${tokenOut}:`, error.message);
return null; // Continue processing other tokens
}
}
// ✅ Validate before calling contracts
if (!isAddress(tokenAddress)) {
throw new Error('Invalid token address');
}
// ✅ Handle "execution reverted" gracefully
if (error.message.includes('execution reverted')) {
// Pool doesn't exist or insufficient liquidity
return null;
}
// ✅ Multicall with individual error handling
const results = await multicall({
contracts: tokens.map(t => ({ ... })),
allowFailure: true, // CRITICAL
});
results.forEach((result, i) => {
if (result.status === 'success') {
// Use result.result
} else {
// Log and skip this token
}
});
// ✅ Always estimate gas before sending
const gasEstimate = await contract.estimateGas.swap(...args);
// ✅ Add 10-20% buffer to gas estimates
const gasLimit = gasEstimate.mul(120).div(100); // 20% buffer
// ✅ EIP-1559 gas pricing
const feeData = await provider.getFeeData();
const tx = {
maxFeePerGas: feeData.maxFeePerGas,
maxPriorityFeePerGas: feeData.maxPriorityFeePerGas,
gasLimit,
};
// ✅ Simulate before execution
try {
await contract.callStatic.swap(...args); // Dry run
const tx = await contract.swap(...args); // Real execution
} catch (e) {
// Would revert - don't send
}
// ✅ Handle gas price spikes
if (feeData.maxFeePerGas > MAX_ACCEPTABLE_GAS) {
throw new Error('Gas too high, waiting...');
}
// ✅ Chain-specific configuration
const CHAIN_CONFIG: Record<ChainId, ChainConfig> = {
ethereum: {
chainId: 1,
rpcUrl: process.env.ETHEREUM_RPC_URL,
blockTime: 12,
confirmations: 2,
nativeToken: 'ETH',
},
polygon: {
chainId: 137,
rpcUrl: process.env.POLYGON_RPC_URL,
blockTime: 2,
confirmations: 5, // More confirmations for faster chains
nativeToken: 'MATIC',
},
};
// ✅ Wait for confirmations
const receipt = await tx.wait(2); // 2 confirmations
// ✅ Nonce management
class NonceManager {
private pending = new Map<Address, number>();
async getNextNonce(address: Address, provider: Provider): Promise<number> {
const onChain = await provider.getTransactionCount(address, 'pending');
const local = this.pending.get(address) ?? onChain;
const next = Math.max(onChain, local);
this.pending.set(address, next + 1);
return next;
}
}
// ✅ Exponential backoff
async function fetchWithRetry<T>(fn: () => Promise<T>, maxRetries = 3): Promise<T> {
for (let attempt = 0; attempt < maxRetries; attempt++) {
try {
return await fn();
} catch (error) {
if (error.status === 429) { // Rate limited
const delay = Math.pow(2, attempt) * 1000;
await sleep(delay);
continue;
}
throw error;
}
}
throw new Error('Max retries exceeded');
}
// ✅ Fallback RPC endpoints
const RPC_ENDPOINTS = [
'https://eth-mainnet.alchemyapi.io/v2/KEY',
'https://mainnet.infura.io/v3/KEY',
'https://rpc.ankr.com/eth',
];
allowFailure: truedevelopment
Apple Human Interface Guidelines for content display components. Use this skill when the user asks about charts component, collection view, image view, web view, color well, image well, activity view, lockup, data visualization, content display, displaying images, rendering web content, color pickers, or presenting collections of items in Apple apps. Also use when the user says how should I display charts, what's the best way to show images, should I use a web view, how do I build a grid of items, what component shows media, or how do I present a share sheet. Cross-references: hig-foundations for color/typography/accessibility, hig-patterns for data visualization patterns, hig-components-layout for structural containers, hig-platforms for platform-specific component behavior.
tools
Automate HelpDesk tasks via Rube MCP (Composio): list tickets, manage views, use canned responses, and configure custom fields. Always search tools first for current schemas.
testing
Expert Haskell engineer specializing in advanced type systems, pure functional design, and high-reliability software. Use PROACTIVELY for type-level programming, concurrency, and architecture guidance.
tools
GraphQL gives clients exactly the data they need - no more, no less. One endpoint, typed schema, introspection. But the flexibility that makes it powerful also makes it dangerous. Without proper controls, clients can craft queries that bring down your server. This skill covers schema design, resolvers, DataLoader for N+1 prevention, federation for microservices, and client integration with Apollo/urql. Key insight: GraphQL is a contract. The schema is the API documentation. Design it carefully.