npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

decap-sdk

v1.2.0

Published

Decentralized CAPTCHA SDK for Web3 applications

Readme

DeCap SDK

Decentralized CAPTCHA for Web3 Applications

DeCap is a React component that provides intelligent CAPTCHA verification based on wallet reputation. It offers three verification modes: simple puzzles for basic bot protection, advanced verification with wallet signatures for high-security operations, and automatic mode selection based on user reputation.

Installation

npm install decap-sdk
# or
pnpm add decap-sdk
# or
yarn add decap-sdk

Usage

Simple Mode

Basic bot protection without wallet requirements:

import { DeCap } from 'decap-sdk';

function App() {
  return (
    <DeCap
      mode="simple"
      onSuccess={(proof) => console.log('Verified!', proof)}
      onFailure={() => console.log('Failed')}
    >
      <button>Protected Action</button>
    </DeCap>
  );
}

Props:

  • mode: "simple"
  • onSuccess: (proof: VerificationProof) => void
  • onFailure: () => void
  • children: React element to wrap
  • theme?: "light" | "dark" | "auto" (optional)

Advanced Mode

Enhanced security with cryptographic wallet signatures:

import { DeCap } from 'decap-sdk';

function SecureApp() {
  return (
    <DeCap
      mode="advanced"
      userWallet={wallet}
      onSuccess={(proof) => {
        console.log('Verified with signature:', proof.walletSignature);
        // Verify signature on your backend for maximum security
      }}
      onFailure={() => console.log('Verification failed')}
    >
      <button>High-Security Action</button>
    </DeCap>
  );
}

Props:

  • mode: "advanced"
  • userWallet: WalletConnection (required)
  • onSuccess: (proof: VerificationProof) => void
  • onFailure: () => void
  • children: React element to wrap
  • theme?: "light" | "dark" | "auto" (optional)

Auto Mode ⚠️ (Experimental)

Adaptive verification based on wallet reputation:

import { DeCap } from 'decap-sdk';

function SmartApp() {
  return (
    <DeCap
      mode="auto"
      userWallet={wallet}
      reputationScore={userReputation}
      onSuccess={(proof) => console.log('Smart verification:', proof)}
      onFailure={() => console.log('Failed')}
    >
      <button>Adaptive Action</button>
    </DeCap>
  );
}

Props:

  • mode: "auto"
  • userWallet: WalletConnection (required)
  • reputationScore?: number (0-100, optional)
  • onSuccess: (proof: VerificationProof) => void
  • onFailure: () => void
  • children: React element to wrap
  • theme?: "light" | "dark" | "auto" (optional)

⚠️ Auto Mode Status: Currently experimental. Reputation scoring is under active development and may not be fully reliable. Use simple or advanced modes for production applications.

Reputation Score Integration

DeCap provides powerful reputation scoring functions that you can use independently in your application for wallet analysis, risk assessment, and custom verification logic.

Basic Reputation Fetching

import { fetchReputationScore } from 'decap-sdk';

// Simple reputation fetch (uses fallback data if no API key)
const reputation = await fetchReputationScore('0x742d35Cc6634C0532925a3b8D');
console.log(reputation.score); // 0-100
console.log(reputation.trustLevel); // 'low' | 'medium' | 'high'
console.log(reputation.captchaMode); // 'advanced' | 'simple' | 'bypass'

// Production usage with Etherscan API
const reputation = await fetchReputationScore('0x742d35Cc6634C0532925a3b8D', {
  apiKey: process.env.ETHERSCAN_API_KEY
});

Advanced Reputation Functions

import { 
  fetchReputationScore,
  batchFetchWalletReputation,
  getCaptchaModeFromScore,
  getTrustLevelFromScore,
  calculateWalletReputation,
  clearCache
} from 'decap-sdk';

// Batch analyze multiple wallets
const wallets = ['0x123...', '0x456...', '0x789...'];
const reputations = await batchFetchWalletReputation(wallets, {
  apiKey: process.env.ETHERSCAN_API_KEY
});

// Direct score calculation with custom config
const score = await calculateWalletReputation('0x123...', {
  easyThreshold: 50,
  bypassThreshold: 80,
  weights: {
    transactionActivity: 0.3,
    contractInteractions: 0.25,
    walletAge: 0.2,
    tokenDiversity: 0.15,
    riskFlags: 0.1
  }
});

// Utility functions for score analysis
const trustLevel = getTrustLevelFromScore(75); // 'high'
const captchaMode = getCaptchaModeFromScore(45); // 'simple'

// Clear reputation cache when needed
clearCache();

React Hook Integration

import { useWalletReputation } from 'decap-sdk';

function WalletAnalyzer({ walletAddress }: { walletAddress: string }) {
  const {
    reputationData,
    isLoading,
    error,
    getRecommendedMode,
    fetchReputation,
    refreshReputation
  } = useWalletReputation({
    walletAddress,
    bypassThreshold: 70,
    easyThreshold: 40,
    autoFetch: true
  });

  if (isLoading) return <div>Analyzing wallet...</div>;
  if (error) return <div>Error: {error}</div>;
  if (!reputationData) return <div>No data</div>;

  return (
    <div>
      <h3>Wallet Reputation: {reputationData.score}/100</h3>
      <p>Trust Level: {reputationData.trustLevel}</p>
      <p>Recommended CAPTCHA: {getRecommendedMode() || 'None needed'}</p>
      <button onClick={refreshReputation}>Refresh</button>
    </div>
  );
}

State Management Integration

// With Zustand
import { create } from 'zustand';
import { fetchReputationScore, ReputationResult } from 'decap-sdk';

interface ReputationStore {
  reputations: Record<string, ReputationResult>;
  fetchReputation: (address: string) => Promise<void>;
}

const useReputationStore = create<ReputationStore>((set, get) => ({
  reputations: {},
  fetchReputation: async (address: string) => {
    const reputation = await fetchReputationScore(address, {
      apiKey: process.env.ETHERSCAN_API_KEY
    });
    set(state => ({
      reputations: { ...state.reputations, [address]: reputation }
    }));
  }
}));

// With Jotai
import { atom } from 'jotai';
import { fetchReputationScore } from 'decap-sdk';

const walletAddressAtom = atom<string>('');
const reputationAtom = atom(async (get) => {
  const address = get(walletAddressAtom);
  if (!address) return null;
  return await fetchReputationScore(address);
});

Custom Scoring Configuration

import { calculateWalletReputation, ReputationConfig } from 'decap-sdk';

const customConfig: ReputationConfig = {
  easyThreshold: 50,    // Simple CAPTCHA threshold
  bypassThreshold: 80,  // Skip CAPTCHA threshold
  weights: {
    transactionActivity: 0.35,     // Transaction count & volume
    contractInteractions: 0.25,    // Smart contract usage
    walletAge: 0.20,              // Account age
    tokenDiversity: 0.15,         // Token variety
    riskFlags: 0.05               // Risk indicators
  }
};

const score = await calculateWalletReputation(
  '0x742d35Cc6634C0532925a3b8D',
  customConfig,
  process.env.ETHERSCAN_API_KEY
);

Reputation Result Interface

interface ReputationResult {
  score: number;                              // 0-100 reputation score
  trustLevel: 'low' | 'medium' | 'high';    // Trust classification
  captchaMode: 'advanced' | 'simple' | 'bypass'; // Recommended CAPTCHA
  walletData: WalletData;                    // Detailed wallet analysis
  dataSource: 'etherscan' | 'mock' | 'fallback'; // Data source used
  timestamp: number;                         // When calculated
}

Configuration

Setup Configuration File

Create a decap.config.js file in your project root:

module.exports = {
  // Etherscan API Configuration
  etherscan: {
    // Get your free API key from https://etherscan.io/apis
    apiKey: process.env.ETHERSCAN_API_KEY || 'YourEtherscanApiKeyHere',
    network: 'mainnet',
    timeout: 10000
  },

  // Reputation Scoring Configuration (for auto mode)
  reputation: {
    thresholds: {
      bypass: 70,  // Skip verification entirely
      simple: 40,  // Simple puzzle only
      advanced: 0  // Puzzle + wallet signature
    },
    cache: {
      ttl: 300000,     // 5 minutes
      maxEntries: 1000
    }
  },

  // UI/UX Settings
  ui: {
    defaultTheme: 'auto',
    animations: { enabled: true, duration: 300 },
    modal: {
      closeOnOverlayClick: false,
      showCloseButton: true,
      autoCloseDelay: 2000
    }
  },

  // Development Settings
  development: {
    debug: process.env.NODE_ENV === 'development',
    useMockData: !process.env.ETHERSCAN_API_KEY
  }
};

Environment Variables

ETHERSCAN_API_KEY=your_api_key_here
NODE_ENV=development

Runtime Configuration

import { updateConfig } from 'decap-sdk';

// Update configuration at runtime
updateConfig({
  etherscan: { apiKey: 'new-api-key' },
  development: { debug: true }
});

Technology Stack

  • React - UI framework
  • TypeScript - Type safety and developer experience
  • CSS Variables - Dynamic theming system
  • Ethers.js - Ethereum wallet integration
  • Crypto API - Secure nonce generation
  • Portal Rendering - Modal overlay management
  • Flexbox/Grid - Responsive layout system

Contribute

Check out our repository to get started:

🚀 Contribute to DeCap SDK

  • Report bugs and request features
  • Submit pull requests
  • Improve documentation
  • Share feedback and ideas

License

MIT License - see LICENSE file for details.