Documentation

ZapChain is a client-side automation plugin for Web3.js v4 that enables programmable logic without external servers or private key custody.

🚀 v2.0.0 Released: Native ETH transfers, EIP-712 signing, WebSocket support, and more!See what's new →

Introduction

Building automated dApp features usually involves complex infrastructure: indexer nodes, backend cron jobs, and centralized hot wallets. ZapChain eliminates this complexity by moving the automation logic directly into the user's browser (or your localized Node.js script).

Core Philosophy: "If it happens on-chain, your client should be able to react to it automatically."

Architecture Reference

The plugin operates as a background service attached to your Web3 instance. It periodically queries the blockchain for state changes (balances, events, gas prices) and evaluates them against user-defined "Rules".

The Execution Loop

  1. Monitor: Plugin polls chain state at fixed intervals (default 12s) or uses WebSocket for real-time updates (v2.0).
  2. Initial Check: [v2.0] Conditions are evaluated immediately at startup, not just on changes.
  3. Evaluation: Checks active rules against the current block data.
  4. Safety Check: Runs an internal eth_call simulation to verify success. [v2.0: Smart EOA detection]
  5. Authorization: If simulation passes, signatures are used/requested via EIP-712 typed signing [v2.0].
  6. Execution: Transaction is broadcasted to the network.

Use Cases

💸 DeFi Automation

  • Auto-compound yield when reward > $50.
  • Limit orders: Swap ETH to USDC if ETH > $3000.
  • Stop-loss: Exit position if price drops 10%.
  • [v2.0] Auto-sweep to cold wallet with native_transfer.

🛡️ Security & Monitoring

  • Auto-revoke approvals if a protocol is hacked.
  • Move funds to cold storage if wallet idle > 30 days.
  • Listen for specific NFT mints and auto-buy.
  • [v2.0] Real-time liquidation protection with WebSocket.

Key Features

  • Periodic Monitoring: Robust polling mechanism that works with any HTTP provider.
  • WebSocket Support: [v2.0] Subscribe to newHeads for sub-second reactivity.
  • Zero-Custody: Keys stay with the provider; ZapChain only orchestrates the logic.
  • Safety Guard: Internal simulation checks before every transaction to prevent reverts.
  • Native Transfers: [v2.0] Send ETH/MATIC directly without contract ABIs.
  • EIP-712 Signing: [v2.0] Human-readable rule authorization in wallet popups.
  • Verbose Logging: [v2.0] Clear status and skip reasons for every execution.
  • Native Integration: Extends web3.zapChain directly.