OverviewFilesCommitsIssuesDocsReleasesPeers

hypercore-kb / tetherto-kb / pattern-map.json

194 lines · json ref:
{
  "_meta": {
    "description": "Implementation pattern mappings for the Tether WDK ecosystem",
    "documentation": {
      "useCases": "See use-case-map.json for when to use each pattern",
      "skills": "See skills/ directory for pattern code examples",
      "concepts": "See README.md for pattern integration and relationships"
    },
    "patternCount": 12,
    "patterns": [
      "hd-wallet",
      "multi-chain",
      "protocol-registry",
      "lightning-invoice",
      "stablecoin-support",
      "cross-chain-transfer",
      "account-abstraction",
      "pear-integration",
      "defi-composition",
      "bip84-segwit",
      "bare-worklet",
      "mobile-integration"
    ],
    "lastUpdated": "2026-01-23",
    "phase": "Phase 1 - Initial Pattern Mapping"
  },
  "patterns": {
    "hd-wallet": {
      "description": "Hierarchical Deterministic wallet - single seed phrase generates all keys",
      "implementedBy": [
        "wdk-core",
        "wdk-wallet"
      ],
      "usedBy": [
        "wdk-wallet-btc",
        "wdk-wallet-evm",
        "wdk-wallet-spark",
        "wdk-wallet-ton",
        "wdk-wallet-tron",
        "wdk-wallet-solana"
      ],
      "whenToUse": "Need deterministic key derivation from mnemonic seed",
      "alternatives": [],
      "standards": ["BIP-39", "BIP-44", "BIP-84"],
      "codeExample": "const wdk = new WDK(seedPhrase); const account = await wdk.getAccount('ethereum', 0);"
    },
    "multi-chain": {
      "description": "Single wallet interface supporting multiple blockchains",
      "implementedBy": [
        "wdk-core"
      ],
      "usedBy": [
        "wdk-wallet-btc",
        "wdk-wallet-evm",
        "wdk-wallet-spark"
      ],
      "whenToUse": "Need to support multiple blockchains from one codebase",
      "alternatives": [],
      "codeExample": "wdk.registerWallet('ethereum', WalletManagerEvm).registerWallet('bitcoin', WalletManagerBtc)"
    },
    "protocol-registry": {
      "description": "Register DeFi protocols (swap, lending, bridge) to wallet accounts",
      "implementedBy": [
        "wdk-core"
      ],
      "usedBy": [
        "wdk-protocol-swap-velora-evm",
        "wdk-protocol-lending-aave-evm",
        "wdk-protocol-bridge-usdt0-evm"
      ],
      "whenToUse": "Need to add DeFi functionality to wallet",
      "alternatives": [],
      "codeExample": "wdk.registerProtocol('swap', ProtocolSwapVelora); account.getSwapProtocol('velora')"
    },
    "lightning-invoice": {
      "description": "Create and pay Lightning Network invoices for instant payments",
      "implementedBy": [
        "wdk-wallet-spark"
      ],
      "usedBy": [],
      "whenToUse": "Need instant, low-fee Bitcoin-like payments",
      "alternatives": [],
      "notes": "Spark blockchain only, not traditional Bitcoin Lightning",
      "codeExample": "await account.createLightningInvoice({amount, memo})"
    },
    "stablecoin-support": {
      "description": "Native support for USDT and other stablecoins across chains",
      "implementedBy": [
        "wdk-wallet-evm",
        "wdk-wallet-ton",
        "wdk-wallet-tron"
      ],
      "usedBy": [
        "wdk-protocol-bridge-usdt0-evm"
      ],
      "whenToUse": "Need stable value cryptocurrency (avoid volatility)",
      "alternatives": [],
      "tokens": ["USDT", "USDC", "DAI"],
      "codeExample": "await account.sendTransaction({to, value, token: 'USDT'})"
    },
    "cross-chain-transfer": {
      "description": "Move assets between different blockchains via bridges",
      "implementedBy": [
        "wdk-protocol-bridge-usdt0-evm",
        "wdk-protocol-bridge-usdt0-ton"
      ],
      "usedBy": [],
      "whenToUse": "Need to transfer USDT between chains (e.g., Ethereum → TON)",
      "alternatives": [],
      "codeExample": "await account.getBridgeProtocol('usdt0').bridge({from: 'ethereum', to: 'ton', amount})"
    },
    "account-abstraction": {
      "description": "ERC-4337 smart contract wallets with gasless transactions",
      "implementedBy": [
        "wdk-wallet-evm-erc-4337"
      ],
      "usedBy": [],
      "whenToUse": "Need sponsored gas fees or advanced wallet features",
      "alternatives": [],
      "standards": ["ERC-4337"],
      "features": ["gasless-tx", "session-keys", "social-recovery"],
      "codeExample": "wdk.registerWallet('ethereum', WalletManagerEvmErc4337, {paymaster})"
    },
    "pear-integration": {
      "description": "Run WDK in Pear P2P applications using Bare runtime",
      "implementedBy": [
        "pear-wrk-wdk"
      ],
      "usedBy": [],
      "whenToUse": "Building P2P desktop applications with crypto payments",
      "alternatives": [],
      "runtime": "Bare",
      "codeExample": "const { WDKManager } = require('@tetherto/pear-wrk-wdk'); const wdk = new WDKManager({runtime: 'bare'})"
    },
    "defi-composition": {
      "description": "Compose multiple DeFi protocols (swap + lending + bridge)",
      "implementedBy": [
        "wdk-core"
      ],
      "usedBy": [
        "wdk-protocol-swap-velora-evm",
        "wdk-protocol-lending-aave-evm"
      ],
      "whenToUse": "Need complex DeFi workflows (e.g., swap then lend)",
      "alternatives": [],
      "codeExample": "await account.getSwapProtocol('velora').swap(); await account.getLendingProtocol('aave').deposit()"
    },
    "bip84-segwit": {
      "description": "Bitcoin BIP-84 native SegWit (bech32) address generation",
      "implementedBy": [
        "wdk-wallet-btc"
      ],
      "usedBy": [],
      "whenToUse": "Need modern Bitcoin addresses with lower fees",
      "alternatives": ["BIP-44 (legacy)", "BIP-49 (nested SegWit)"],
      "standards": ["BIP-84"],
      "addressFormat": "bc1...",
      "codeExample": "const address = await btcAccount.getAddress(); // Returns bc1..."
    },
    "bare-worklet": {
      "description": "Cryptographic operations run in isolated Bare worklet context",
      "implementedBy": [
        "pear-wrk-wdk"
      ],
      "usedBy": [],
      "whenToUse": "Need secure key isolation in Pear apps",
      "alternatives": [],
      "security": "Keys never leave worklet context",
      "codeExample": "// Automatic in pear-wrk-wdk - worklets handle all crypto ops"
    },
    "mobile-integration": {
      "description": "React Native integration with WDK for mobile wallets",
      "implementedBy": [
        "wdk-starter-react-native"
      ],
      "usedBy": [],
      "whenToUse": "Building iOS/Android wallet apps",
      "alternatives": [],
      "platforms": ["iOS", "Android"],
      "codeExample": "// See wdk-starter-react-native for complete template"
    },
    "instant-settlement": {
      "description": "Instant transaction finality without block confirmations",
      "implementedBy": [
        "wdk-wallet-spark"
      ],
      "usedBy": [],
      "whenToUse": "Need immediate payment confirmation (e.g., point-of-sale)",
      "alternatives": ["On-chain Bitcoin (10-60 min)", "Ethereum (12 sec blocks)"],
      "codeExample": "const result = await sparkAccount.payInvoice({invoice}); // Instant confirmation"
    }
  }
}