Problem
The x402 protocol requires EIP-3009 transferWithAuthorization — an off-chain ECDSA (secp256k1) signature on EIP-712 typed data. This lets a facilitator execute the USDC transfer on-chain on behalf of the client.
The clw.cash enclave currently only supports Schnorr signing for Bitcoin/Ark. The signMessage method in RemoteSignerIdentity explicitly throws on ECDSA:
// remote-signer-identity/src/remoteSignerIdentity.ts:107
if (signatureType === "ecdsa") {
throw new Error("ECDSA signing is not supported by RemoteSignerIdentity");
}
What's needed
- Enclave: Add ECDSA signing endpoint (e.g.
/sign-ecdsa) alongside the existing Schnorr endpoint. Same secp256k1 key, different signature scheme.
- API: Expose ECDSA signing via a new route or extend the existing
/sign endpoint with a signatureType parameter.
- RemoteSignerIdentity: Remove the ECDSA throw, route ECDSA requests to the new endpoint.
- Derive Ethereum address: The existing compressed secp256k1 pubkey can derive an Ethereum address (
keccak256(uncompressedPubKey[1:])[-20:]). Expose this so the agent knows its EVM address.
x402 flow once ECDSA is available
Agent requests URL → gets 402 Payment Required
→ parse PAYMENT-REQUIRED header (amount, token, chain, recipient)
→ swap BTC → USDC to agent's own EVM address (via existing LendaSwap infra)
→ construct EIP-712 typed data for EIP-3009 TransferWithAuthorization
→ hash client-side, send digest to enclave for ECDSA signing
→ retry request with PAYMENT-SIGNATURE header
→ facilitator settles the USDC transfer on-chain
→ agent gets the resource
New CLI command: cash pay <url>
Once ECDSA signing is available, implement:
cash pay <url> — fetch URL, handle 402 automatically, return response body
- Uses
@x402/fetch wrapper or custom implementation
- Integrates with existing
cash send swap infrastructure for the BTC→USDC funding step
Files affected
enclave/src/index.ts — new ECDSA signing route
api/src/index.ts — expose ECDSA signing
remote-signer-identity/src/remoteSignerIdentity.ts — support ECDSA
cli/src/commands/pay.ts — new command (after ECDSA is available)
Reference
Problem
The x402 protocol requires EIP-3009
transferWithAuthorization— an off-chain ECDSA (secp256k1) signature on EIP-712 typed data. This lets a facilitator execute the USDC transfer on-chain on behalf of the client.The clw.cash enclave currently only supports Schnorr signing for Bitcoin/Ark. The
signMessagemethod inRemoteSignerIdentityexplicitly throws on ECDSA:What's needed
/sign-ecdsa) alongside the existing Schnorr endpoint. Same secp256k1 key, different signature scheme./signendpoint with asignatureTypeparameter.keccak256(uncompressedPubKey[1:])[-20:]). Expose this so the agent knows its EVM address.x402 flow once ECDSA is available
New CLI command:
cash pay <url>Once ECDSA signing is available, implement:
cash pay <url>— fetch URL, handle 402 automatically, return response body@x402/fetchwrapper or custom implementationcash sendswap infrastructure for the BTC→USDC funding stepFiles affected
enclave/src/index.ts— new ECDSA signing routeapi/src/index.ts— expose ECDSA signingremote-signer-identity/src/remoteSignerIdentity.ts— support ECDSAcli/src/commands/pay.ts— new command (after ECDSA is available)Reference
@x402/evmpackage withExactEvmScheme