Skip to content
Skillv1.0.0

quicknode-sdk-patterns

Production-ready QuickNode SDK and ethers.js patterns for blockchain applications. Use when building production dApps, implementing retry logic, or establishing patterns. Trigger with phrases like "qu

by jeremylongshore(0) 0 installs
Free
Sign in to install

Free account. Installing gives you the manifest plus copy-paste snippets.

See reviews

About

Imported from jeremylongshore/tons-of-skills-marketplace (plugins/saas-packs/quicknode-pack/skills/quicknode-sdk-patterns/SKILL.md). Install upstream with npx skills add jeremylongshore/tons-of-skills-marketplace --skill quicknode-sdk-patterns. Copyright stays with the author (MIT).

QuickNode SDK Patterns

Overview

Production-ready patterns for blockchain development with QuickNode: provider singletons, retry logic, batch RPC calls, and multi-chain support.

Prerequisites

  • Completed quicknode-install-auth
  • ethers.js or @quicknode/sdk installed

Instructions

Step 1: Provider Singleton

import { ethers } from 'ethers';

let _provider: ethers.JsonRpcProvider | null = null;

export function getProvider(): ethers.JsonRpcProvider {
  if (!_provider) {
    _provider = new ethers.JsonRpcProvider(process.env.QUICKNODE_ENDPOINT, undefined, {
      staticNetwork: true,  // Skip chainId lookup on every call
      batchMaxCount: 10,    // Enable batch RPC
    });
  }
  return _provider;
}

Step 2: Retry Wrapper with Backoff

async function withRetry<T>(fn: () => Promise<T>, maxRetries = 3): Promise<T> {
  for (let attempt = 0; attempt <= maxRetries; attempt++) {
    try {
      return await fn();
    } catch (err: any) {
      const isRetryable = err.code === 'SERVER_ERROR' || err.code === 'TIMEOUT' || err.status === 429;
      if (!isRetryable || attempt === maxRetries) throw err;
      const delay = Math.min(1000 * Math.pow(2, attempt), 10000);
      await new Promise(r => setTimeout(r, delay));
    }
  }
  throw new Error('Unreachable');
}

// Usage
const balance = await withRetry(() => getProvider().getBalance(address));

Step 3: Multi-Chain Client Factory

const ENDPOINTS: Record<string, string> = {
  ethereum: process.env.QUICKNODE_ETH_ENDPOINT!,
  polygon: process.env.QUICKNODE_POLYGON_ENDPOINT!,
  arbitrum: process.env.QUICKNODE_ARB_ENDPOINT!,
};

const providers = new Map<string, ethers.JsonRpcProvider>();

export function getChainProvider(chain: string): ethers.JsonRpcProvider {
  if (!providers.has(chain)) {
    const url = ENDPOINTS[chain];
    if (!url) throw new Error(`No endpoint for chain: ${chain}`);
    providers.set(chain, new ethers.JsonRpcProvider(url, undefined, { staticNetwork: true }));
  }
  return providers.get(chain)!;
}

Step 4: Batch RPC Calls

async function batchGetBalances(addresses: string[]): Promise<Map<string, bigint>> {
  const provider = getProvider();
  const results = new Map<string, bigint>();

  // ethers.js batches these automatically when batchMaxCount > 1
  const promises = addresses.map(async (addr) => {
    const balance = await provider.getBalance(addr);
    results.set(addr, balance);
  });

  await Promise.all(promises);
  return results;
}

Step 5: Contract Wrapper with Caching

import { LRUCache } from 'lru-cache';

const contractCache = new LRUCache<string, any>({ max: 100, ttl: 60000 });

async function cachedContractCall(contract: ethers.Contract, method: string, ...args: any[]) {
  const key = `${contract.target}:${method}:${JSON.stringify(args)}`;
  const cached = contractCache.get(key);
  if (cached) return cached;

  const result = await contractmethod;
  contractCache.set(key, result);
  return result;
}

Output

  • Thread-safe provider singleton with batch support
  • Retry logic for transient RPC failures
  • Multi-chain client factory
  • Cached contract calls reducing RPC usage

Error Handling

Pattern Use Case Benefit
Singleton All RPC calls One connection, reused
Retry wrapper Transient failures Automatic recovery
Multi-chain factory Cross-chain dApps Clean chain switching
Contract cache Repeated reads Fewer RPC calls

Resources

Next Steps

Build transaction workflows: quicknode-core-workflow-a

Use it

Copy one of these into your project. Installing also returns the manifest and these snippets.

yaml
targets:
  - https://api.opensmartroute.ai/api/v1/registry/jeremylongshore-tons-of-skills-marketplace-quicknode-sdk-5d4668/manifest   # or paste the manifest below

Manifest

An Open Capability Manifest: the router reads it to know what this does, what it costs and when to pick it.

jeremylongshore-tons-of-skills-marketplace-quicknode-sdk-5d4668.ocm.jsonjson
{
  "ocm": "1",
  "id": "jeremylongshore-tons-of-skills-marketplace-quicknode-sdk-5d4668",
  "kind": "skill",
  "name": "quicknode-sdk-patterns",
  "description": "Production-ready QuickNode SDK and ethers.js patterns for blockchain applications. Use when building production dApps, implementing retry logic, or establishing patterns. Trigger with phrases like \"quicknode patterns\", \"ethers best practices\", \"web3 patterns\".",
  "publisher": "jeremylongshore",
  "version": "1.0.0",
  "capabilities": {
    "domains": [
      "general"
    ],
    "tags": [
      "skill-md",
      "saas",
      "quicknode",
      "blockchain",
      "web3",
      "patterns",
      "skills-sh"
    ],
    "languages": [
      "en"
    ]
  },
  "quality_prior": 0.6,
  "examples": [
    "Production-ready QuickNode SDK and ethers.js patterns for blockchain applications. Use when building production dApps, implementing retry logic, or establishing patterns. Trigger with phrases like \"quicknode patterns\", \"ethers best practices\", \"web3 patterns\"."
  ],
  "primary": false,
  "metadata": {
    "source": {
      "provider": "skills.sh",
      "repository": "https://github.com/jeremylongshore/tons-of-skills-marketplace",
      "path": "plugins/saas-packs/quicknode-pack/skills/quicknode-sdk-patterns/SKILL.md",
      "ref": "HEAD",
      "url": "https://github.com/jeremylongshore/tons-of-skills-marketplace/blob/HEAD/plugins/saas-packs/quicknode-pack/skills/quicknode-sdk-patterns/SKILL.md",
      "key": "jeremylongshore/tons-of-skills-marketplace/plugins/saas-packs/quicknode-pack/skills/quicknode-sdk-patterns/SKILL.md"
    },
    "compatibility": "Designed for Claude Code",
    "allowed_tools": [
      "Read,",
      "Write,",
      "Edit"
    ],
    "license": "MIT"
  },
  "instructions": "# QuickNode SDK Patterns\n\n## Overview\n\nProduction-ready patterns for blockchain development with QuickNode: provider singletons, retry logic, batch RPC calls, and multi-chain support.\n\n## Prerequisites\n\n- Completed `quicknode-install-auth`\n- ethers.js or @quicknode/sdk installed\n\n## Instructions\n\n### Step 1: Provider Singleton\n\n```typescript\nimport { ethers } from 'ethers';\n\nlet _provider: ethers.JsonRpcProvider | null = null;\n\nexport function getProvider(): ethers.JsonRpcProvider {\n  if (!_provider) {\n    _provider = new ethers.JsonRpcProvider(process.env.QUICKNODE_ENDPOINT, undefined, {\n    ",
  "cost": {
    "context_tokens": 943
  }
}

Fetch it by URL: GET /api/v1/registry/jeremylongshore-tons-of-skills-marketplace-quicknode-sdk-5d4668/manifest?version=1.0.0

Reviews

Star ratings from people who tried it. One review per account; edit yours any time.

No reviews yet. Install it, try it, and be the first to rate it.