ClawRouter icon indicating copy to clipboard operation
ClawRouter copied to clipboard

feat: add CDP (Coinbase Developer Platform) MPC wallet support

Open skingem1 opened this issue 9 months ago • 1 comments

CDP Wallet Support for ClawRouter

Adds Coinbase Developer Platform (CDP) MPC wallets as an alternative to raw private keys for x402 payments.

Why?

  • MPC-based — no single private key to leak or lose
  • Enterprise-grade — Coinbase-managed backup and recovery
  • Agent-native — programmatic wallet creation via API
  • Fully backward compatible — raw private key still works exactly as before

Changes

New files

  • src/wallet-signer.ts — WalletSigner interface (abstract signing layer)
  • src/wallet-cdp.ts — CDP MPC wallet implementation using @coinbase/coinbase-sdk
  • src/wallet-pk.ts — Raw private key wrapper (satisfies WalletSigner)
  • docs/cdp-wallet.md — Full setup documentation

Updated files

  • src/x402.ts — createPaymentFetch() now accepts WalletSigner | 0x${string}``
  • src/proxy.ts — ProxyOptions accepts optional walletSigner
  • src/index.ts — Auto-detects CDP env vars at startup, falls back to raw key
  • src/auth.ts — New cdpWalletAuth (wizard) + cdpEnvAuth (env vars) methods

Usage

# Set CDP credentials
export BLOCKRUN_CDP_API_KEY_NAME="organizations/xxx/apiKeys/yyy"
export BLOCKRUN_CDP_PRIVATE_KEY="-----BEGIN EC PRIVATE KEY-----\n..."

# ClawRouter auto-detects and uses CDP wallet on startup
openclaw gateway restart

Build

  • ESM ✅
  • DTS ✅
  • Zero breaking changes

skingem1 avatar Feb 26 '26 21:02 skingem1

Thanks for this, and apologies it sat. Closing as not-rebasable rather than not-wanted: it rewrites src/x402.ts and changes createPaymentFetch()'s signature — both of which no longer exist. Main now builds its pay-fetch from x402Client (@x402/fetch) + createPayFetchWithPreAuth, and toClientEvmSigner from @x402/evm is the signer abstraction now. So the seam you wanted exists; it just landed differently.

Two things worth flagging if you or anyone revisits CDP support:

  1. createAndPersistWallet calls wallet.export() and writes the seed in plaintext to ~/.openclaw/blockrun/cdp/wallet.json — which defeats the stated premise of "no single private key to leak".
  2. The EIP-712 path hashes with viem then calls defaultAddress.signHash(hash); there's no test proving a CDP-signed authorization actually settles with the facilitator (v normalization / format).

A fresh PR against @x402/evm's signer interface would be welcome.

VickyXAI avatar Jul 15 '26 04:07 VickyXAI