pitfalls-blockchainlisted
Install: claude install-skill aiskillstore/marketplace
# Blockchain Pitfalls
Common pitfalls and correct patterns for blockchain interactions.
## When to Use
- Making contract calls via RPC
- Estimating gas for transactions
- Handling reverts and errors
- Managing nonces for concurrent txs
- Configuring multi-chain support
- Reviewing blockchain code
## Workflow
### Step 1: Verify Error Handling
Check all contract calls are wrapped in try/catch.
### Step 2: Check Gas Estimation
Ensure gas is estimated with buffer before sending.
### Step 3: Verify Multicall Safety
Confirm multicall uses allowFailure: true.
---
## RPC Error Handling
```typescript
// ✅ 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 === 'suc