Skip to content

feat(chain-watcher): implement Base chain watcher for USDC transfers#59

Merged
geminimir merged 2 commits intogeminimir:mainfrom
coryli:feature/base-chain-watcher-usdc-transfers
Mar 15, 2026
Merged

feat(chain-watcher): implement Base chain watcher for USDC transfers#59
geminimir merged 2 commits intogeminimir:mainfrom
coryli:feature/base-chain-watcher-usdc-transfers

Conversation

@coryli
Copy link
Contributor

@coryli coryli commented Mar 15, 2026

Summary

Add BaseChainWatcher that subscribes to ERC-20 Transfer events on the Base USDC contract via WebSocket, filtering for transfers to configured merchant deposit addresses.

Changes

  • BaseChainWatcher class with WebSocket subscription to Transfer events via ConnectionManager
  • TransactionStore interface with PostgreSQL and in-memory implementations
  • Filter transfers by destination address (merchant deposit addresses from config)
  • Parse transfer amount (6 decimals), sender, receiver, tx hash, block number
  • Store discovered transactions in chain_transactions table
  • Skip duplicate tx_hash insertions (idempotent)
  • Updated index.ts to use BaseChainWatcher with environment configuration

How to Test

  1. npm ci
  2. npm run typecheck
  3. npm test

For manual testing with real Base network:

export BASE_RPC_URL="https://mainnet.base.org"
export BASE_RPC_WS_URL="wss://mainnet.base.org"
export MERCHANT_ADDRESSES="0x..."
export DATABASE_URL="postgres://..."
npm run dev --workspace=@stripeonchain/chain-watcher

Tests

  • Tests added/updated
  • All tests pass (npm test)
  • Lint passes (npm run lint)
  • Type-check passes (npm run typecheck)
  • Formatting passes (npm run format:check)

Checklist

  • No secrets or credentials committed
  • Migrations run cleanly up and down (npm run migrate:up / npm run migrate:down)
  • Docker Compose starts without errors (docker compose up)

Related Issues

Closes #13

Made with Cursor

coryli and others added 2 commits March 15, 2026 11:27
Add BaseChainWatcher that subscribes to ERC-20 Transfer events on the
Base USDC contract via WebSocket, filtering for transfers to configured
merchant deposit addresses.

Changes:
- BaseChainWatcher class with WebSocket subscription to Transfer events
- TransactionStore interface with PostgreSQL and in-memory implementations
- Filter transfers by destination address (merchant deposit addresses)
- Parse transfer amount (6 decimals), sender, receiver, tx hash, block number
- Store discovered transactions in chain_transactions table
- Skip duplicate tx_hash insertions (idempotent)

Tests:
- Mocked WebSocket delivers Transfer event and tx is stored
- Transfer to non-merchant address is filtered out
- Duplicate tx_hash is not re-inserted

Closes geminimir#13

Made-with: Cursor
@geminimir geminimir merged commit 1817294 into geminimir:main Mar 15, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement Base Chain Watcher: WebSocket subscription to USDC Transfer events

2 participants