Skip to content

feat: USDC credit purchasing — stub + demo#91

Open
mmurrs wants to merge 2 commits intomasterfrom
feat/usdc-billing-and-agentkit-funding
Open

feat: USDC credit purchasing — stub + demo#91
mmurrs wants to merge 2 commits intomasterfrom
feat/usdc-billing-and-agentkit-funding

Conversation

@mmurrs
Copy link

@mmurrs mmurrs commented Mar 6, 2026

What this is

A stub demonstrating the proposed USDC credit purchasing flow in the ecloud CLI. Not a final implementation — makes the proposed UX concrete so the team can evaluate it. The billing API backend for USDC credit purchases already exists (PR #22 on ecloud-billing-api).

Problem

ecloud billing only routes through Stripe checkout (credit card). Developers who want to purchase credits with USDC have no CLI path — they'd need to know the contract address independently.

What changed

Command Change What it does
ecloud billing top-up New Executes USDCCredits.purchaseCreditsFor(amount, account) on-chain. Prompts for USDC amount → approves USDC spend → calls purchaseCreditsFor → polls billing API for credit confirmation. Stubbed until contract address is deployed.
ecloud billing subscribe Modified Prompts "Credit card or Purchase credits with USDC?" before Stripe checkout. CC path unchanged. USDC delegates to top-up.
ecloud billing status Modified Adds "Need more credits? Run ecloud billing top-up" when credits < $10 or subscription inactive.
ecloud billing cancel Unchanged

How top-up works

1. Show current credit balance (from billing API)
2. Read wallet USDC balance on Base
3. If no USDC → "Send USDC to <wallet> on Base, then re-run"
4. Prompt: "How much USDC to spend on credits?"
5. USDC.approve(USDCCredits, amount)
6. USDCCredits.purchaseCreditsFor(amount, account)
7. Wait for tx confirmation
8. Poll billing API until credits appear

The user's wallet is already loaded (private key is a prerequisite for all billing commands), so the CLI forms and submits the transaction directly.

Demo

npx tsx demo/billing-flow.ts

What's stubbed

No billing API changes. No new dependencies (viem already in the project).

Related

mmurrs and others added 2 commits March 6, 2026 18:06
Add USDC as a payment option alongside credit cards. Today the billing
flow only routes through Stripe checkout — developers who want to pay
with USDC have no CLI path. This surfaces the on-chain credit purchase
flow that the billing API (PR #22) enables.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The CLI calls approve + purchaseCreditsFor(amount, account) directly
using the user's loaded wallet. Stubbed until the contract address is
deployed, but the full flow is wired: prompt amount → approve USDC →
submit purchaseCreditsFor → poll billing API for credit confirmation.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

1 participant